Commit 74db414bda7399940cee6cc3972b2eab68fc4826

Authored by yvan.ni
1 parent 3a3e37f8

判断有没有领过券

packageA/pages/profile/profile.js
... ... @@ -525,18 +525,16 @@ Page({
525 525  
526 526 self = this;
527 527 let url1 = '/api/weshop/storeconfig/get/';
528   - let url2 = '/api/weshop/prom/coupon/get/';
529 528 let url3 = '/api/weshop/users/getERPUser/';
530 529 url1 += r.stoid;
531 530 var user=app.globalData.userInfo;
  531 + if(!user) return false;
532 532  
533 533 //-- 赋予默认值 --
534 534 if(user['idcard']) this.data.id=user['idcard'];
535 535 if(user['vipname']) this.data.name=user['vipname'];
536 536 if(user['address']) this.data.address=user['address'];
537   -
538   -
539   -
  537 +
540 538 app.request.get(url1, {
541 539 success: function(res) {
542 540 console.log('x-->', res.data.code, res.data.data.reg_type, res.data.data.reg_info);
... ... @@ -545,19 +543,11 @@ Page({
545 543 let reg_info = res.data.data.reg_info;
546 544 if(reg_type) { //reg_type为1才显示积分信息
547 545 if(reg_info) {
548   - reg_info = JSON.parse(reg_info);
549   - //获取优惠券
550   - url2 += reg_info.reginfo_coupon;
551   - app.request.get(url2, {
552   - success: function(r) {
553   - if(r.data.code == 0) {
554   - console.log('000res==>', r.data.data.name);
555   - self.setData({
556   - couponInfo: r.data.data.name,
557   - });
558   - };
559   - },
560   - });
  546 + reg_info = JSON.parse(reg_info);
  547 + if(reg_info.reginfo_coupon){
  548 + //判断有没有领过券
  549 + self.check_is_send_quan(reg_info.reginfo_coupon,user.user_id);
  550 + }
561 551 };
562 552 };
563 553 self.setData({
... ... @@ -632,16 +622,13 @@ Page({
632 622 };
633 623 }
634 624 });
635   -
636   -
  625 +
637 626 if(user){
638   - self.setData({user:user})
  627 + self.setData({user:user})
639 628 }
640 629  
641 630 },
642   -
643   -
644   -
  631 +
645 632 onShow: function() {
646 633 var e = this;
647 634 if (this.data.is_zy) return false;
... ... @@ -680,7 +667,37 @@ Page({
680 667 }, !0);
681 668 },
682 669  
683   -
  670 + check_is_send_quan:function(cid,uid){
  671 + var self=this;
  672 + let url2 = '/api/weshop/prom/coupon/get/';
  673 + //看一下会员有没有领过注册的券
  674 + getApp().promiseGet("/api/weshop/couponList/page",{
  675 + data:{store_id:r.stoid,uid:uid,cid:cid}
  676 + }).then(res=>{
  677 + var is_ling=0;
  678 + if(res.data.code==0 && res.data.data && res.data.data.total>0){
  679 + is_ling=1;
  680 + }
  681 +
  682 + //没有领过券,就显示
  683 + if(!is_ling){
  684 + //获取优惠券
  685 + url2 += cid;
  686 + app.request.get(url2, {
  687 + success: function(r) {
  688 + if(r.data.code == 0) {
  689 + console.log('000res==>', r.data.data.name);
  690 + self.setData({
  691 + couponInfo: r.data.data.name,
  692 + });
  693 + };
  694 + },
  695 + });
  696 + }
  697 +
  698 + })
  699 +
  700 + },
684 701  
685 702  
686 703 //------卡片的显示和关闭--------
... ...