Browse Source

fix(订单详情): 修复订单状态判断逻辑并完善支付流程

- 将订单状态判断从严格相等(===)改为宽松相等(==)以兼容字符串和数字类型
- 添加支付状态标志位防止重复支付
- 完善支付流程,增加支付成功/失败处理
- 新增"再来一单"和"查看服务记录"功能
- 修复评价页面跳转参数传递问题
master
前端-胡立永 1 month ago
parent
commit
65093432c0
1 changed files with 69 additions and 10 deletions
  1. +69
    -10
      pages_order/order/orderDetail.vue

+ 69
- 10
pages_order/order/orderDetail.vue View File

@ -22,17 +22,23 @@
<!-- 底部按钮区域 -->
<view class="order-detail-footer">
<view class="footer-btn cancel-btn" v-if="orderDetail.status === '1'" @click="$refs.cancelOrderPopup.open()">
<view class="footer-btn cancel-btn" v-if="orderDetail.status == '0'" @click="$refs.cancelOrderPopup.open()">
<text>取消订单</text>
</view>
<view class="footer-btn pay-btn" v-if="orderDetail.status === '1'" @click="goToPay">
<view class="footer-btn pay-btn" v-if="orderDetail.status == '0'" @click="goToPay">
<text>去付款</text>
</view>
<!-- <view class="footer-btn modify-btn" v-if="orderDetail.status != 0 && orderDetail.status != 3" @click="modifyOrder">
<!-- <view class="footer-btn modify-btn" v-if="orderDetail.status == '1' || orderDetail.status == '2'" @click="modifyOrder">
<text>修改订单</text>
</view> -->
<view class="footer-btn review-btn" v-if="orderDetail.status === 4" @click="goToReview">
<text>评价订单</text>
<view class="footer-btn pay-btn" v-if="orderDetail.status == '3'" @click="goToReview">
<text>去评价</text>
</view>
<view class="footer-btn pay-btn" v-if="orderDetail.status == '3'" @click="handleReorder">
<text>再来一单</text>
</view>
<view class="footer-btn pay-btn" v-if="orderDetail.status == '2'" @click="handleReorder">
<text>查看服务记录</text>
</view>
<view class="footer-btn contact-btn">
<text>联系客服</text>
@ -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}`
});
}
},
//


Loading…
Cancel
Save