完善服务模块缺少付款页的bug
This commit is contained in:
@@ -175,6 +175,7 @@ import { onHide, onLoad, onShow, onUnload } from '@dcloudio/uni-app'
|
||||
import { supabaseService } from '@/utils/supabaseService.uts'
|
||||
import { goToLogin } from '@/utils/utils.uts'
|
||||
import { formatCountdownHM, getRemainingSeconds, getUnifiedDisplayState, isOrderPayExpired, isPendingPayOrder, ORDER_STATUS_CANCELLED, ORDER_STATUS_PENDING, ORDER_STATUS_TIMEOUT_LEGACY, ORDER_TIMEOUT_CANCEL_REASON, PAYMENT_STATUS_TIMEOUT, PAYMENT_STATUS_UNPAID, type OrderStatusSource } from '@/utils/orderStatus.uts'
|
||||
import { dispatchPaidHomecareOrder, showHomecareDispatchFailureModal } from '@/services/serviceOrderService.uts'
|
||||
|
||||
type BusinessTabItem = {
|
||||
id: string,
|
||||
@@ -223,7 +224,9 @@ type OrderItem = {
|
||||
merchant_id: string,
|
||||
shop_name: string,
|
||||
products: OrderProduct[],
|
||||
service_info: UnifiedServiceInfo | null
|
||||
service_info: UnifiedServiceInfo | null,
|
||||
dispatch_status: string,
|
||||
dispatch_error_message: string
|
||||
}
|
||||
|
||||
type UnifiedOrdersCursorResult = {
|
||||
@@ -713,7 +716,9 @@ const mapRawOrdersToViewModels = (rawOrders: UTSJSONObject[]): OrderItem[] => {
|
||||
merchant_id: merchantId ?? '',
|
||||
shop_name: shopName,
|
||||
products: productsList,
|
||||
service_info: serviceInfo
|
||||
service_info: serviceInfo,
|
||||
dispatch_status: orderObj.getString('dispatch_status') ?? '',
|
||||
dispatch_error_message: orderObj.getString('dispatch_error_message') ?? ''
|
||||
})
|
||||
}
|
||||
return mappedOrders
|
||||
@@ -1333,7 +1338,11 @@ const getOrderStatusText = (order: OrderItem): string => {
|
||||
if (displayState == 'cancelled' || displayState == 'expired') return '已取消'
|
||||
|
||||
if (order.biz_type === 'service') {
|
||||
if (order.status == 1) return '待付款'
|
||||
if (order.payment_status == 1 && order.status == 1) return '待付款'
|
||||
if (order.payment_status == 2 && (order.dispatch_status == 'pending' || order.dispatch_status == '')) return '待派单'
|
||||
if (order.payment_status == 2 && order.dispatch_status == 'dispatching') return '正在派单'
|
||||
if (order.payment_status == 2 && order.dispatch_status == 'failed') return '派单未成功'
|
||||
if (order.payment_status == 2 && order.dispatch_status == 'assigned') return '已派单'
|
||||
if (order.status == 2) return '待接单'
|
||||
if (order.status == 3) return '待服务'
|
||||
if (order.status == 4) return '服务中'
|
||||
@@ -1648,6 +1657,50 @@ const rebookService = (order: OrderItem) => {
|
||||
uni.showToast({ title: '暂无可预约服务', icon: 'none' })
|
||||
}
|
||||
|
||||
let isRedispatching = false
|
||||
|
||||
const redispatchServiceOrder = async (order: OrderItem) => {
|
||||
if (isRedispatching) {
|
||||
return
|
||||
}
|
||||
isRedispatching = true
|
||||
uni.showLoading({ title: '正在重新派单', mask: true })
|
||||
try {
|
||||
const result = await dispatchPaidHomecareOrder(order.id)
|
||||
uni.hideLoading()
|
||||
if (result.success) {
|
||||
uni.showToast({ title: '派单成功', icon: 'success' })
|
||||
setTimeout(() => {
|
||||
uni.navigateTo({ url: `/pages/mall/consumer/home-service/order-detail?id=${order.id}` })
|
||||
}, 800)
|
||||
return
|
||||
}
|
||||
showHomecareDispatchFailureModal(order.id, result, (id: string) => {
|
||||
const targetOrder = getLoadedOrderById(id)
|
||||
if (targetOrder != null) {
|
||||
redispatchServiceOrder(targetOrder)
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
uni.hideLoading()
|
||||
console.error('[redispatchServiceOrder] 重新派单异常:', e)
|
||||
uni.showModal({
|
||||
title: '派单服务异常',
|
||||
content: '派单服务暂时异常,请稍后重试',
|
||||
showCancel: true,
|
||||
cancelText: '稍后再试',
|
||||
confirmText: '重新派单',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
redispatchServiceOrder(order)
|
||||
}
|
||||
}
|
||||
})
|
||||
} finally {
|
||||
isRedispatching = false
|
||||
}
|
||||
}
|
||||
|
||||
const viewSimilarService = (order: OrderItem) => {
|
||||
const serviceName = order.service_info != null ? order.service_info.service_name : ''
|
||||
const url = serviceName != ''
|
||||
@@ -1727,6 +1780,11 @@ const getOrderActions = (order: OrderItem): OrderActionItem[] => {
|
||||
}
|
||||
|
||||
if (order.biz_type === 'service') {
|
||||
if (order.payment_status == 2 && order.dispatch_status == 'failed') {
|
||||
actions.push({ id: 'view-detail', name: '查看详情', kind: 'secondary' })
|
||||
actions.push({ id: 'redispatch', name: '重新派单', kind: 'primary' })
|
||||
return actions
|
||||
}
|
||||
if (order.status === 2) {
|
||||
actions.push({ id: 'cancel', name: '取消预约', kind: 'secondary' })
|
||||
actions.push({ id: 'contact-service', name: '联系客服', kind: 'secondary' })
|
||||
@@ -1797,6 +1855,8 @@ const onOrderActionTap = (order: OrderItem, actionId: string) => {
|
||||
uni.showToast({ title: '服务评价功能待接入', icon: 'none' })
|
||||
} else if (actionId === 'rebook') {
|
||||
rebookService(order)
|
||||
} else if (actionId === 'redispatch') {
|
||||
redispatchServiceOrder(order)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user