From 65093432c0fe854e5534e7731bc449d2e4f134f6 Mon Sep 17 00:00:00 2001 From: huliyong <2783385703@qq.com> Date: Thu, 5 Jun 2025 21:51:02 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E8=AE=A2=E5=8D=95=E8=AF=A6=E6=83=85):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AE=A2=E5=8D=95=E7=8A=B6=E6=80=81=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E9=80=BB=E8=BE=91=E5=B9=B6=E5=AE=8C=E5=96=84=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将订单状态判断从严格相等(===)改为宽松相等(==)以兼容字符串和数字类型 - 添加支付状态标志位防止重复支付 - 完善支付流程,增加支付成功/失败处理 - 新增"再来一单"和"查看服务记录"功能 - 修复评价页面跳转参数传递问题 --- pages_order/order/orderDetail.vue | 79 ++++++++++++++++++++++++++++++++++----- 1 file changed, 69 insertions(+), 10 deletions(-) diff --git a/pages_order/order/orderDetail.vue b/pages_order/order/orderDetail.vue index ec98668..d33e11a 100644 --- a/pages_order/order/orderDetail.vue +++ b/pages_order/order/orderDetail.vue @@ -22,17 +22,23 @@ - + 取消订单 - + 去付款 - - - 评价订单 + + 去评价 + + + 再来一单 + + + 查看服务记录 联系客服 @@ -85,6 +91,8 @@ orderId: null, orderDetail: {},//格式化后的数据 detail : {},//未格式化的数据 + isPaying: false, + loading: false }; }, onLoad(options) { @@ -105,6 +113,7 @@ if (res) { // 处理接口返回的数据 const data = res; + this.detail = data; // 保存原始数据 data.petVOList.forEach(pet => { pet.orderServiceText = getOrderServiceText(pet.id, data.orderServiceList) // 日期 @@ -147,7 +156,7 @@ }) itemList.forEach(p => { - price += p.salePrice + price += p.salePrice * p.quantity itemsText = [...new Set([...itemsText, p.productName])] }) @@ -245,21 +254,71 @@ // 去付款 goToPay() { - uni.navigateTo({ - url: `/pages/details/order?id=${this.orderId}` + const { orderPay } = require('@/api/order/order.js'); + orderPay({ + orderId: this.orderId + }).then(res => { + this.pay(res.data) + }).catch(err => { + console.log(err); }); }, + pay(params) { + if (this.isPaying) { + return; + } + this.isPaying = true + uni.requestPayment({ + provider: 'wxpay', + timeStamp: params.timeStamp, + nonceStr: params.nonceStr, + package: params.package_, + signType: params.signType, + paySign: params.paySign, + success: (res) => { + this.$modal.showToast('支付成功') + this.getOrderDetail() + }, + fail: (err) => { + this.loading = false + console.log('支付失败', err) + this.$modal.showToast('支付失败') + }, + complete: () => { + this.loading = false + this.isPaying = false + } + }) + }, + // 去评价 goToReview() { + const order = this.detail; uni.navigateTo({ - url: `/pages_order/order/orderReview?id=${this.orderId}` + url: `/pages_order/order/orderReview?id=${order.teacherId}&orderId=${order.orderId}` }); }, // 处理取消订单 handleCancelOrder() { - // 待实现取消订单逻辑 + this.getOrderDetail(); + }, + + // 处理再来一单/查看服务记录 + handleReorder() { + if (this.orderDetail.status == '3') { + // 再来一单 - 可以添加伴宠师选择弹窗 + uni.showToast({ + title: '再来一单功能开发中', + icon: 'none' + }); + } else if (this.orderDetail.status == '2') { + // 查看服务记录 + uni.navigateTo({ + url: `/pages_order/order/serviceRecord?orderId=${this.orderId}` + }); + } }, // 修改订单