解决登录显示、首页显示bug
This commit is contained in:
143
services/deliveryService.uts
Normal file
143
services/deliveryService.uts
Normal file
@@ -0,0 +1,143 @@
|
||||
import {
|
||||
acceptDeliveryOrderById,
|
||||
arriveOrderById,
|
||||
checkinOrderById,
|
||||
finishServiceById,
|
||||
getDeliveryDashboardByStaffId,
|
||||
getDeliveryMessagesList,
|
||||
getDeliveryOrderDetailById,
|
||||
getDeliveryOrdersByStaffId,
|
||||
getDeliveryProfileByUserId,
|
||||
getDeliveryRecordsByStaffId,
|
||||
loginDelivery as loginDeliveryApi,
|
||||
rejectDeliveryOrderById,
|
||||
retryEvidenceById,
|
||||
saveServiceProgressById,
|
||||
startDepartById,
|
||||
startServiceById,
|
||||
submitExceptionById,
|
||||
updateDeliveryOnlineStatusByStaffId,
|
||||
uploadEvidenceById
|
||||
} from '@/api/delivery.uts'
|
||||
import { getDeliveryInfo, getUserInfo, requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
|
||||
import type {
|
||||
DeliveryCheckinPayloadType,
|
||||
DeliveryDashboardType,
|
||||
DeliveryExceptionPayloadType,
|
||||
DeliveryFinishPayloadType,
|
||||
DeliveryInfoType,
|
||||
DeliveryLocationType,
|
||||
DeliveryLoginPayloadType,
|
||||
DeliveryLoginResultType,
|
||||
DeliveryMessageType,
|
||||
DeliveryOrderQueryType,
|
||||
DeliveryOrderType,
|
||||
DeliveryProgressPayloadType,
|
||||
DeliveryRecordType,
|
||||
DeliveryEvidenceRecordType
|
||||
} from '@/types/delivery.uts'
|
||||
|
||||
function getCurrentStaffId(): string {
|
||||
const info = getDeliveryInfo()
|
||||
if (info != null) {
|
||||
return info.id
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
export async function loginDelivery(payload: DeliveryLoginPayloadType): Promise<DeliveryLoginResultType> {
|
||||
return await loginDeliveryApi(payload)
|
||||
}
|
||||
|
||||
export async function getDeliveryProfile(): Promise<DeliveryInfoType | null> {
|
||||
const userInfo = getUserInfo()
|
||||
if (userInfo == null || userInfo.id == null || userInfo.id == '') {
|
||||
return null
|
||||
}
|
||||
return await getDeliveryProfileByUserId(userInfo.id)
|
||||
}
|
||||
|
||||
export async function getDeliveryByUserId(userId: string): Promise<DeliveryInfoType | null> {
|
||||
return await getDeliveryProfileByUserId(userId)
|
||||
}
|
||||
|
||||
export async function getCurrentDeliverer(): Promise<DeliveryInfoType | null> {
|
||||
return await getDeliveryProfile()
|
||||
}
|
||||
|
||||
export async function checkDeliveryAccountByUserId(userId: string): Promise<DeliveryInfoType | null> {
|
||||
return await getDeliveryProfileByUserId(userId)
|
||||
}
|
||||
|
||||
export async function checkDeliveryAuth(): Promise<boolean> {
|
||||
const result = await requireDeliveryAuth({ redirectOnFail: false, toastOnFail: false })
|
||||
return result.ok
|
||||
}
|
||||
|
||||
export async function getDeliveryDashboard(): Promise<DeliveryDashboardType> {
|
||||
return await getDeliveryDashboardByStaffId(getCurrentStaffId())
|
||||
}
|
||||
|
||||
export async function getDeliveryOrders(params: DeliveryOrderQueryType): Promise<Array<DeliveryOrderType>> {
|
||||
return await getDeliveryOrdersByStaffId(getCurrentStaffId(), params)
|
||||
}
|
||||
|
||||
export async function getDeliveryOrderDetail(id: string): Promise<DeliveryOrderType | null> {
|
||||
return await getDeliveryOrderDetailById(id)
|
||||
}
|
||||
|
||||
export async function acceptDeliveryOrder(id: string): Promise<DeliveryOrderType | null> {
|
||||
return await acceptDeliveryOrderById(id)
|
||||
}
|
||||
|
||||
export async function rejectDeliveryOrder(id: string, reason: string): Promise<DeliveryOrderType | null> {
|
||||
return await rejectDeliveryOrderById(id, reason)
|
||||
}
|
||||
|
||||
export async function startDepart(id: string, location: DeliveryLocationType): Promise<DeliveryOrderType | null> {
|
||||
return await startDepartById(id, location)
|
||||
}
|
||||
|
||||
export async function arriveOrder(id: string, location: DeliveryLocationType): Promise<DeliveryOrderType | null> {
|
||||
return await arriveOrderById(id, location)
|
||||
}
|
||||
|
||||
export async function checkinOrder(id: string, payload: DeliveryCheckinPayloadType): Promise<DeliveryOrderType | null> {
|
||||
return await checkinOrderById(id, payload)
|
||||
}
|
||||
|
||||
export async function startService(id: string): Promise<DeliveryOrderType | null> {
|
||||
return await startServiceById(id)
|
||||
}
|
||||
|
||||
export async function saveServiceProgress(id: string, payload: DeliveryProgressPayloadType): Promise<DeliveryOrderType | null> {
|
||||
return await saveServiceProgressById(id, payload)
|
||||
}
|
||||
|
||||
export async function uploadEvidence(id: string, phase: string, files: Array<string>): Promise<Array<DeliveryEvidenceRecordType>> {
|
||||
return await uploadEvidenceById(id, phase, files)
|
||||
}
|
||||
|
||||
export async function retryUploadEvidence(id: string, evidenceId: string): Promise<DeliveryEvidenceRecordType | null> {
|
||||
return await retryEvidenceById(id, evidenceId)
|
||||
}
|
||||
|
||||
export async function submitException(id: string, payload: DeliveryExceptionPayloadType): Promise<DeliveryOrderType | null> {
|
||||
return await submitExceptionById(id, payload)
|
||||
}
|
||||
|
||||
export async function finishService(id: string, payload: DeliveryFinishPayloadType): Promise<DeliveryOrderType | null> {
|
||||
return await finishServiceById(id, payload)
|
||||
}
|
||||
|
||||
export async function getDeliveryRecords(): Promise<Array<DeliveryRecordType>> {
|
||||
return await getDeliveryRecordsByStaffId(getCurrentStaffId())
|
||||
}
|
||||
|
||||
export async function getDeliveryMessages(): Promise<Array<DeliveryMessageType>> {
|
||||
return await getDeliveryMessagesList()
|
||||
}
|
||||
|
||||
export async function updateDeliveryOnlineStatus(status: string): Promise<DeliveryInfoType | null> {
|
||||
return await updateDeliveryOnlineStatusByStaffId(getCurrentStaffId(), status)
|
||||
}
|
||||
Reference in New Issue
Block a user