继续完善居家服务模块

This commit is contained in:
2026-05-22 10:16:51 +08:00
parent 3a7b2808af
commit d25f80ccdd
10 changed files with 670 additions and 110 deletions

View File

@@ -39,8 +39,8 @@
<text class="stat-label">服务中</text>
</view>
<view class="stat-item">
<text class="stat-value money">{{ incomeText }}</text>
<text class="stat-label">预计收入</text>
<text class="stat-value">{{ dashboard.completedCount }}</text>
<text class="stat-label">已完成</text>
</view>
</view>
</view>
@@ -89,7 +89,7 @@ import { computed, ref } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import ServicePageScaffold from '@/components/homeService/ServicePageScaffold.uvue'
import type { DeliveryInfoType } from '@/types/delivery.uts'
import { acceptServiceOrder, getDeliveryDashboardStats, getDeliveryProfile, markDeparted } from '@/services/deliveryService.uts'
import { acceptServiceOrder, getDeliveryDashboardStats, getDeliveryProfile } from '@/services/deliveryService.uts'
import { getNextStepText, getPrimaryActionText } from '@/utils/deliveryCareUi.uts'
import { requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
@@ -117,7 +117,6 @@ const onlineText = computed((): string => {
if (profile.value.onlineStatus == 'busy') return '忙碌'
return '离线'
})
const incomeText = computed((): string => '¥' + String(dashboard.value.expectedIncome))
const nextActionText = computed((): string => dashboard.value.nextOrder == null ? '查看详情' : getPrimaryActionText(dashboard.value.nextOrder!.status))
const nextStepText = computed((): string => dashboard.value.nextOrder == null ? '暂无' : getNextStepText(dashboard.value.nextOrder!.status))
const nextStatusText = computed((): string => dashboard.value.nextOrder == null ? '' : dashboard.value.nextOrder!.statusText)
@@ -172,9 +171,7 @@ async function handleOrderAction(orderId: string) {
return
}
if (order.status == 'accepted' || order.status == 'waiting_departure') {
await markDeparted(orderId)
uni.showToast({ title: '已标记出发', icon: 'success' })
loadData()
uni.navigateTo({ url: '/pages/mall/delivery/orders/route?id=' + orderId })
return
}
goDetail(orderId)

View File

@@ -127,7 +127,7 @@ async function submitCheckin() {
checkinMode: 'gps'
})
uni.showToast({ title: '签到成功', icon: 'success' })
uni.navigateTo({ url: '/pages/mall/delivery/orders/execute?id=' + orderId.value })
uni.redirectTo({ url: '/pages/mall/delivery/service-record/index?id=' + orderId.value })
} finally {
submitting.value = false
}

View File

