完善登录逻辑和个人资料完善

This commit is contained in:
2026-05-26 11:29:06 +08:00
parent cecb51a8e2
commit 9680276b3f
27 changed files with 3934 additions and 1572 deletions

View File

@@ -1,16 +1,18 @@
import { getDeliveryProfileByUserId, loginDelivery as loginDeliveryApi } from '@/api/delivery.uts'
import {
acceptOrder as acceptRealServiceOrder,
arriveOrder as arriveRealServiceOrder,
checkinOrder as checkinRealServiceOrder,
departOrder as departRealServiceOrder,
finishOrder as finishRealServiceOrder,
getDashboard as getRealDashboard,
getOrderDetail as getRealServiceOrderDetail,
getOrdersByTab as getRealOrdersByTab,
saveServiceRecord as saveRealServiceRecord,
startService as startRealService
} from '@/services/serviceOrderService.uts'
acceptDeliveryOrderById,
arriveOrderById,
checkinOrderById,
finishServiceById,
getDeliveryDashboardByStaffId,
getDeliveryOrderDetailById,
getDeliveryOrdersByStaffId,
getDeliveryProfileByUserId,
loginDelivery as loginDeliveryApi,
saveServiceProgressById,
startDepartById,
startServiceById
} from '@/api/delivery.uts'
import { saveServiceRecord as saveRealServiceRecord } from '@/services/serviceOrderService.uts'
import {
acceptCareOrder,
checkInCareOrder,
@@ -31,12 +33,13 @@ import {
updateCareOrderStatus,
updateDeliveryCareOnlineStatus
} from '@/mock/delivery-care.mock.uts'
import { getUserInfo, requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
import { requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
import type {
DeliveryAbnormalReportType,
DeliveryCheckinPayloadType,
DeliveryDashboardType,
DeliveryExceptionPayloadType,
DeliveryFinishPayloadType,
DeliveryInfoType,
DeliveryLocationType,
DeliveryLoginPayloadType,
@@ -79,26 +82,51 @@ export async function checkDeliveryAuth(): Promise<boolean> {
return result.ok
}
async function getCurrentStaffId(): Promise<string> {
const profile = await getDeliveryProfile()
if (profile == null) {
return ''
}
return profile.id
}
function createEmptyLocation(): DeliveryLocationType {
return {
latitude: 0,
longitude: 0,
address: '',
time: new Date().toISOString().replace('T', ' ').substring(0, 19)
}
}
export async function getDeliveryDashboard(): Promise<DeliveryDashboardType> {
const staffId = await getCurrentStaffId()
if (staffId != '') {
return await getDeliveryDashboardByStaffId(staffId)
}
return getDeliveryCareDashboard()
}
export async function getDeliveryOrders(params: DeliveryOrderQueryType): Promise<Array<DeliveryOrderType>> {
const staffId = await getCurrentStaffId()
if (staffId != '') {
return await getDeliveryOrdersByStaffId(staffId, params)
}
if (params.tab == 'pending' || params.tab == 'pending_assignment') {
return await getRealOrdersByTab('pending')
return getPendingCareOrders()
}
if (params.tab == 'history' || params.tab == 'completed' || params.tab == 'archive') {
return await getRealOrdersByTab('history')
return getHistoryCareOrders()
}
return await getRealOrdersByTab('today')
return getTodayCareOrders()
}
export async function getDeliveryOrderDetail(id: string): Promise<DeliveryOrderType | null> {
return await getRealServiceOrderDetail(id)
return await getDeliveryOrderDetailById(id)
}
export async function acceptDeliveryOrder(id: string): Promise<DeliveryOrderType | null> {
return await acceptRealServiceOrder(id)
return await acceptDeliveryOrderById(id)
}
export async function rejectDeliveryOrder(id: string, reason: string): Promise<DeliveryOrderType | null> {
@@ -106,30 +134,23 @@ export async function rejectDeliveryOrder(id: string, reason: string): Promise<D
}
export async function startDepart(id: string, location: DeliveryLocationType): Promise<DeliveryOrderType | null> {
return await departRealServiceOrder(id, location)
return await startDepartById(id, location)
}
export async function arriveOrder(id: string, location: DeliveryLocationType): Promise<DeliveryOrderType | null> {
return await arriveRealServiceOrder(id, location)
return await arriveOrderById(id, location)
}
export async function checkinOrder(id: string, payload: DeliveryCheckinPayloadType): Promise<DeliveryOrderType | null> {
return await checkinRealServiceOrder(id, payload)
return await checkinOrderById(id, payload)
}
export async function startService(id: string): Promise<DeliveryOrderType | null> {
return await startRealService(id)
return await startServiceById(id)
}
export async function saveServiceProgress(id: string, payload: DeliveryProgressPayloadType): Promise<DeliveryOrderType | null> {
const current = getCareOrderDetail(id)
if (current == null) {
return null
}
current.serviceItems = payload.items
current.progressNote = payload.progressNote
current.serviceSummary = payload.serviceSummary
return current
return await saveServiceProgressById(id, payload)
}
export async function uploadEvidence(id: string, phase: string, files: Array<string>): Promise<Array<any>> {
@@ -168,8 +189,13 @@ export async function submitException(id: string, payload: DeliveryExceptionPayl
return submitCareAbnormalReport(id, payload)
}
export async function finishService(id: string): Promise<DeliveryOrderType | null> {
return completeCareOrder(id)
export async function finishService(id: string, payload: DeliveryFinishPayloadType | null = null): Promise<DeliveryOrderType | null> {
const finishPayload = payload != null ? payload : {
serviceSummary: '',
signatureName: '',
confirmByFamily: false
} as DeliveryFinishPayloadType
return await finishServiceById(id, finishPayload)
}
export async function getDeliveryRecords(): Promise<Array<DeliveryRecordType>> {
@@ -198,27 +224,27 @@ export async function updateDeliveryOnlineStatus(status: string): Promise<Delive
}
export async function getDeliveryDashboardStats(): Promise<DeliveryDashboardType> {
return await getRealDashboard()
return await getDeliveryDashboard()
}
export async function getPendingServiceOrders(): Promise<Array<DeliveryOrderType>> {
return await getRealOrdersByTab('pending')
return await getDeliveryOrders({ tab: 'pending', keyword: '' } as DeliveryOrderQueryType)
}
export async function getTodayServiceOrders(): Promise<Array<DeliveryOrderType>> {
return await getRealOrdersByTab('today')
return await getDeliveryOrders({ tab: 'today', keyword: '' } as DeliveryOrderQueryType)
}
export async function getHistoryServiceOrders(): Promise<Array<DeliveryOrderType>> {
return await getRealOrdersByTab('history')
return await getDeliveryOrders({ tab: 'history', keyword: '' } as DeliveryOrderQueryType)
}
export async function getServiceOrderDetail(orderId: string): Promise<DeliveryOrderType | null> {
return await getRealServiceOrderDetail(orderId)
return await getDeliveryOrderDetail(orderId)
}
export async function acceptServiceOrder(orderId: string): Promise<DeliveryOrderType | null> {
return await acceptRealServiceOrder(orderId)
return await acceptDeliveryOrder(orderId)
}
export async function rejectServiceOrder(orderId: string, reason: string): Promise<DeliveryOrderType | null> {
@@ -226,18 +252,18 @@ export async function rejectServiceOrder(orderId: string, reason: string): Promi
}
export async function markDeparted(orderId: string): Promise<DeliveryOrderType | null> {
return await departRealServiceOrder(orderId, null)
return await startDepartById(orderId, createEmptyLocation())
}
export async function markArrived(orderId: string): Promise<DeliveryOrderType | null> {
return await arriveRealServiceOrder(orderId, null)
return await arriveOrderById(orderId, createEmptyLocation())
}
export async function checkInServiceOrder(orderId: string, note: string, location: DeliveryLocationType | null = null): Promise<DeliveryOrderType | null> {
if (location == null) {
return null
}
return await checkinRealServiceOrder(orderId, {
return await checkinOrderById(orderId, {
location,
note,
photos: [] as Array<string>,
@@ -246,7 +272,7 @@ export async function checkInServiceOrder(orderId: string, note: string, locatio
}
export async function startServiceOrder(orderId: string): Promise<DeliveryOrderType | null> {
return await startRealService(orderId)
return await startServiceById(orderId)
}
export async function submitServiceRecord(orderId: string, record: DeliveryServiceRecordType): Promise<DeliveryOrderType | null> {
@@ -254,7 +280,7 @@ export async function submitServiceRecord(orderId: string, record: DeliveryServi
}
export async function completeServiceOrder(orderId: string): Promise<DeliveryOrderType | null> {
return await finishRealServiceOrder(orderId)
return await finishService(orderId)
}
export async function submitAbnormalReport(orderId: string, report: DeliveryExceptionPayloadType): Promise<DeliveryOrderType | null> {