修改数据库并修改页面样式
This commit is contained in:
@@ -2,11 +2,11 @@
|
|||||||
// 内网环境 - 本地部署的 Supabase
|
// 内网环境 - 本地部署的 Supabase
|
||||||
// IP: 192.168.1.62
|
// IP: 192.168.1.62
|
||||||
// Kong HTTP Port: 8000
|
// Kong HTTP Port: 8000
|
||||||
export const SUPA_URL: string = 'http://192.168.1.62:8000'
|
export const SUPA_URL: string = 'http://192.168.1.62:13000'
|
||||||
export const SUPA_KEY: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlzcyI6InN1cGFiYXNlIiwiaWF0IjoxNzY4ODMwNjI0LCJleHAiOjE5MjY1MTA2MjR9.mDVl-kIOdRK9v6VTxo0TDF8r7X7xk3PZXazaavHyVvg'
|
export const SUPA_KEY: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlzcyI6InN1cGFiYXNlIiwiaWF0IjoxNzY4ODMwNjI0LCJleHAiOjE5MjY1MTA2MjR9.mDVl-kIOdRK9v6VTxo0TDF8r7X7xk3PZXazaavHyVvg'
|
||||||
|
|
||||||
// WebSocket 实时连接(内网使用 ws:// 而非 wss://)
|
// WebSocket 实时连接(内网使用 ws:// 而非 wss://)
|
||||||
export const WS_URL: string = 'ws://192.168.1.62:8000/realtime/v1/websocket'
|
export const WS_URL: string = 'ws://192.168.1.62:13000/realtime/v1/websocket'
|
||||||
|
|
||||||
// 备用配置(已注释,如需切换可取消注释)
|
// 备用配置(已注释,如需切换可取消注释)
|
||||||
// 开发环境 - 其他内网地址
|
// 开发环境 - 其他内网地址
|
||||||
|
|||||||
@@ -454,7 +454,7 @@
|
|||||||
confirmPickup() {
|
confirmPickup() {
|
||||||
// TODO: 调用API确认取货
|
// TODO: 调用API确认取货
|
||||||
if (this.currentTask) {
|
if (this.currentTask) {
|
||||||
this.currentTask.status = 4 // 更新状态为“已取货”
|
this.currentTask.status = 5 // 更新状态为“已取货”
|
||||||
}
|
}
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '取货完成',
|
title: '取货完成',
|
||||||
@@ -462,16 +462,16 @@
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
startDelivery() {
|
// startDelivery() {
|
||||||
// TODO: 调用API开始配送
|
// // TODO: 调用API开始配送
|
||||||
if (this.currentTask) {
|
// if (this.currentTask) {
|
||||||
this.currentTask.status = 5 // 更新状态为“配送中”
|
// this.currentTask.status = 5 // 更新状态为“配送中”
|
||||||
}
|
// }
|
||||||
uni.showToast({
|
// uni.showToast({
|
||||||
title: '开始配送',
|
// title: '开始配送',
|
||||||
icon: 'success'
|
// icon: 'success'
|
||||||
})
|
// })
|
||||||
},
|
// },
|
||||||
|
|
||||||
// 显示确认送达弹框
|
// 显示确认送达弹框
|
||||||
showConfirmDeliveryDialog() {
|
showConfirmDeliveryDialog() {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
<!-- 配送端 - 订单详情页 -->
|
|
||||||
<template>
|
<template>
|
||||||
<view class="delivery-order-detail">
|
<view class="delivery-order-detail">
|
||||||
<!-- 返回按钮 -->
|
<!-- 返回按钮 -->
|
||||||
@@ -180,16 +179,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="uts">
|
<script lang="uts">
|
||||||
import type { OrderType, OrderItemType, MerchantType } from '@/types/mall-types.uts'
|
|
||||||
|
|
||||||
type DeliveryInfoType = {
|
|
||||||
distance: number
|
|
||||||
estimated_time: number
|
|
||||||
courier_id: string
|
|
||||||
pickup_time: string
|
|
||||||
delivery_time: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -207,8 +196,8 @@ export default {
|
|||||||
payment_status: 0,
|
payment_status: 0,
|
||||||
delivery_address: {},
|
delivery_address: {},
|
||||||
created_at: ''
|
created_at: ''
|
||||||
} as OrderType,
|
},
|
||||||
orderItems: [] as Array<OrderItemType & { product_image: string }>,
|
orderItems: [],
|
||||||
merchant: {
|
merchant: {
|
||||||
id: '',
|
id: '',
|
||||||
user_id: '',
|
user_id: '',
|
||||||
@@ -222,49 +211,50 @@ export default {
|
|||||||
rating: 0,
|
rating: 0,
|
||||||
total_sales: 0,
|
total_sales: 0,
|
||||||
created_at: ''
|
created_at: ''
|
||||||
} as MerchantType,
|
},
|
||||||
deliveryInfo: {
|
deliveryInfo: {
|
||||||
distance: 0,
|
distance: 0,
|
||||||
estimated_time: 0,
|
estimated_time: 0,
|
||||||
courier_id: '',
|
courier_id: '',
|
||||||
pickup_time: '',
|
pickup_time: '',
|
||||||
delivery_time: ''
|
delivery_time: ''
|
||||||
} as DeliveryInfoType,
|
},
|
||||||
pickupAddress: '',
|
pickupAddress: '',
|
||||||
customerNote: '',
|
customerNote: '',
|
||||||
merchantNote: '',
|
merchantNote: '',
|
||||||
deliveryNote: '', // 配送备注
|
deliveryNote: '',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onLoad(options: any) {
|
onLoad(options: any) {
|
||||||
const orderId = options.id as string
|
const orderId = options.id as string
|
||||||
// 👇 从 URL 参数获取 status
|
// ✅ 从 URL 参数获取 status
|
||||||
const status = parseInt(options.status as string) || 0
|
const status = parseInt(options.status as string) || 0
|
||||||
|
|
||||||
if (orderId) {
|
if (orderId) {
|
||||||
// 将从 URL 获取的状态赋值给 order 对象
|
|
||||||
this.order.id = orderId
|
this.order.id = orderId
|
||||||
this.order.status = status // 👈 设置状态
|
this.order.status = status // ✅ 设置传入的状态
|
||||||
this.loadOrderDetail(orderId)
|
this.loadOrderDetail(orderId)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
// 返回上一页
|
|
||||||
goBack() {
|
goBack() {
|
||||||
uni.navigateBack()
|
uni.navigateBack()
|
||||||
},
|
},
|
||||||
|
|
||||||
loadOrderDetail(orderId: string) {
|
loadOrderDetail(orderId: string) {
|
||||||
|
// ✅ 保留从 URL 获取的状态
|
||||||
|
const originalStatus = this.order.status
|
||||||
|
|
||||||
// 模拟加载订单详情数据
|
// 模拟加载订单详情数据
|
||||||
// 注意:现在 status 的值在 onLoad 时已经从 URL 获取并设置,这里可以依据它来调整数据加载逻辑(如果需要)
|
const mockOrder = {
|
||||||
// 为了演示,我们保持模拟数据不变,但实际应用中可以根据 status 加载不同的数据
|
id: orderId,
|
||||||
this.order = {
|
|
||||||
...this.order, // 保留从 URL 获取的 id 和 status
|
|
||||||
order_no: 'ORD202401150001',
|
order_no: 'ORD202401150001',
|
||||||
user_id: 'user_001',
|
user_id: 'user_001',
|
||||||
merchant_id: 'merchant_001',
|
merchant_id: 'merchant_001',
|
||||||
|
// ✅ 使用传入的 status,而不是硬编码
|
||||||
|
status: originalStatus,
|
||||||
total_amount: 299.98,
|
total_amount: 299.98,
|
||||||
discount_amount: 30.00,
|
discount_amount: 30.00,
|
||||||
delivery_fee: 8.00,
|
delivery_fee: 8.00,
|
||||||
@@ -279,6 +269,9 @@ export default {
|
|||||||
created_at: '2024-01-15 14:30:00'
|
created_at: '2024-01-15 14:30:00'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ✅ 合并数据,保留传入的 status
|
||||||
|
Object.assign(this.order, mockOrder)
|
||||||
|
|
||||||
this.orderItems = [
|
this.orderItems = [
|
||||||
{
|
{
|
||||||
id: 'item_001',
|
id: 'item_001',
|
||||||
@@ -324,7 +317,6 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getStatusDesc(): string {
|
getStatusDesc(): string {
|
||||||
// 根据 order.status 动态返回描述
|
|
||||||
if (this.order.status >= 5) {
|
if (this.order.status >= 5) {
|
||||||
return '订单已送达完成'
|
return '订单已送达完成'
|
||||||
} else if (this.order.status === 4) {
|
} else if (this.order.status === 4) {
|
||||||
@@ -349,37 +341,14 @@ 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) {
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: '确认取货',
|
title: '确认取货',
|
||||||
content: '确认已从商家处取到商品?',
|
content: '确认已从商家处取到商品?',
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
this.order.status = 4 // 更新状态为已取货
|
this.order.status = 4 // 更新为已取货
|
||||||
this.deliveryInfo.pickup_time = new Date().toISOString()
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '取货确认成功',
|
title: '取货确认成功',
|
||||||
icon: 'success'
|
icon: 'success'
|
||||||
@@ -390,17 +359,14 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// ✅ 保留:点击“确认送达”按钮
|
|
||||||
confirmDelivery() {
|
confirmDelivery() {
|
||||||
// 仅在订单未完成时执行
|
|
||||||
if (this.order.status < 5) {
|
if (this.order.status < 5) {
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: '确认送达',
|
title: '确认送达',
|
||||||
content: '确认商品已送达到顾客手中?',
|
content: '确认商品已送达到顾客手中?',
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
this.order.status = 5 // 更新状态为已完成
|
this.order.status = 5 // 更新为已完成
|
||||||
this.deliveryInfo.delivery_time = new Date().toISOString()
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '送达确认成功',
|
title: '送达确认成功',
|
||||||
icon: 'success'
|
icon: 'success'
|
||||||
@@ -411,16 +377,14 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// ✅ 保留:接受订单
|
|
||||||
acceptOrder() {
|
acceptOrder() {
|
||||||
// 仅在订单未完成时执行
|
|
||||||
if (this.order.status < 5) {
|
if (this.order.status < 5) {
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: '接受订单',
|
title: '接受订单',
|
||||||
content: '确定接受这个配送订单吗?',
|
content: '确定接受这个配送订单吗?',
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
this.order.status = 2 // 更新状态为已接单
|
this.order.status = 2 // 更新为已接单
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '订单接受成功',
|
title: '订单接受成功',
|
||||||
icon: 'success'
|
icon: 'success'
|
||||||
@@ -431,9 +395,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// ✅ 保留:拒绝订单
|
|
||||||
rejectOrder() {
|
rejectOrder() {
|
||||||
// 仅在订单未完成时执行
|
|
||||||
if (this.order.status < 5) {
|
if (this.order.status < 5) {
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: '拒绝订单',
|
title: '拒绝订单',
|
||||||
@@ -451,9 +413,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// ✅ 保留:启动导航(用于“前往取货”按钮)
|
|
||||||
startNavigation() {
|
startNavigation() {
|
||||||
// 仅在订单未完成时执行
|
|
||||||
if (this.order.status < 5) {
|
if (this.order.status < 5) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '正在启动导航',
|
title: '正在启动导航',
|
||||||
@@ -471,15 +431,11 @@ export default {
|
|||||||
|
|
||||||
callCustomer() {
|
callCustomer() {
|
||||||
const phone = this.getDeliveryAddress().phone
|
const phone = this.getDeliveryAddress().phone
|
||||||
uni.makePhoneCall({
|
uni.makePhoneCall({ phoneNumber: phone })
|
||||||
phoneNumber: phone
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
|
||||||
callMerchant() {
|
callMerchant() {
|
||||||
uni.makePhoneCall({
|
uni.makePhoneCall({ phoneNumber: this.merchant.contact_phone })
|
||||||
phoneNumber: this.merchant.contact_phone
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
|
||||||
contactService() {
|
contactService() {
|
||||||
@@ -492,13 +448,14 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
/* ... 保持原有 style 部分不变 ... */
|
/* 保持原有样式不变 */
|
||||||
.delivery-order-detail {
|
.delivery-order-detail {
|
||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
padding-bottom: 160rpx;
|
padding-bottom: 160rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ... 其余样式保持原样 ... */
|
||||||
/* 返回按钮头部 */
|
/* 返回按钮头部 */
|
||||||
.back-header {
|
.back-header {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
@@ -866,18 +823,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; /* 允许按钮换行 */
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.action-btn {
|
.action-btn {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 120rpx; /* 设置最小宽度 */
|
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; /* 添加外边距 */
|
margin: 5rpx;
|
||||||
box-sizing: border-box; /* 确保宽高包含边距 */
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.action-btn.accept, .action-btn.complete {
|
.action-btn.accept, .action-btn.complete {
|
||||||
|
|||||||
Reference in New Issue
Block a user