浏览代码

feat(卡券):优化券

zhoumuhao 3 年之前
父节点
当前提交
b78ce9ceb8
共有 3 个文件被更改,包括 24 次插入18 次删除
  1. 21 15
      pages/couponReceive/couponReceive.js
  2. 2 2
      pages/couponReceive/couponReceive.wxml
  3. 1 1
      project.private.config.json

+ 21 - 15
pages/couponReceive/couponReceive.js

@@ -31,22 +31,28 @@ Page({
   //根据code-id获取券详情信息 判断该codeId是否过期
   async getShareActivityCode(codeId) {
     let _self = this;
-    let result = await activity.getShareActivityCode(codeId);
-    _self.setData({
-      // activityInfo:result.activityInfo,
-      activityId:result.activityInfo.activityId
-    })
-    _self.activityInfo(result.activityInfo.activityId);
-    let expireTime = result.expireTime;
-    //失效的时间
-    let expireTimeTime = util.getUnixTime(expireTime);
-    //获取当前的时间戳
-    var nowTime = Date.parse(new Date())/1000;
-    if(expireTimeTime-nowTime>0) {
+    try {
+      let result = await activity.getShareActivityCode(codeId);
       _self.setData({
-        isEffective:true
+        // activityInfo:result.activityInfo,
+        activityId:result.activityInfo.activityId
       })
-    }
+      _self.activityInfo(result.activityInfo.activityId);
+      let expireTime = result.expireTime;
+      //失效的时间
+      let expireTimeTime = util.getUnixTime(expireTime);
+      //获取当前的时间戳
+      var nowTime = Date.parse(new Date())/1000;
+      if(expireTimeTime-nowTime>0) {
+        _self.setData({
+          isEffective:true
+        })
+      }
+    }catch(error) {
+      _self.setData({
+        isEffective:false
+      })
+    }  
   },
   /**
    * 
@@ -79,7 +85,7 @@ Page({
           console.log(e)
       }
       if (_self.data.activityInfo.isPay == 1 && orderSn) {
-        console.log(22222)
+        // console.log(22222)
         //TODO::暂时屏蔽
         // _self.goPay();
         app.showToast('领取成功','success',1000,function(){

+ 2 - 2
pages/couponReceive/couponReceive.wxml

@@ -9,8 +9,8 @@
   <span wx:for="{{activityInfo.couponTypeAndNumObj}}">{{item.typeText}} ({{item.num}}) </span>  
   </view>
   <!-- 领取 -->
-  <view class="receive-button" bindtap="getNowCoupon" wx:if="{{memberMobile.length>0}}">立即领取</view>
-  <button class="receive-button-button" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" wx:else>立即领取</button>
+  <view class="receive-button" bindtap="getNowCoupon" wx:if="{{memberMobile.length>0 && isEffective==true}}">立即领取</view>
+  <button class="receive-button-button" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" wx:elif="{{memberMobile.length==0 && isEffective==true}}">立即领取</button>
   <view class="bottom-line"></view>
   <view class="flex-row bottom-date">
   <view>有效期:</view>

+ 1 - 1
project.private.config.json

@@ -21,7 +21,7 @@
         {
           "name": "pages/couponReceive/couponReceive",
           "pathName": "pages/couponReceive/couponReceive",
-          "query": "codeId=N6bmwP67Qw-46",
+          "query": "codeId=JyZmVzKm0D-47",
           "scene": null
         },
         {