diff --git a/packageA/pages/profile/profile.js b/packageA/pages/profile/profile.js index 7a40acc..a81c0c6 100644 --- a/packageA/pages/profile/profile.js +++ b/packageA/pages/profile/profile.js @@ -525,18 +525,16 @@ Page({ self = this; let url1 = '/api/weshop/storeconfig/get/'; - let url2 = '/api/weshop/prom/coupon/get/'; let url3 = '/api/weshop/users/getERPUser/'; url1 += r.stoid; var user=app.globalData.userInfo; + if(!user) return false; //-- 赋予默认值 -- if(user['idcard']) this.data.id=user['idcard']; if(user['vipname']) this.data.name=user['vipname']; if(user['address']) this.data.address=user['address']; - - - + app.request.get(url1, { success: function(res) { console.log('x-->', res.data.code, res.data.data.reg_type, res.data.data.reg_info); @@ -545,19 +543,11 @@ Page({ let reg_info = res.data.data.reg_info; if(reg_type) { //reg_type为1才显示积分信息 if(reg_info) { - reg_info = JSON.parse(reg_info); - //获取优惠券 - url2 += reg_info.reginfo_coupon; - app.request.get(url2, { - success: function(r) { - if(r.data.code == 0) { - console.log('000res==>', r.data.data.name); - self.setData({ - couponInfo: r.data.data.name, - }); - }; - }, - }); + reg_info = JSON.parse(reg_info); + if(reg_info.reginfo_coupon){ + //判断有没有领过券 + self.check_is_send_quan(reg_info.reginfo_coupon,user.user_id); + } }; }; self.setData({ @@ -632,16 +622,13 @@ Page({ }; } }); - - + if(user){ - self.setData({user:user}) + self.setData({user:user}) } }, - - - + onShow: function() { var e = this; if (this.data.is_zy) return false; @@ -680,7 +667,37 @@ Page({ }, !0); }, - + check_is_send_quan:function(cid,uid){ + var self=this; + let url2 = '/api/weshop/prom/coupon/get/'; + //看一下会员有没有领过注册的券 + getApp().promiseGet("/api/weshop/couponList/page",{ + data:{store_id:r.stoid,uid:uid,cid:cid} + }).then(res=>{ + var is_ling=0; + if(res.data.code==0 && res.data.data && res.data.data.total>0){ + is_ling=1; + } + + //没有领过券,就显示 + if(!is_ling){ + //获取优惠券 + url2 += cid; + app.request.get(url2, { + success: function(r) { + if(r.data.code == 0) { + console.log('000res==>', r.data.data.name); + self.setData({ + couponInfo: r.data.data.name, + }); + }; + }, + }); + } + + }) + + }, //------卡片的显示和关闭--------