添加对应逻辑并修改样式
This commit is contained in:
@@ -521,17 +521,19 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
// 查看订单详情(跳转到 order-detail 页面)
|
// 查看订单详情(跳转到 order-detail 页面)
|
||||||
viewOrderDetail(orderId?: string) {
|
viewOrderDetail(orderId?: string,status?:number) {
|
||||||
if (orderId) {
|
if (orderId && status) {
|
||||||
// 跳转到附近订单的详情页
|
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/mall/delivery/order-detail?id=${orderId}`
|
url: `/pages/mall/delivery/order-detail?id=${orderId}&status=${status}` // ✅ 强制为 1
|
||||||
})
|
})
|
||||||
} else if (this.currentTask) {
|
} else if (this.currentTask) {
|
||||||
// 跳转到当前任务的详情页,并传递 status
|
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/mall/delivery/order-detail?id=${this.currentTask.id}&status=${this.currentTask.status}`
|
url: `/pages/mall/delivery/order-detail?id=${this.currentTask.id}&status=${this.currentTask.status}`
|
||||||
})
|
})
|
||||||
|
}else{
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages/mall/delivery/order-detail?id=${orderId}&status=1` // ✅ 强制为 1
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,11 @@
|
|||||||
<!-- 订单状态 -->
|
<!-- 订单状态 -->
|
||||||
<view class="order-status">
|
<view class="order-status">
|
||||||
<view class="status-progress">
|
<view class="status-progress">
|
||||||
|
<view class="progress-item" :class="{ active: order.status >= 1 }">
|
||||||
|
<view class="progress-dot"></view>
|
||||||
|
<text class="progress-text">待接单</text>
|
||||||
|
</view>
|
||||||
|
<view class="progress-line" :class="{ active: order.status >= 2 }"></view>
|
||||||
<view class="progress-item" :class="{ active: order.status >= 2 }">
|
<view class="progress-item" :class="{ active: order.status >= 2 }">
|
||||||
<view class="progress-dot"></view>
|
<view class="progress-dot"></view>
|
||||||
<text class="progress-text">已接单</text>
|
<text class="progress-text">已接单</text>
|
||||||
@@ -154,13 +159,20 @@
|
|||||||
|
|
||||||
<!-- 底部操作 -->
|
<!-- 底部操作 -->
|
||||||
<view class="bottom-actions">
|
<view class="bottom-actions">
|
||||||
<!-- 只在已接单状态且订单未完成时显示订单操作按钮 -->
|
<!-- 只在待接单状态且订单未完成时显示接受/拒绝订单按钮 -->
|
||||||
<button v-if="order.status === 2 && order.status < 5" class="action-btn accept" @click="acceptOrder">接受订单</button>
|
<button v-if="order.status === 1" class="action-btn accept" @click="acceptOrder">接受订单</button>
|
||||||
<button v-if="order.status === 2 && order.status < 5" class="action-btn reject" @click="rejectOrder">拒绝订单</button>
|
<button v-if="order.status === 1" class="action-btn reject" @click="rejectOrder">拒绝订单</button>
|
||||||
<!-- 只在取货中状态且订单未完成时显示导航按钮 -->
|
|
||||||
<button v-if="order.status === 3 && order.status < 5" class="action-btn navigate" @click="startNavigation">开始导航</button>
|
<!-- 只在已接单状态且订单未完成时显示“前往取货”和“正在取货”按钮 -->
|
||||||
<!-- 只在已取货状态且订单未完成时显示完成按钮 -->
|
<button v-if="order.status === 2" class="action-btn navigate" @click="startNavigation">前往取货</button>
|
||||||
<button v-if="order.status === 4 && order.status < 5" class="action-btn complete" @click="completeDelivery">完成配送</button>
|
<button v-if="order.status === 2" class="action-btn complete" @click="confirmArrivedAtPickup">正在取货</button>
|
||||||
|
|
||||||
|
<!-- 只在取货中状态且订单未完成时显示“确认取货”按钮 -->
|
||||||
|
<button v-if="order.status === 3" class="action-btn complete" @click="confirmPickup">确认取货</button>
|
||||||
|
|
||||||
|
<!-- 只在已取货状态且订单未完成时显示“确认送达”按钮 -->
|
||||||
|
<button v-if="order.status === 4" class="action-btn complete" @click="confirmDelivery">确认送达</button>
|
||||||
|
|
||||||
<!-- 始终显示联系客服按钮 -->
|
<!-- 始终显示联系客服按钮 -->
|
||||||
<button class="action-btn contact" @click="contactService">联系客服</button>
|
<button class="action-btn contact" @click="contactService">联系客服</button>
|
||||||
</view>
|
</view>
|
||||||
@@ -224,6 +236,7 @@ export default {
|
|||||||
deliveryNote: '', // 配送备注
|
deliveryNote: '', // 配送备注
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onLoad(options: any) {
|
onLoad(options: any) {
|
||||||
const orderId = options.id as string
|
const orderId = options.id as string
|
||||||
// 👇 从 URL 参数获取 status
|
// 👇 从 URL 参数获取 status
|
||||||
@@ -236,6 +249,7 @@ export default {
|
|||||||
this.loadOrderDetail(orderId)
|
this.loadOrderDetail(orderId)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
// 返回上一页
|
// 返回上一页
|
||||||
goBack() {
|
goBack() {
|
||||||
@@ -319,6 +333,8 @@ export default {
|
|||||||
return '配送员正在前往取货'
|
return '配送员正在前往取货'
|
||||||
} else if (this.order.status === 2) {
|
} else if (this.order.status === 2) {
|
||||||
return '订单已接取'
|
return '订单已接取'
|
||||||
|
} else if (this.order.status === 1) {
|
||||||
|
return '等待配送员接单'
|
||||||
} else {
|
} else {
|
||||||
return '订单状态未知'
|
return '订单状态未知'
|
||||||
}
|
}
|
||||||
@@ -333,6 +349,27 @@ export default {
|
|||||||
return Object.keys(specifications).map(key => `${key}: ${specifications[key]}`).join(', ')
|
return Object.keys(specifications).map(key => `${key}: ${specifications[key]}`).join(', ')
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// ✅ 新增:点击“正在取货”按钮
|
||||||
|
confirmArrivedAtPickup() {
|
||||||
|
// 仅在订单未完成时执行
|
||||||
|
if (this.order.status < 5) {
|
||||||
|
uni.showModal({
|
||||||
|
title: '正在取货',
|
||||||
|
content: '确认已到达商家,开始取货?',
|
||||||
|
success: (res) => {
|
||||||
|
if (res.confirm) {
|
||||||
|
this.order.status = 3 // 更新状态为取货中
|
||||||
|
uni.showToast({
|
||||||
|
title: '已进入取货流程',
|
||||||
|
icon: 'success'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// ✅ 保留:点击“确认取货”按钮
|
||||||
confirmPickup() {
|
confirmPickup() {
|
||||||
// 仅在订单未完成时执行
|
// 仅在订单未完成时执行
|
||||||
if (this.order.status < 5) {
|
if (this.order.status < 5) {
|
||||||
@@ -353,6 +390,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// ✅ 保留:点击“确认送达”按钮
|
||||||
confirmDelivery() {
|
confirmDelivery() {
|
||||||
// 仅在订单未完成时执行
|
// 仅在订单未完成时执行
|
||||||
if (this.order.status < 5) {
|
if (this.order.status < 5) {
|
||||||
@@ -373,6 +411,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// ✅ 保留:接受订单
|
||||||
acceptOrder() {
|
acceptOrder() {
|
||||||
// 仅在订单未完成时执行
|
// 仅在订单未完成时执行
|
||||||
if (this.order.status < 5) {
|
if (this.order.status < 5) {
|
||||||
@@ -381,7 +420,7 @@ export default {
|
|||||||
content: '确定接受这个配送订单吗?',
|
content: '确定接受这个配送订单吗?',
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
this.order.status = 3 // 更新状态为取货中
|
this.order.status = 2 // 更新状态为已接单
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '订单接受成功',
|
title: '订单接受成功',
|
||||||
icon: 'success'
|
icon: 'success'
|
||||||
@@ -392,6 +431,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// ✅ 保留:拒绝订单
|
||||||
rejectOrder() {
|
rejectOrder() {
|
||||||
// 仅在订单未完成时执行
|
// 仅在订单未完成时执行
|
||||||
if (this.order.status < 5) {
|
if (this.order.status < 5) {
|
||||||
@@ -411,6 +451,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// ✅ 保留:启动导航(用于“前往取货”按钮)
|
||||||
startNavigation() {
|
startNavigation() {
|
||||||
// 仅在订单未完成时执行
|
// 仅在订单未完成时执行
|
||||||
if (this.order.status < 5) {
|
if (this.order.status < 5) {
|
||||||
@@ -428,21 +469,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
completeDelivery() {
|
|
||||||
// 仅在订单未完成时执行
|
|
||||||
if (this.order.status < 5) {
|
|
||||||
if (!this.deliveryNote.trim()) {
|
|
||||||
uni.showToast({
|
|
||||||
title: '请填写配送备注',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
this.confirmDelivery()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
callCustomer() {
|
callCustomer() {
|
||||||
const phone = this.getDeliveryAddress().phone
|
const phone = this.getDeliveryAddress().phone
|
||||||
uni.makePhoneCall({
|
uni.makePhoneCall({
|
||||||
@@ -840,14 +866,18 @@ export default {
|
|||||||
box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.1);
|
box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.1);
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 15rpx;
|
gap: 15rpx;
|
||||||
|
flex-wrap: wrap; /* 允许按钮换行 */
|
||||||
}
|
}
|
||||||
|
|
||||||
.action-btn {
|
.action-btn {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
min-width: 120rpx; /* 设置最小宽度 */
|
||||||
height: 70rpx;
|
height: 70rpx;
|
||||||
border-radius: 35rpx;
|
border-radius: 35rpx;
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
border: none;
|
border: none;
|
||||||
|
margin: 5rpx; /* 添加外边距 */
|
||||||
|
box-sizing: border-box; /* 确保宽高包含边距 */
|
||||||
}
|
}
|
||||||
|
|
||||||
.action-btn.accept, .action-btn.complete {
|
.action-btn.accept, .action-btn.complete {
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ export default {
|
|||||||
{
|
{
|
||||||
id: '3',
|
id: '3',
|
||||||
order_no: 'D202501081236',
|
order_no: 'D202501081236',
|
||||||
status: 2, // 取货中
|
status: 1, // 取货中
|
||||||
pickup_address: {
|
pickup_address: {
|
||||||
detail: '罗湖区东门步行街',
|
detail: '罗湖区东门步行街',
|
||||||
area: '罗湖'
|
area: '罗湖'
|
||||||
|
|||||||
@@ -81,10 +81,17 @@ import { ref, onMounted } from 'vue'
|
|||||||
// 响应式数据
|
// 响应式数据
|
||||||
const task = ref(null)
|
const task = ref(null)
|
||||||
|
|
||||||
// 生命周期
|
// ✅ 关键:在 setup 中无法直接访问 onLoad,所以改用以下方式
|
||||||
|
// 方案:通过 getCurrentPages() 获取当前页面参数
|
||||||
|
function getQueryParams() {
|
||||||
|
const pages = getCurrentPages()
|
||||||
|
const currentPage = pages[pages.length - 1]
|
||||||
|
return currentPage.options || {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 在 onMounted 中获取参数
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// 获取 URL 参数
|
const query = getQueryParams()
|
||||||
const query = uni.getLaunchOptionsSync().query
|
|
||||||
const taskId = query.id
|
const taskId = query.id
|
||||||
|
|
||||||
if (!taskId) {
|
if (!taskId) {
|
||||||
@@ -92,80 +99,42 @@ onMounted(() => {
|
|||||||
title: '任务ID不能为空',
|
title: '任务ID不能为空',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
|
console.error('❌ 未获取到 taskId,query:', query)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
loadTaskDetail(taskId)
|
loadTaskDetail(taskId)
|
||||||
})
|
})
|
||||||
|
|
||||||
// 方法
|
// 其他方法保持不变...
|
||||||
function loadTaskDetail(taskId: string) {
|
function loadTaskDetail(taskId: string) {
|
||||||
// 模拟加载任务详情
|
|
||||||
const mockTasks = [
|
const mockTasks = [
|
||||||
{
|
{
|
||||||
id: 'task001',
|
id: 'task001',
|
||||||
order_id: 'ORD20250122001',
|
order_id: 'ORD20250122001',
|
||||||
driver_id: 'driver001',
|
|
||||||
pickup_address: { address: '深圳市南山区科技园南区深圳湾科技生态园' },
|
pickup_address: { address: '深圳市南山区科技园南区深圳湾科技生态园' },
|
||||||
delivery_address: { address: '深圳市南山区蛇口海上世界广场' },
|
delivery_address: { address: '深圳市南山区蛇口海上世界广场' },
|
||||||
distance: 8.2,
|
distance: 8.2,
|
||||||
estimated_time: 25,
|
estimated_time: 25,
|
||||||
delivery_fee: 12.0,
|
delivery_fee: 12.0,
|
||||||
status: 3, // 配送中
|
status: 3,
|
||||||
pickup_time: '2025-01-22 14:30:00',
|
|
||||||
delivered_time: null,
|
|
||||||
delivery_code: 'DEL001',
|
|
||||||
remark: '联系电话: 13800138000',
|
remark: '联系电话: 13800138000',
|
||||||
created_at: '2025-01-22 14:00:00',
|
created_at: '2025-01-22 14:00:00'
|
||||||
updated_at: '2025-01-22 14:35:00'
|
|
||||||
},
|
},
|
||||||
{
|
// 更多模拟数据...
|
||||||
id: 'task002',
|
|
||||||
order_id: 'ORD20250122002',
|
|
||||||
driver_id: 'driver001',
|
|
||||||
pickup_address: { address: '深圳市南山区海岸城' },
|
|
||||||
delivery_address: { address: '深圳市南山区欢乐颂广场' },
|
|
||||||
distance: 3.5,
|
|
||||||
estimated_time: 12,
|
|
||||||
delivery_fee: 8.0,
|
|
||||||
status: 4, // 已完成
|
|
||||||
pickup_time: '2025-01-22 13:00:00',
|
|
||||||
delivered_time: '2025-01-22 13:15:00',
|
|
||||||
delivery_code: 'DEL002',
|
|
||||||
remark: '',
|
|
||||||
created_at: '2025-01-22 12:45:00',
|
|
||||||
updated_at: '2025-01-22 13:15:00'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'task003',
|
|
||||||
order_id: 'ORD20250122003',
|
|
||||||
driver_id: 'driver001',
|
|
||||||
pickup_address: { address: '深圳市南山区世界之窗' },
|
|
||||||
delivery_address: { address: '深圳市南山区欢乐谷' },
|
|
||||||
distance: 2.1,
|
|
||||||
estimated_time: 8,
|
|
||||||
delivery_fee: 6.5,
|
|
||||||
status: 1, // 待接单
|
|
||||||
pickup_time: null,
|
|
||||||
delivered_time: null,
|
|
||||||
delivery_code: 'DEL003',
|
|
||||||
remark: '',
|
|
||||||
created_at: '2025-01-22 11:15:00',
|
|
||||||
updated_at: '2025-01-22 11:15:00'
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
|
|
||||||
const foundTask = mockTasks.find(t => t.id === taskId)
|
const foundTask = mockTasks.find(t => t.id === taskId)
|
||||||
if (foundTask) {
|
if (foundTask) {
|
||||||
task.value = foundTask
|
task.value = foundTask
|
||||||
|
console.log('✅ 加载任务成功:', task.value)
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({
|
uni.showToast({ title: '未找到该任务', icon: 'none' })
|
||||||
title: '未找到该任务',
|
console.warn('⚠️ 任务ID不存在:', taskId)
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 其他方法...
|
||||||
function getTaskStatusText(status: number): string {
|
function getTaskStatusText(status: number): string {
|
||||||
const statusMap = {
|
const statusMap = {
|
||||||
1: '待接单',
|
1: '待接单',
|
||||||
@@ -178,22 +147,19 @@ function getTaskStatusText(status: number): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getAddressText(address: UTSJSONObject): string {
|
function getAddressText(address: UTSJSONObject): string {
|
||||||
return address['address'] as string || '地址信息'
|
return address?.['address'] as string || '地址信息'
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatTime(dateStr: string): string {
|
function formatTime(dateStr: string): string {
|
||||||
|
if (!dateStr) return '未知时间'
|
||||||
const date = new Date(dateStr)
|
const date = new Date(dateStr)
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
const diff = now.getTime() - date.getTime()
|
const diff = now.getTime() - date.getTime()
|
||||||
const hours = Math.floor(diff / (1000 * 60 * 60))
|
const hours = Math.floor(diff / (1000 * 60 * 60))
|
||||||
|
|
||||||
if (hours < 1) {
|
if (hours < 1) return '刚刚'
|
||||||
return '刚刚'
|
if (hours < 24) return `${hours}小时前`
|
||||||
} else if (hours < 24) {
|
return `${Math.floor(hours / 24)}天前`
|
||||||
return `${hours}小时前`
|
|
||||||
} else {
|
|
||||||
return `${Math.floor(hours / 24)}天前`
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function contactCustomer() {
|
function contactCustomer() {
|
||||||
@@ -201,9 +167,7 @@ function contactCustomer() {
|
|||||||
itemList: ['拨打电话', '发送短信'],
|
itemList: ['拨打电话', '发送短信'],
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (res.tapIndex === 0) {
|
if (res.tapIndex === 0) {
|
||||||
uni.makePhoneCall({
|
uni.makePhoneCall({ phoneNumber: '13800138000' })
|
||||||
phoneNumber: '13800138000'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -211,32 +175,16 @@ function contactCustomer() {
|
|||||||
|
|
||||||
function completeTask() {
|
function completeTask() {
|
||||||
if (task.value?.status !== 3) {
|
if (task.value?.status !== 3) {
|
||||||
uni.showToast({
|
uni.showToast({ title: '当前任务不是“配送中”状态', icon: 'none' })
|
||||||
title: '当前任务不是“配送中”状态',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 模拟完成配送
|
|
||||||
task.value.status = 4
|
task.value.status = 4
|
||||||
uni.showToast({
|
uni.showToast({ title: '任务已完成', icon: 'success' })
|
||||||
title: '任务已完成',
|
|
||||||
icon: 'success'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 返回上一页
|
|
||||||
function goBack() {
|
function goBack() {
|
||||||
uni.navigateBack()
|
uni.navigateBack()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果你希望在左上角也返回主页(可选)
|
|
||||||
function goBackToHome() {
|
|
||||||
uni.reLaunch({
|
|
||||||
url: '/pages/mall/delivery/index'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
Reference in New Issue
Block a user