kk.shi 3 rokov pred
rodič
commit
435d5efdf5
1 zmenil súbory, kde vykonal 27 pridanie a 21 odobranie
  1. 27 21
      pages/welfareMall/order/orderCompletion.js

+ 27 - 21
pages/welfareMall/order/orderCompletion.js

@@ -53,6 +53,18 @@ Page({
     })
   },
 
+  /**
+   * 
+   * 订单数据--查询
+   */
+  selectOrder: async function(orderSn) {
+    let res = await WelfareMall.getOrder({
+      mobile: getMobileCache(),
+      orderSn: orderSn,
+    })
+    await this.changeOrder(res.data.orderSn,res.data.status.value,res.data.status.showText);
+  },
+
   userOrderistView: function(data) {
     if (!data) {
         console.log("订单详情数据为空");
@@ -71,6 +83,7 @@ Page({
    * 取消订单
    */ 
   toCancelOrder(e) {
+    var that = this;
     wx.showModal({
       title: '取消订单',
       content: '',
@@ -85,7 +98,7 @@ Page({
             //点击确定 
             WelfareMall.cancelOrder({
               mobile: getMobileCache(),
-              orderSn: this.data.orderSn,
+              orderSn: that.data.orderSn,
             }).then(res => {
                 if (res.code == 200) {
                   wx.showToast({
@@ -93,12 +106,12 @@ Page({
                     icon: 'none',
                     duration: 1500
                   });
-                  this.changeOrder(this.data.orderSn,4,'已取消');
+                  that.selectOrder(that.data.orderSn);
                 }
-                this.data.lock = false
+                that.data.lock = false
             }).catch(_ => {
                 console.log(_)
-                this.data.lock = false
+                that.data.lock = false
             })
         }
       },
@@ -125,7 +138,7 @@ Page({
         success: function (res) {
           //支付成功
           console.log(res);
-          that.changeOrder(that.data.orderSn,2,'已支付');
+          that.selectOrder(that.data.orderSn);
         },
         fail: function (res) {
           console.log(res);
@@ -188,25 +201,18 @@ Page({
    * 
    * 申请退款
    */ 
-  goRefund: function(reason) {
+  goRefund: async function(reason) {
     var that = this;
-    WelfareMall.orderRefund({
+    await WelfareMall.orderRefund({
       mobile: getMobileCache(),
       orderSn: that.data.orderSn,
       reason: reason,
-    }).then(res => {
-        if (res.code == 200) {
-          that.cancel();
-          that.onLoad(that.options);
-          that.changeOrder(that.data.orderSn,3,'已退款');
-          const url = "../refund/refund?orderSn=" + that.data.orderSn
-          wx.navigateTo({
-              url
-          })
-        }
-    }).catch(_ => {
-        console.log(_)
-        that.cancel();
+    });
+    await that.cancel();
+    await that.onLoad(that.options);
+    await that.selectOrder(that.data.orderSn);
+    await wx.navigateTo({
+      url:  "../refund/refund?orderSn=" + that.data.orderSn
     })
     
   },
@@ -232,7 +238,7 @@ Page({
         })
       }
     })
-    return;
+    return ;
   },
 
   /**