@@ -92,15 +92,10 @@ import ServicePageScaffold from '@/components/homeService/ServicePageScaffold.uv
import type { DeliveryOrderType } from '@/types/delivery.uts'
import {
acceptServiceOrder,
checkInServiceOrder,
completeServiceOrder,
getServiceOrderDetail,
markArrived,
markDeparted,
rejectServiceOrder,
startServiceOrder
rejectServiceOrder
} from '@/services/deliveryService.uts'
import { getNextStepText, getPrimaryActionText, needsServiceRecord } from '@/utils/deliveryCareUi.uts'
import { getNextStepText, getPrimaryActionText } from '@/utils/deliveryCareUi.uts'
import { requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
import { getDeliveryRouteParam } from '@/utils/deliveryRoute.uts'
@@ -129,7 +124,10 @@ function makePhoneCall(phone: string) {
}
function mockNavigate() {
uni.showToast({ title: '导航为 mock 占位', icon: 'none' })
if (order.value == null) {
return
}
uni.navigateTo({ url: '/pages/mall/delivery/orders/route?id=' + order.value!.id })
}
function goException() {
@@ -164,27 +162,15 @@ async function handlePrimary() {
return
}
if (status == 'accepted' || status == 'waiting_departure') {
await markDeparted(orderId.value)
uni.showToast({ title: '已出发', icon: 'success' })
loadData()
uni.navigateTo({ url: '/pages/mall/delivery/orders/route?id=' + orderId.value })
return
}
if (status == 'departed' || status == 'on_the_way') {
await markArrived(orderId.value)
uni.showToast({ title: '已到达', icon: 'success' })
loadData()
uni.navigateTo({ url: '/pages/mall/delivery/orders/route?id=' + orderId.value })
return
}
if (status == 'arrived') {
await checkInServiceOrder(orderId.value, '详情页签到', null)
uni.showToast({ title: '签到成功', icon: 'success' })
loadData()
return
}
if (status == 'checked_in') {
await startServiceOrder(orderId.value)
uni.showToast({ title: '开始服务', icon: 'success' })
loadData()
uni.navigateTo({ url: '/pages/mall/delivery/orders/checkin?id=' + orderId.value })
return
}
if (status == 'in_service' || status == 'serving' || status == 'completed') {
@@ -192,14 +178,7 @@ async function handlePrimary() {
return
}
if (status == 'pending_confirm' || status == 'pending_acceptance' || status == 'pending_submit') {
if (needsServiceRecord(order.value)) {
uni.showToast({ title: '请先填写服务记录', icon: 'none' })
goRecord()
return
}
await completeServiceOrder(orderId.value)
uni.showToast({ title: '服务已完成', icon: 'success' })
loadData()
uni.showToast({ title: '已完成服务,等待用户验收', icon: 'none' })
return
}
if (status == 'abnormal' || status == 'exception_pending') {

View File

@@ -43,15 +43,10 @@ import ServicePageScaffold from '@/components/homeService/ServicePageScaffold.uv
import type { DeliveryOrderStatus, DeliveryOrderType } from '@/types/delivery.uts'
import {
acceptServiceOrder,
checkInServiceOrder,
completeServiceOrder,
getHistoryServiceOrders,
getPendingServiceOrders,
getTodayServiceOrders,
markArrived,
markDeparted,
rejectServiceOrder,
startServiceOrder
rejectServiceOrder
} from '@/services/deliveryService.uts'
import { getDeliveryOrderTabs, getPrimaryActionText } from '@/utils/deliveryCareUi.uts'
import { requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
@@ -137,27 +132,15 @@ async function handleAction(orderId: string, status: DeliveryOrderStatus) {
return
}
if (status == 'accepted' || status == 'waiting_departure') {
await markDeparted(orderId)
uni.showToast({ title: '已标记出发', icon: 'success' })
loadData()
uni.navigateTo({ url: '/pages/mall/delivery/orders/route?id=' + orderId })
return
}
if (status == 'departed' || status == 'on_the_way') {
await markArrived(orderId)
uni.showToast({ title: '已标记到达', icon: 'success' })
loadData()
uni.navigateTo({ url: '/pages/mall/delivery/orders/route?id=' + orderId })
return
}
if (status == 'arrived') {
await checkInServiceOrder(orderId, '已到达并签到', null)
uni.showToast({ title: '签到成功', icon: 'success' })
loadData()
return
}
if (status == 'checked_in') {
await startServiceOrder(orderId)
uni.showToast({ title: '已开始服务', icon: 'success' })
loadData()
uni.navigateTo({ url: '/pages/mall/delivery/orders/checkin?id=' + orderId })
return
}
if (status == 'in_service' || status == 'serving' || status == 'completed') {
@@ -165,13 +148,7 @@ async function handleAction(orderId: string, status: DeliveryOrderStatus) {
return
}
if (status == 'pending_confirm' || status == 'pending_acceptance' || status == 'pending_submit') {
const result = await completeServiceOrder(orderId)
if (result == null) {
uni.showToast({ title: '请先填写服务记录', icon: 'none' })
return
}
uni.showToast({ title: '服务已完成', icon: 'success' })
loadData()
uni.showToast({ title: '已完成服务,等待用户验收', icon: 'none' })
return
}
goDetail(orderId)

View File

@@ -60,7 +60,7 @@ import { computed, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import ServicePageScaffold from '@/components/homeService/ServicePageScaffold.uvue'
import type { DeliveryOrderType, DeliveryServiceItemType, DeliveryServiceRecordType } from '@/types/delivery.uts'
import { getServiceOrderDetail, submitServiceRecord } from '@/services/deliveryService.uts'
import { completeServiceOrder, getServiceOrderDetail, startServiceOrder, submitServiceRecord } from '@/services/deliveryService.uts'
import { requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
import { getDeliveryRouteParam } from '@/utils/deliveryRoute.uts'
@@ -145,6 +145,9 @@ async function submitRecordAction() {
if (!validateRecord()) {
return
}
if (order.value != null && order.value.status != 'in_service' && order.value.status != 'serving') {
await startServiceOrder(orderId.value)
}
const record = {
id: 'record-' + orderId.value,
orderId: orderId.value,
@@ -176,7 +179,8 @@ async function submitRecordAction() {
updatedAt: new Date().toISOString().replace('T', ' ').substring(0, 19)
} as DeliveryServiceRecordType
await submitServiceRecord(orderId.value, record)
uni.showToast({ title: '服务记录已提交', icon: 'success' })
await completeServiceOrder(orderId.value)
uni.showToast({ title: '服务记录已提交,等待验收', icon: 'success' })
setTimeout(() => {
uni.redirectTo({ url: '/pages/mall/delivery/orders/detail?id=' + orderId.value })
}, 300)