Ver código fonte

Merge branch 'skk/feat/welfare-mall' into jeffrey/feat/coupon-center

xing.li 3 anos atrás
pai
commit
e706213b1a

+ 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 ;
   },
 
   /**

+ 23 - 0
pages/welfareMall/personal/personal.js

@@ -134,6 +134,22 @@ Page({
     })
   },
 
+  // 授权手机号--券包
+  getPhoneNumberCoupon(e) {
+    getPhoneNumberSync(e, async () => {
+        let nums = await this.getCountNum();
+        this.setData({
+            isLogin: true,
+            mobileTop: getMobileCache(),
+            countNum: nums,
+        });
+        const url = "../../luckDraw/profile"
+        wx.navigateTo({
+            url
+        })      
+    })
+  },
+
   toHistorical(e) {
       const url = "../historical/historical?id=" + e.currentTarget.dataset.id
       wx.navigateTo({
@@ -162,6 +178,13 @@ Page({
     })
   },
 
+  toCoupon(e) {
+    const url = "../../luckDraw/profile?id=" + e.currentTarget.dataset.id
+    wx.navigateTo({
+        url
+    })
+},
+
   /**
    * 生命周期函数--监听页面初次渲染完成
    */

+ 2 - 2
pages/welfareMall/personal/personal.wxml

@@ -53,8 +53,8 @@
       <!-- 我的券包 -->
       <view class="coupon-bag content-style flex-row">
         <view class="grant flex-row">
-          <button class="wx-isLogin" wx:if="{{!isLogin}}" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber"></button>
-          <view class="content-img-text flex-row">
+          <button class="wx-isLogin" wx:if="{{!isLogin}}" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumberCoupon"></button>
+          <view class="content-img-text flex-row" catchtap="toCoupon">
             <image class="content-img" src="/images/welfareMall/coupon-bag.png" />
             <view class="content-text">我的券包</view>
           </view>