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}` + }); + } }, // 修改订单