ソースを参照

个人中心卡券数量处理

kk.shi 3 年 前
コミット
03b3560fae
共有4 個のファイルを変更した63 個の追加12 個の削除を含む
  1. 24 0
      api/welfareMall.js
  2. 5 5
      pages/welfareMall/feedback/feedback.js
  3. 33 6
      pages/welfareMall/personal/personal.js
  4. 1 1
      pages/welfareMall/personal/personal.wxml

+ 24 - 0
api/welfareMall.js

@@ -58,6 +58,30 @@ class WelfareMall extends request {
     return this.postRequest(`${this.BASE_URL}open/welfare-mall/add-feedback`, params);
   }
 
+  /**
+   * 福利社
+   * 获取购买优惠券个数
+   */
+  static async getUserBuyCouponNum(params) {
+    return this.postRequest(`${this.BASE_URL}open/welfare-mall/user-buy-coupon-num`, params);
+  }
+
+  /**
+   * 签到
+   * 获取购买优惠券个数
+   */
+  static async getUserAwardCouponNum(params) {
+    return this.postRequest(`${this.BASE_URL}open/sign-in/user-award-coupon-num`, params);
+  }
+
+  /**
+   * 抽奖
+   * 获取购买优惠券个数
+   */
+  static async getUserDrawCouponNum(params) {
+    return this.postRequest(`${this.BASE_URL}open/luck-draw/user-draw-coupon-num`, params);
+  }
+
 }
 
 export default WelfareMall

+ 5 - 5
pages/welfareMall/feedback/feedback.js

@@ -161,11 +161,11 @@ Page({
             icon: 'none',
             duration: 1500
           });
-          this.onLoad(this.options);
-          this.setData({
-            content: '',
-            avatarUrl: '',
-       });
+          var pages =getCurrentPages();//当前页面栈
+          if (pages.length >1) {
+          var beforePage = pages[pages.length- 2];//获取上一个页面实例对象
+          beforePage.changeData();//触发父页面中的方法
+          }
         }
         this.data.lock = false
     }).catch(_ => {

+ 33 - 6
pages/welfareMall/personal/personal.js

@@ -1,4 +1,5 @@
 // pages/welfareMall/personal/personal.js
+import WelfareMall from '../../../api/welfareMall'
 import {getMobileCache, getPhoneNumber as getPhoneNumberSync} from '../../../utils/user'
 Page({
 
@@ -8,29 +9,55 @@ Page({
   data: {
     isLogin: false,
     mobileTop: 'TONY WU',
-
+    countNum: 0,
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
-  onLoad: function (options) {
+  onLoad: async function (options) {
     this.setData({
       isLogin: getMobileCache() != '',
       mobileTop: getMobileCache(),
-  })
+    })
+
+    if(this.data.isLogin){
+      let nums = await this.getCountNum();
+      this.setData({
+        countNum: nums,
+      })
+    }
 
   },
 
+  getCountNum: async function(){
+  /**
+   * 福利社
+   */
+    let resBuy = await WelfareMall.getUserBuyCouponNum({
+      mobile: getMobileCache(),
+    });
+    let resAward = await  WelfareMall.getUserAwardCouponNum({
+      mobile: getMobileCache(),
+    });
+    let resDraw = await  WelfareMall.getUserDrawCouponNum({
+      mobile: getMobileCache(),
+    });
+    let nums = Number(resBuy.data.notUseNum)+Number(resAward.data.notUseNum)+Number(resDraw.data.notUseNum)
+    return nums;
+  },
+
   // 授权手机号
   getPhoneNumber(e) {
-    getPhoneNumberSync(e, _ => {
+    getPhoneNumberSync(e, async () => {
+        let nums = await this.getCountNum();
         this.setData({
             isLogin: true,
             mobileTop: getMobileCache(),
-        })
+            countNum: nums,
+        })       
     })
-},
+  },
 
   toHistorical(e) {
       const url = "../historical/historical?id=" + e.currentTarget.dataset.id

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

@@ -10,7 +10,7 @@
     <view class="head-card flex-row">
       <view class="head-card-coupon">我的优惠券</view>
       <view class="head-card-nt flex-row">
-        <view class="head-card-num">0</view>
+        <view class="head-card-num">{{countNum}}</view>
         <view class="head-card-text">张</view>
       </view>
     </view>