调试订单接口

This commit is contained in:
wangxiaowei
2026-01-02 03:10:07 +08:00
parent 83a2b4da9d
commit dd8e9f9168
5 changed files with 187 additions and 149 deletions

View File

@ -78,4 +78,26 @@ export function acceptTeaSpecialistOrder(id: number) {
*/ */
export function departTeaSpecialistOrder(id: number) { export function departTeaSpecialistOrder(id: number) {
return http.Post<any>('/teamapi/order/orderDepart', { id }) return http.Post<any>('/teamapi/order/orderDepart', { id })
}
/**
* 茶艺师已到达
* @param id 订单ID
*/
export interface ArriveTeaSpecialistOrderParams {
id: number
longitude: number
latitude: number
}
export function arriveTeaSpecialistOrder(data: ArriveTeaSpecialistOrderParams) {
return http.Post<any>('/teamapi/order/orderArrive', data)
}
/**
* 茶艺师打卡
* @param id 订单ID
* @param img 图片(/teamapi/order/orderImage.png)
*/
export function checkInTeaSpecialistOrder(id: number, img: string) {
return http.Post<any>('/teamapi/order/orderImage', { id, img })
} }

View File

@ -1,10 +1,12 @@
import { router } from '@/utils/tools' import { router } from '@/utils/tools'
import { acceptTeaSpecialistOrder } from '@/api/tes-specialist' import { acceptTeaSpecialistOrder, departTeaSpecialistOrder, arriveTeaSpecialistOrder } from '@/api/tes-specialist'
import { l } from 'vite/dist/node/types.d-aGj9QkWt'
/** /**
* 茶艺师接单 * 茶艺师接单
* @param id 订单ID * @param id 订单ID
* @param type 来源于订单详情页还是订单列表页
*/ */
export async function handleReleaseOrderHooks(id: number) { export async function handleReleaseOrderHooks(id: number) {
try { try {
@ -21,10 +23,23 @@ export async function handleReleaseOrderHooks(id: number) {
*/ */
export async function handleDepartOrderHooks(id: number) { export async function handleDepartOrderHooks(id: number) {
try { try {
await acceptTeaSpecialistOrder(id) await departTeaSpecialistOrder(id)
return true return true
} }
catch (error) { catch (error) {
return false return false
} }
} }
/**
* 茶艺师已到达
*/
export async function handleArriveOrderHooks(data: {id: number, longitude: number, latitude: number}) {
try {
await arriveTeaSpecialistOrder(data)
return true
}
catch (error) {
return false
}
}

View File

@ -42,15 +42,27 @@
</view> </view>
<view class="steps"> <view class="steps">
<wd-steps :active="stepsActive" vertical dot> <wd-steps :active="stepsActive" vertical dot>
<wd-step title="客户下订单" :description="order.dtime" /> <wd-step title="客户下订单" :description="order.dtime">
<wd-step title="茶艺师接单" :description="order.take_order_time" /> <template #description>
<wd-step title="茶艺师出发" :description="order.travel_time" /> <view >{{ order.dtime }}</view>
</template>
</wd-step>
<wd-step title="茶艺师接单" :description="order.take_order_time" >
<template #description>
<view >{{ order.take_order_time }}</view>
</template>
</wd-step>
<wd-step title="茶艺师出发" >
<template #description>
<view >{{ order.travel_time }}</view>
</template>
</wd-step>
<wd-step title="茶艺师到达"> <wd-step title="茶艺师到达">
<template #description> <template #description>
<view class="" v-if="order.image"> <view class="" v-if="order.image">
<wd-img width="120rpx" height='80rpx' :src="order.image" radius="8rpx"></wd-img> <wd-img width="120rpx" height='80rpx' :src="order.image" radius="8rpx"></wd-img>
</view> </view>
<view class="">{{ order.arrival_time }}</view> <view >{{ order.arrival_time }}</view>
</template> </template>
</wd-step> </wd-step>
<wd-step title="服务完成" /> <wd-step title="服务完成" />
@ -254,7 +266,7 @@
</view> </view>
<view class="info-item"> <view class="info-item">
<text class="info-label">预约时长:</text> <text class="info-label">预约时长:</text>
<text class="info-value">{{ order.hours }}</text> <text class="info-value">{{ order.hours }}小时</text>
</view> </view>
</view> </view>
</view> </view>
@ -284,7 +296,7 @@
<view class="mt-16rpx"> <view class="mt-16rpx">
<view class="info-item"> <view class="info-item">
<text class="info-label">续单时长</text> <text class="info-label">续单时长</text>
<text class="info-value">{{ order.renew_hours || 0 }}/小时</text> <text class="info-value">{{ order.renew_hours || 0 }}小时</text>
</view> </view>
<view class="info-item"> <view class="info-item">
<text class="info-label">续单金额</text> <text class="info-label">续单金额</text>
@ -378,9 +390,9 @@
</view> </view>
<view class="info-item flex justify-between items-center"> <view class="info-item flex justify-between items-center">
<text class="info-label">订单编号</text> <text class="info-label">订单编号</text>
<view class="order-sn-wrapper"> <view class="order-sn-wrapper flex items-center justify-between">
<text class="info-value">{{ order.order_sn }}</text> <view class="info-value">{{ order.order_sn }}</view>
<text class="copy-text" @click.stop="copy(order.order_sn)">|复制</text> <view class="copy-text" @click.stop="copy(order.order_sn)">| 复制</view>
</view> </view>
</view> </view>
<view class="info-item flex items-center justify-between" v-if="order.pay_title"> <view class="info-item flex items-center justify-between" v-if="order.pay_title">
@ -405,7 +417,7 @@
<!-- 待接单 --> <!-- 待接单 -->
<template v-if="orderStatus === TeaSpecialistOrderStatus.Pending"> <template v-if="orderStatus === TeaSpecialistOrderStatus.Pending">
<view class="w-112rpx h-90rpx text-[#606266] text-28rpx leading-90rpx" @click="Detail.handleAbandonOrder">放弃接单</view> <view class="w-112rpx h-90rpx text-[#606266] text-28rpx leading-90rpx" @click="Detail.handleAbandonOrder">放弃接单</view>
<view class="w-360rpx h-90rpx bg-[#4C9F44] rounded-8rpx text-[#fff] text-center leading-90rpx">立即接单</view> <view class="w-360rpx h-90rpx bg-[#4C9F44] rounded-8rpx text-[#fff] text-center leading-90rpx" @click="Detail.handleaAcceptOrder">立即接单</view>
</template> </template>
<!-- 待服务 --> <!-- 待服务 -->
@ -415,7 +427,7 @@
<!-- 已出发 --> <!-- 已出发 -->
<template v-if="orderStatus === TeaSpecialistOrderStatus.Departed"> <template v-if="orderStatus === TeaSpecialistOrderStatus.Departed">
<view class="w-630rpx h-90rpx bg-[#4C9F44] rounded-8rpx text-[#fff] text-center leading-90rpx" @click="Detail.handleToTakePhone">已到达</view> <view class="w-630rpx h-90rpx bg-[#4C9F44] rounded-8rpx text-[#fff] text-center leading-90rpx" @click="Detail.handleArrived">已到达</view>
</template> </template>
<!-- 服务中 --> <!-- 服务中 -->
@ -440,13 +452,15 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useMessage } from 'wot-design-uni' import { useMessage, useToast } from 'wot-design-uni'
import PriceFormat from '@/components/PriceFormat.vue' import PriceFormat from '@/components/PriceFormat.vue'
import { copy } from '@/utils/tools' import { copy } from '@/utils/tools'
import { TeaSpecialistOrderStatus, TeaSpecialistManageStatusTextValue } from '@/utils/teaSpecialistOrder' import { TeaSpecialistOrderStatus, TeaSpecialistManageStatusTextValue } from '@/utils/teaSpecialistOrder'
import { getTeaSpecialistOrderDetails } from '@/api/tes-specialist' import { getTeaSpecialistOrderDetails } from '@/api/tes-specialist'
import { handleReleaseOrderHooks, handleDepartOrderHooksm, handleDepartOrderHooks } from '@/hooks/useOrder'
const OSS = inject('OSS') const OSS = inject('OSS')
const toast = useToast()
// navbar 标题 // navbar 标题
const title = ref<string>('') const title = ref<string>('')
@ -473,26 +487,6 @@
// 费用明细弹窗 // 费用明细弹窗
const showCostDetailPopup = ref(false) const showCostDetailPopup = ref(false)
// 费用明细数据
const costDetail = ref({
orderTotal: 828.90,
serviceFee: 640.00,
serviceFeePerHour: 160,
serviceHours: 4,
travelFee: 30.90,
travelFeePerKm: 3.00,
distance: 10.3,
teaServiceFee: 178.00,
teaName: '红茶/绿茶/福鼎白茶/铁观音',
teaPrice: 158,
teawarePrice: 20,
discount: 20.00,
couponDiscount: 20,
deductFee: 130.00,
platformFee: 130.00,
actualIncome: 698.90,
})
// 订单数据 // 订单数据
const order = ref({ const order = ref({
id: 0, id: 0,
@ -625,6 +619,34 @@
} }
}, },
/**
* 立即接单
*/
handleaAcceptOrder: () => {
message.confirm({
title: '确定接单?',
msg: '请务必提前确认服务日程,妥善安排好时间',
confirmButtonText: '确定',
cancelButtonText: '取消',
cancelButtonProps: {
customClass: '!bg-[#F6F7F8] !text-[#303133] !text-32rpx !leading-44rpx !rounded-8rpx',
},
confirmButtonProps: {
customClass: '!bg-[#4C9F44] !text-[#fff] !text-32rpx !leading-44rpx !rounded-8rpx',
},
}).then(async (res) => {
if (res.action === 'confirm') {
toast.loading('加载中...')
const res = await handleReleaseOrderHooks(order.value.id)
toast.close()
if (res) {
Detail.handleInit()
}
}
}).catch(() => {})
},
/** /**
* 放弃接单 * 放弃接单
*/ */
@ -654,8 +676,8 @@
*/ */
handleToGo: () => { handleToGo: () => {
message.confirm({ message.confirm({
title: '开启定位服务', title: '提示',
msg: '需要开启手机定位功能,以记录本次服务的出发状态', msg: '是否立即出发',
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
cancelButtonProps: { cancelButtonProps: {
@ -664,9 +686,15 @@
confirmButtonProps: { confirmButtonProps: {
customClass: '!bg-[#4C9F44] !text-[#fff] !text-32rpx !leading-44rpx !rounded-8rpx', customClass: '!bg-[#4C9F44] !text-[#fff] !text-32rpx !leading-44rpx !rounded-8rpx',
} }
}).then((res) => { }).then(async(res) => {
if (res.action == 'confirm') { if (res.action === 'confirm') {
// TODO 这里需要获取经纬度 toast.loading('加载中...')
const res = await handleDepartOrderHooks(order.value.id)
toast.close()
if (res) {
Detail.handleInit()
}
} }
}).catch(() => { }).catch(() => {
// 点击取消按钮回调事件 // 点击取消按钮回调事件
@ -676,10 +704,10 @@
/** /**
* 已到达 * 已到达
*/ */
handleToTakePhone: () => { handleArrived: () => {
message.confirm({ message.confirm({
title: '确定到达', title: '提示',
msg: '确认到达后需拍照记录,否则无法开始服务计时', msg: '是否确认到达目的地',
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
cancelButtonProps: { cancelButtonProps: {
@ -687,15 +715,27 @@
}, },
confirmButtonProps: { confirmButtonProps: {
customClass: '!bg-[#4C9F44] !text-[#fff] !text-32rpx !leading-44rpx !rounded-8rpx', customClass: '!bg-[#4C9F44] !text-[#fff] !text-32rpx !leading-44rpx !rounded-8rpx',
} },
}).then((res) => { }).then(async (res) => {
if (res.action == 'confirm') { if (res.action === 'confirm') {
// TODO 这里需要获取经纬度及拍照 const location = await handleGetLocationFallback()
if (location.lat && location.lng) {
toast.loading('加载中...')
const res = await handleArriveOrderHooks({
id: order.value.id,
longitude: location.lng,
latitude: location.lat,
})
toast.close()
if (res) {
Detail.handleInit()
}
} else {
toast.show('获取位置信息失败,请检查定位权限是否开启')
}
} }
}).catch(() => { }).catch(() => {})
// 点击取消按钮回调事件
})
}, },
/** /**

View File

@ -114,7 +114,6 @@
import type { ITeaSpecialistOrderDetailsResult } from '@/api/types/tea' import type { ITeaSpecialistOrderDetailsResult } from '@/api/types/tea'
import { copy } from '@/utils/tools' import { copy } from '@/utils/tools'
import { getOrderStoreDetail } from '@/api/order' import { getOrderStoreDetail } from '@/api/order'
import { handleReleaseTeaRoomOrderHookds, handleCancelOrderHooks } from '@/hooks/useOrder'
const title = ref<string>('') const title = ref<string>('')

View File

@ -69,7 +69,7 @@
<!-- 价格 --> <!-- 价格 -->
<view class="mb-24rpx"> <view class="mb-24rpx">
<text class="service-type" :class="getServiceTypeClass(order.server_type)"> <text class="service-type" :class="Order.handleGetServiceTypeClass(order.server_type)">
{{ order.server_type == 1 ? '到店服务' : '上门服务' }} {{ order.server_type == 1 ? '到店服务' : '上门服务' }}
</text> </text>
</view> </view>
@ -109,7 +109,7 @@
import { TeaSpecialistManageOrderStatusText, TeaSpecialistOrderStatus, TeaSpecialistManageStatusTextValue } from '@/utils/teaSpecialistOrder' import { TeaSpecialistManageOrderStatusText, TeaSpecialistOrderStatus, TeaSpecialistManageStatusTextValue } from '@/utils/teaSpecialistOrder'
import { getTeaSpecialistOrderList } from '@/api/tes-specialist' import { getTeaSpecialistOrderList } from '@/api/tes-specialist'
import { handleGetLocationFallback } from '@/hooks/useLocation' import { handleGetLocationFallback } from '@/hooks/useLocation'
import { handleReleaseOrderHooks } from '@/hooks/useOrder' import { handleReleaseOrderHooks, handleDepartOrderHooks, handleArriveOrderHooks } from '@/hooks/useOrder'
const OSS = inject('OSS') const OSS = inject('OSS')
const toast = useToast() const toast = useToast()
@ -126,100 +126,20 @@
const orderStatus = ref<string>('') const orderStatus = ref<string>('')
const list = ref<Array<any>>([]) // 茶室列表 const list = ref<Array<any>>([]) // 茶室列表
const keywords = ref<string>('') // 搜索关键词 const keywords = ref<string>('') // 搜索关键词
const canReset = ref<boolean>(false) // 第一次onShow避免与自动下拉刷新冲突
// 消息提示框 // 消息提示框
const message = useMessage('wd-message-box-slot') const message = useMessage('wd-message-box-slot')
// 当前选中的标签 // 当前选中的标签
const activeTab = ref('all') const activeTab = ref('all')
// 模拟订单数据 onShow(() => {
const orders = ref<Array<any>>([ if (canReset.value) {
{ Order.handleSearch()
id: 1, }
serviceName: '苓苑共享茶室空间', canReset.value = true
serviceType: '到店服务', })
status: 'pending',
statusText: '待接单',
price: 212.20,
appointmentTime: '09/03 08:00-12:00',
address: '上海浦东新区新金桥路58号新银东大厦15楼F室',
timer: 30 * 60 * 60 * 1000,
},
{
id: 2,
serviceName: '韩梅梅预约单',
serviceType: '上门服务',
status: 'waiting',
statusText: '待服务',
price: 212.20,
appointmentTime: '09/03 08:00-12:00',
address: '上海浦东新区新金桥路58号新银东大厦15楼F室',
},
{
id: 3,
serviceName: '韩梅梅预约单',
serviceType: '上门服务',
status: 'waiting_arrived',
statusText: '待服务',
price: 212.20,
appointmentTime: '09/03 08:00-12:00',
address: '上海浦东新区新金桥路58号新银东大厦15楼F室',
timer: '30 * 60 * 60 * 1000',
},
{
id: 4,
serviceName: '韩梅梅预约单',
serviceType: '上门服务',
status: 'serving',
statusText: '服务中',
price: 212.20,
appointmentTime: '09/03 08:00-12:00',
address: '上海浦东新区新金桥路58号新银东大厦15楼F室',
timer: '99:52',
},
{
id: 5,
serviceName: '韩梅梅预约单',
serviceType: '上门服务',
status: 'serving',
statusText: '服务中',
price: 212.20,
appointmentTime: '09/03 08:00-12:00',
address: '上海浦东新区新金桥路58号新银东大厦15楼F室',
timer: '00:00',
},
{
id: 6,
serviceName: '韩梅梅预约单',
serviceType: '上门服务',
status: 'completed',
statusText: '完成',
price: 212.20,
appointmentTime: '09/03 08:00-12:00',
address: '上海浦东新区新金桥路58号新银东大厦15楼F室',
},
{
id: 7,
serviceName: '韩梅梅预约单',
serviceType: '上门服务',
status: 'cancelled',
statusText: '订单取消',
price: 212.20,
appointmentTime: '09/03 08:00-12:00',
address: '上海浦东新区新金桥路58号新银东大厦15楼F室',
},
])
// 获取服务类型样式类
function getServiceTypeClass(type: number) {
return type === 1 ? 'service-type-store' : 'service-type-home'
}
// 切换标签
function handleTabChange(e: { index: number, name: string }) {
activeTab.value = e.name
}
const Order = { const Order = {
upCallback: (mescroll) => { upCallback: (mescroll) => {
@ -337,7 +257,6 @@
toast.close() toast.close()
if (res) { if (res) {
toast.show('接单成功')
Order.handleSearch() Order.handleSearch()
} }
} }
@ -374,8 +293,8 @@
case 'depart': case 'depart':
// 出发逻辑 - 获取位置并上传 // 出发逻辑 - 获取位置并上传
message.confirm({ message.confirm({
title: '开启定位服务', title: '提示',
msg: '需要开启手机定位功能,以记录本次服务的出发状态', msg: '是否立即出发',
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
cancelButtonProps: { cancelButtonProps: {
@ -386,14 +305,49 @@
}, },
}).then(async (res) => { }).then(async (res) => {
if (res.action === 'confirm') { if (res.action === 'confirm') {
const res = await handleGetLocationFallback() toast.loading('加载中...')
// res = {lat: 30.74501, lng: 120.7555} const res = await handleDepartOrderHooks(order.id)
console.log("🚀 ~ res:", res) toast.close()
if (res) {
Order.handleSearch()
}
} }
}).catch(() => {}) }).catch(() => {})
break break
case 'arrived': case 'arrived':
// 已到达逻辑 - 直接跳转到服务中详情页 // 已到达逻辑
message.confirm({
title: '提示',
msg: '是否确认到达目的地',
confirmButtonText: '确定',
cancelButtonText: '取消',
cancelButtonProps: {
customClass: '!bg-[#F6F7F8] !text-[#303133] !text-32rpx !leading-44rpx !rounded-8rpx',
},
confirmButtonProps: {
customClass: '!bg-[#4C9F44] !text-[#fff] !text-32rpx !leading-44rpx !rounded-8rpx',
},
}).then(async (res) => {
if (res.action === 'confirm') {
const location = await handleGetLocationFallback()
if (location.lat && location.lng) {
toast.loading('加载中...')
const res = await handleArriveOrderHooks({
id: order.id,
longitude: location.lng,
latitude: location.lat,
})
toast.close()
if (res) {
Order.handleSearch()
}
} else {
toast.show('获取位置信息失败,请检查定位权限是否开启')
}
}
}).catch(() => {})
break break
case 'complete': case 'complete':
// 完成服务逻辑 // 完成服务逻辑
@ -401,7 +355,7 @@
case 'delete': case 'delete':
// 删除订单逻辑 // 删除订单逻辑
message.confirm({ message.confirm({
title: '确定删除订单?', title: '提示',
msg: '删除订单后无法恢复,是否确认删除订单?', msg: '删除订单后无法恢复,是否确认删除订单?',
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
@ -448,6 +402,14 @@
orderStatus.value = value orderStatus.value = value
Order.handleSearch() Order.handleSearch()
},
/**
* 获取服务类型样式类
* @param type 1-到店服务 2-上门服务
*/
handleGetServiceTypeClass: (type: number) => {
return type === 1 ? 'service-type-store' : 'service-type-home'
} }
} }
</script> </script>