调试订单接口
This commit is contained in:
@ -79,3 +79,25 @@ export function acceptTeaSpecialistOrder(id: number) {
|
||||
export function departTeaSpecialistOrder(id: number) {
|
||||
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 })
|
||||
}
|
||||
@ -1,10 +1,12 @@
|
||||
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 type 来源于订单详情页还是订单列表页
|
||||
*/
|
||||
export async function handleReleaseOrderHooks(id: number) {
|
||||
try {
|
||||
@ -21,7 +23,20 @@ export async function handleReleaseOrderHooks(id: number) {
|
||||
*/
|
||||
export async function handleDepartOrderHooks(id: number) {
|
||||
try {
|
||||
await acceptTeaSpecialistOrder(id)
|
||||
await departTeaSpecialistOrder(id)
|
||||
return true
|
||||
}
|
||||
catch (error) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 茶艺师已到达
|
||||
*/
|
||||
export async function handleArriveOrderHooks(data: {id: number, longitude: number, latitude: number}) {
|
||||
try {
|
||||
await arriveTeaSpecialistOrder(data)
|
||||
return true
|
||||
}
|
||||
catch (error) {
|
||||
|
||||
@ -42,15 +42,27 @@
|
||||
</view>
|
||||
<view class="steps">
|
||||
<wd-steps :active="stepsActive" vertical dot>
|
||||
<wd-step title="客户下订单" :description="order.dtime" />
|
||||
<wd-step title="茶艺师接单" :description="order.take_order_time" />
|
||||
<wd-step title="茶艺师出发" :description="order.travel_time" />
|
||||
<wd-step title="客户下订单" :description="order.dtime">
|
||||
<template #description>
|
||||
<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="茶艺师到达">
|
||||
<template #description>
|
||||
<view class="" v-if="order.image">
|
||||
<wd-img width="120rpx" height='80rpx' :src="order.image" radius="8rpx"></wd-img>
|
||||
</view>
|
||||
<view class="">{{ order.arrival_time }}</view>
|
||||
<view >{{ order.arrival_time }}</view>
|
||||
</template>
|
||||
</wd-step>
|
||||
<wd-step title="服务完成" />
|
||||
@ -254,7 +266,7 @@
|
||||
</view>
|
||||
<view class="info-item">
|
||||
<text class="info-label">预约时长:</text>
|
||||
<text class="info-value">{{ order.hours }}</text>
|
||||
<text class="info-value">{{ order.hours }}小时</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -284,7 +296,7 @@
|
||||
<view class="mt-16rpx">
|
||||
<view class="info-item">
|
||||
<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 class="info-item">
|
||||
<text class="info-label">续单金额</text>
|
||||
@ -378,9 +390,9 @@
|
||||
</view>
|
||||
<view class="info-item flex justify-between items-center">
|
||||
<text class="info-label">订单编号</text>
|
||||
<view class="order-sn-wrapper">
|
||||
<text class="info-value">{{ order.order_sn }}</text>
|
||||
<text class="copy-text" @click.stop="copy(order.order_sn)">|复制</text>
|
||||
<view class="order-sn-wrapper flex items-center justify-between">
|
||||
<view class="info-value">{{ order.order_sn }}</view>
|
||||
<view class="copy-text" @click.stop="copy(order.order_sn)">| 复制</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="info-item flex items-center justify-between" v-if="order.pay_title">
|
||||
@ -405,7 +417,7 @@
|
||||
<!-- 待接单 -->
|
||||
<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-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>
|
||||
|
||||
<!-- 待服务 -->
|
||||
@ -415,7 +427,7 @@
|
||||
|
||||
<!-- 已出发 -->
|
||||
<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>
|
||||
|
||||
<!-- 服务中 -->
|
||||
@ -440,13 +452,15 @@
|
||||
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { useMessage } from 'wot-design-uni'
|
||||
import { useMessage, useToast } from 'wot-design-uni'
|
||||
import PriceFormat from '@/components/PriceFormat.vue'
|
||||
import { copy } from '@/utils/tools'
|
||||
import { TeaSpecialistOrderStatus, TeaSpecialistManageStatusTextValue } from '@/utils/teaSpecialistOrder'
|
||||
import { getTeaSpecialistOrderDetails } from '@/api/tes-specialist'
|
||||
import { handleReleaseOrderHooks, handleDepartOrderHooksm, handleDepartOrderHooks } from '@/hooks/useOrder'
|
||||
|
||||
const OSS = inject('OSS')
|
||||
const toast = useToast()
|
||||
|
||||
// navbar 标题
|
||||
const title = ref<string>('')
|
||||
@ -473,26 +487,6 @@
|
||||
// 费用明细弹窗
|
||||
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({
|
||||
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: () => {
|
||||
message.confirm({
|
||||
title: '开启定位服务',
|
||||
msg: '需要开启手机定位功能,以记录本次服务的出发状态',
|
||||
title: '提示',
|
||||
msg: '是否立即出发',
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
cancelButtonProps: {
|
||||
@ -664,9 +686,15 @@
|
||||
confirmButtonProps: {
|
||||
customClass: '!bg-[#4C9F44] !text-[#fff] !text-32rpx !leading-44rpx !rounded-8rpx',
|
||||
}
|
||||
}).then((res) => {
|
||||
if (res.action == 'confirm') {
|
||||
// TODO 这里需要获取经纬度
|
||||
}).then(async(res) => {
|
||||
if (res.action === 'confirm') {
|
||||
toast.loading('加载中...')
|
||||
const res = await handleDepartOrderHooks(order.value.id)
|
||||
toast.close()
|
||||
|
||||
if (res) {
|
||||
Detail.handleInit()
|
||||
}
|
||||
}
|
||||
}).catch(() => {
|
||||
// 点击取消按钮回调事件
|
||||
@ -676,10 +704,10 @@
|
||||
/**
|
||||
* 已到达
|
||||
*/
|
||||
handleToTakePhone: () => {
|
||||
handleArrived: () => {
|
||||
message.confirm({
|
||||
title: '确定到达',
|
||||
msg: '确认到达后需拍照记录,否则无法开始服务计时',
|
||||
title: '提示',
|
||||
msg: '是否确认到达目的地',
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
cancelButtonProps: {
|
||||
@ -687,15 +715,27 @@
|
||||
},
|
||||
confirmButtonProps: {
|
||||
customClass: '!bg-[#4C9F44] !text-[#fff] !text-32rpx !leading-44rpx !rounded-8rpx',
|
||||
}
|
||||
}).then((res) => {
|
||||
if (res.action == 'confirm') {
|
||||
// TODO 这里需要获取经纬度及拍照
|
||||
},
|
||||
}).then(async (res) => {
|
||||
if (res.action === 'confirm') {
|
||||
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(() => {})
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@ -114,7 +114,6 @@
|
||||
import type { ITeaSpecialistOrderDetailsResult } from '@/api/types/tea'
|
||||
import { copy } from '@/utils/tools'
|
||||
import { getOrderStoreDetail } from '@/api/order'
|
||||
import { handleReleaseTeaRoomOrderHookds, handleCancelOrderHooks } from '@/hooks/useOrder'
|
||||
|
||||
const title = ref<string>('')
|
||||
|
||||
|
||||
@ -69,7 +69,7 @@
|
||||
|
||||
<!-- 价格 -->
|
||||
<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 ? '到店服务' : '上门服务' }}
|
||||
</text>
|
||||
</view>
|
||||
@ -109,7 +109,7 @@
|
||||
import { TeaSpecialistManageOrderStatusText, TeaSpecialistOrderStatus, TeaSpecialistManageStatusTextValue } from '@/utils/teaSpecialistOrder'
|
||||
import { getTeaSpecialistOrderList } from '@/api/tes-specialist'
|
||||
import { handleGetLocationFallback } from '@/hooks/useLocation'
|
||||
import { handleReleaseOrderHooks } from '@/hooks/useOrder'
|
||||
import { handleReleaseOrderHooks, handleDepartOrderHooks, handleArriveOrderHooks } from '@/hooks/useOrder'
|
||||
|
||||
const OSS = inject('OSS')
|
||||
const toast = useToast()
|
||||
@ -126,6 +126,7 @@
|
||||
const orderStatus = ref<string>('')
|
||||
const list = ref<Array<any>>([]) // 茶室列表
|
||||
const keywords = ref<string>('') // 搜索关键词
|
||||
const canReset = ref<boolean>(false) // 第一次onShow避免与自动下拉刷新冲突
|
||||
|
||||
// 消息提示框
|
||||
const message = useMessage('wd-message-box-slot')
|
||||
@ -133,93 +134,12 @@
|
||||
// 当前选中的标签
|
||||
const activeTab = ref('all')
|
||||
|
||||
// 模拟订单数据
|
||||
const orders = ref<Array<any>>([
|
||||
{
|
||||
id: 1,
|
||||
serviceName: '苓苑共享茶室空间',
|
||||
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
|
||||
}
|
||||
onShow(() => {
|
||||
if (canReset.value) {
|
||||
Order.handleSearch()
|
||||
}
|
||||
canReset.value = true
|
||||
})
|
||||
|
||||
const Order = {
|
||||
upCallback: (mescroll) => {
|
||||
@ -337,7 +257,6 @@
|
||||
toast.close()
|
||||
|
||||
if (res) {
|
||||
toast.show('接单成功')
|
||||
Order.handleSearch()
|
||||
}
|
||||
}
|
||||
@ -374,8 +293,8 @@
|
||||
case 'depart':
|
||||
// 出发逻辑 - 获取位置并上传
|
||||
message.confirm({
|
||||
title: '开启定位服务',
|
||||
msg: '需要开启手机定位功能,以记录本次服务的出发状态',
|
||||
title: '提示',
|
||||
msg: '是否立即出发',
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
cancelButtonProps: {
|
||||
@ -386,14 +305,49 @@
|
||||
},
|
||||
}).then(async (res) => {
|
||||
if (res.action === 'confirm') {
|
||||
const res = await handleGetLocationFallback()
|
||||
// res = {lat: 30.74501, lng: 120.7555}
|
||||
console.log("🚀 ~ res:", res)
|
||||
toast.loading('加载中...')
|
||||
const res = await handleDepartOrderHooks(order.id)
|
||||
toast.close()
|
||||
|
||||
if (res) {
|
||||
Order.handleSearch()
|
||||
}
|
||||
}
|
||||
}).catch(() => {})
|
||||
break
|
||||
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
|
||||
case 'complete':
|
||||
// 完成服务逻辑
|
||||
@ -401,7 +355,7 @@
|
||||
case 'delete':
|
||||
// 删除订单逻辑
|
||||
message.confirm({
|
||||
title: '确定删除订单?',
|
||||
title: '提示',
|
||||
msg: '删除订单后无法恢复,是否确认删除订单?',
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
@ -448,6 +402,14 @@
|
||||
|
||||
orderStatus.value = value
|
||||
Order.handleSearch()
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取服务类型样式类
|
||||
* @param type 1-到店服务 2-上门服务
|
||||
*/
|
||||
handleGetServiceTypeClass: (type: number) => {
|
||||
return type === 1 ? 'service-type-store' : 'service-type-home'
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user