Commit 697f669989f67b8302b6ec657f01178fb2af674c
1 parent
4bceb6a4
OA单的优化,优惠券
Showing
3 changed files
with
42 additions
and
19 deletions
packageA/pages/quan_pro/quan_pro.js
| ... | ... | @@ -88,13 +88,19 @@ Page({ |
| 88 | 88 | th.setData({is_get:1}); |
| 89 | 89 | return false; |
| 90 | 90 | } |
| 91 | + | |
| 92 | + //-- 券已经领取完的优化 -- | |
| 93 | + if(r_data.sum_num && r_data.sum_num<=r_data.use_sumnum){ | |
| 94 | + th.setData({is_get:1}); | |
| 95 | + return false; | |
| 96 | + } | |
| 97 | + | |
| 91 | 98 | if(r_data.type!=1){ |
| 92 | 99 | th.setData({is_get:2}); |
| 93 | 100 | return false; |
| 94 | 101 | } |
| 95 | 102 | |
| 96 | 103 | var now=ut.gettimestamp(); |
| 97 | - | |
| 98 | 104 | if(r_data.send_start_time>now){ |
| 99 | 105 | th.setData({is_get:3}); |
| 100 | 106 | return false; |
| ... | ... | @@ -102,26 +108,26 @@ Page({ |
| 102 | 108 | |
| 103 | 109 | if(r_data.send_end_time<now){ |
| 104 | 110 | th.setData({is_get:4}); |
| 105 | - return false; | |
| 106 | 111 | } |
| 107 | 112 | |
| 108 | - th.setData({is_get:1}); | |
| 109 | 113 | th.setData({ q_data:r_data }); |
| 110 | 114 | |
| 115 | + var url2='/api/weshop/couponList/getUserCouponListMsg?store_id='+os.stoid+'&cid='+th.data.id+'&uid='+getApp().globalData.user_id; | |
| 116 | + var rss=await getApp().request.promiseGet(url2, {}) | |
| 117 | + if(rss && rss.data.code==-1){ | |
| 118 | + if(rss.data.msg.indexOf('您下一次')>-1){ | |
| 119 | + th.setData({is_get:5,err_txt:'您已领过该券'}); | |
| 120 | + }else if(rss.data.msg.indexOf('您已领完该券')>-1){ | |
| 121 | + th.setData({is_get:5,err_txt:'您已领完该券'}); | |
| 122 | + } | |
| 123 | + }else if(rss && rss.data.code==0){ | |
| 124 | + //获取会员已经领取了多少张券 | |
| 125 | + var n1=rss.data.data.usercounted?rss.data.data.usercounted:0; | |
| 126 | + th.setData({'q_data.lqnum':n1}) | |
| 127 | + } | |
| 111 | 128 | |
| 112 | 129 | |
| 113 | 130 | |
| 114 | - // var user_id=getApp().globalData.user_id; | |
| 115 | - // await getApp().request.promiseGet("/api/weshop/prom/coupon/pageCouponList", { | |
| 116 | - // data:{store_id:os.stoid,type:1,id:th.data.id,user_id:user_id} | |
| 117 | - // }).then(res => { | |
| 118 | - // th.setData({is_get:1}); | |
| 119 | - // if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length){ | |
| 120 | - // th.setData({q_data:res.data.data.pageData[0]}); | |
| 121 | - // } | |
| 122 | - // }); | |
| 123 | - | |
| 124 | - | |
| 125 | 131 | }, |
| 126 | 132 | onUnload:function(){ |
| 127 | 133 | wx.offCopyUrl() |
| ... | ... | @@ -198,7 +204,7 @@ Page({ |
| 198 | 204 | success: function(res) { |
| 199 | 205 | th.data.linging = 0; |
| 200 | 206 | if (res.data.code == 0) { |
| 201 | - item.lqnum++; | |
| 207 | + | |
| 202 | 208 | var text3="q_data"; |
| 203 | 209 | var obj = {};obj[text3] = item; |
| 204 | 210 | th.setData(obj); |
| ... | ... | @@ -214,9 +220,24 @@ Page({ |
| 214 | 220 | } |
| 215 | 221 | }) |
| 216 | 222 | } else { |
| 217 | - th.setData({ | |
| 223 | + | |
| 224 | + //设置一下优惠券领取的数量 | |
| 225 | + var q_data=th.data.q_data; | |
| 226 | + q_data.use_sumnum++; | |
| 227 | + q_data.lqnum++; | |
| 228 | + | |
| 229 | + th.setData({ | |
| 218 | 230 | show_success: 1, |
| 231 | + q_data | |
| 219 | 232 | }) |
| 233 | + | |
| 234 | + if(q_data.everyone_num>0 && q_data.everyone_num<= q_data.lqnum){ | |
| 235 | + th.setData({is_get:5,err_txt:'您已领完该券'}); | |
| 236 | + }else if(q_data.interval_time>0){ | |
| 237 | + th.setData({is_get:5,err_txt:'您已领过该券'}); | |
| 238 | + } | |
| 239 | + | |
| 240 | + | |
| 220 | 241 | } |
| 221 | 242 | } else { |
| 222 | 243 | app.confirmBox(res.data.msg); | ... | ... |
packageA/pages/quan_pro/quan_pro.wxml
| ... | ... | @@ -34,7 +34,7 @@ |
| 34 | 34 | </view> |
| 35 | 35 | </view> |
| 36 | 36 | |
| 37 | - <block wx:if="{{ q_data}}"> | |
| 37 | + <block wx:if="{{q_data}}"> | |
| 38 | 38 | <view wx:if="{{ q_data.endtype==0}}" class="lower fs30">有效期 |
| 39 | 39 | <text wx:if="{{q_data.starttype==1}}"> {{filters.format_time(getcurday+3600*24*q_data.startdays)}}</text> |
| 40 | 40 | <text wx:if="{{q_data.use_start_time>0 && q_data.starttype==0}}"> {{filters.format_time(q_data.use_start_time)}}</text>至 |
| ... | ... | @@ -58,7 +58,9 @@ |
| 58 | 58 | </view> |
| 59 | 59 | |
| 60 | 60 | <view wx:if="{{q_data}}" class="flex jc-center" style="margin-top: 40rpx"> |
| 61 | - <view wx:if="{{q_data.everyone_num>0 && q_data.lqnum>=q_data.everyone_num}}" class="btn flex jc-center ai-center gray" bindtap="get_quan">已领取</view> | |
| 61 | + <view wx:if="{{q_data.sum_num>0 && q_data.use_sumnum>=q_data.sum_num}}" class="btn flex jc-center ai-center gray" >该券已领完</view> | |
| 62 | + <view wx:elif="{{is_get==4}}" class="btn flex jc-center ai-center gray" >优惠券已过期</view> | |
| 63 | + <view wx:elif="{{is_get==5}}" class="btn flex jc-center ai-center gray" >{{err_txt}}</view> | |
| 62 | 64 | <view wx:else class="btn flex jc-center ai-center" bindtap="get_quan">立即领取</view> |
| 63 | 65 | </view> |
| 64 | 66 | ... | ... |
packageA/pages/quan_pro/quan_pro.wxss
| ... | ... | @@ -26,7 +26,7 @@ page{background-color: #f8f8f8;} |
| 26 | 26 | border-bottom-left-radius:25rpx; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | -.btn.gray{background-color: #dcdcdc; color: #adb3be;} | |
| 29 | +.btn.gray{background-color: #aaa; color: #fff;} | |
| 30 | 30 | .coupon_remark{padding: 30rpx 0 10rpx 0; box-sizing: border-box; overflow: hidden;} |
| 31 | 31 | |
| 32 | 32 | .q_title{ | ... | ... |