Commit ff93b3664a1bd33329c2ad4ae27bb8ee5acd20eb

Authored by yvan.ni
1 parent 43fb56aa

小程序弹出节日有礼的图片

... ... @@ -381,5 +381,18 @@ App({
381 381 }
382 382 });
383 383 },
  384 +
  385 + //------定时等待某个值,有值才进行运算--------
  386 + waitfor:function(time,pop_value,func){
  387 + if(!time){
  388 + time=setInterval(function(){
  389 + console.log(time);
  390 + if(pop_value) {
  391 + clearInterval(time);
  392 + func();
  393 + }
  394 + },1000);
  395 + }
  396 + }
384 397  
385 398 });
... ...
pages/index/index/index.js
... ... @@ -70,6 +70,8 @@ Page({
70 70 is_disgraceful: 0, //是否显示新人广告
71 71 new_image: "", //新人有礼弹窗图片
72 72 new_nav: "", //新人页面跳转地址
  73 +
  74 + w_holiday_pop:0
73 75  
74 76 },
75 77  
... ... @@ -90,7 +92,7 @@ Page({
90 92 });
91 93 }
92 94 })
93   - th.is_festival();
  95 +
94 96  
95 97 },
96 98 //关闭新用户领取广告
... ... @@ -102,10 +104,7 @@ Page({
102 104 },
103 105 async onShow() {
104 106 var th = this;
105   - var new_nav = th.data.new_nav;
106   - if (new_nav == "") {
107   - th.is_new();
108   - }
  107 +
109 108 if (getApp().globalData.user_id) getApp().requestCardNum();
110 109 await this.init_load();
111 110 //显示的时候要开启计时器
... ... @@ -113,7 +112,14 @@ Page({
113 112 //如果是自定义模板
114 113 if (this.data.isTemplate) {
115 114 //---先获取会员---
116   - t.getUserFir(function() {});
  115 + t.getUserFir(function() {
  116 + th.is_festival();
  117 + var new_nav = th.data.new_nav;
  118 + if (new_nav == "") {
  119 + th.is_new();
  120 + }
  121 +
  122 + });
117 123 } else {
118 124 await this.init_fir();
119 125 }
... ... @@ -159,7 +165,8 @@ Page({
159 165 //当隐藏的时候就关闭计时器
160 166 onHide: function() {
161 167 this.data.is_timer = 0;
162   - clearInterval(this.data.pt_timer)
  168 + clearInterval(this.data.pt_timer);
  169 + clearInterval(this.data.w_holiday_pop);
163 170 },
164 171  
165 172 //同步初始加载
... ... @@ -368,7 +375,12 @@ Page({
368 375 });
369 376 //---先获取会员---
370 377 t.getUserFir(function() {
371   -
  378 + th.is_festival();
  379 + var new_nav = th.data.new_nav;
  380 + if (new_nav == "") {
  381 + th.is_new();
  382 + }
  383 +
372 384 });
373 385 var goods_list = this.selectComponent("#goods_list"); //组件的id
374 386 goods_list.init();
... ... @@ -727,12 +739,19 @@ Page({
727 739 th.setData({
728 740 is_disgraceful: 1
729 741 })
730   - }
  742 + }else{
  743 + th.check_holiday_pop(); //节日的弹窗
  744 + }
  745 +
731 746 })
732   - }
  747 + }else{
  748 + th.check_holiday_pop(); //节日的弹窗
  749 + }
  750 +
733 751 })
734 752  
735 753 },
  754 +
736 755 is_festival: function(e) {
737 756 var th = this;
738 757 var url = "/api/weshop/marketing/holiday/act/judge";
... ... @@ -747,7 +766,11 @@ Page({
747 766 var giftBagId = res.data.data.gifBagId; //礼包id
748 767 var nav_url = "/pages/giftpack/festival/festival?actId=" + actid + '&' + 'actType=' + 3 + '&' + 'giftBagId=' + giftBagId;
749 768 var swiperimage = th.data.swiperimage;
750   - var actBoundImg = res.data.data.actBoundImg; actBoundImg
  769 + var actBoundImg = res.data.data.actBoundImg;
  770 +
  771 + th.data.holiday_image= res.data.data.actImg;
  772 + th.data.holiday_url=nav_url;
  773 +
751 774 var img = {
752 775 image: actBoundImg,
753 776 nav_url: nav_url
... ... @@ -759,5 +782,19 @@ Page({
759 782 })
760 783 }
761 784 })
  785 + },
  786 +
  787 + //弹出节日有礼
  788 + check_holiday_pop:function(){
  789 + var th=this;
  790 + getApp().waitfor(th.data.w_holiday_pop,th.data.holiday_image,function(){
  791 + console.log(th.data.holiday_image);
  792 + th.setData({
  793 + new_image: th.data.holiday_image,
  794 + new_nav: th.data.holiday_url,
  795 + is_disgraceful: 1
  796 + })
  797 + })
762 798 }
  799 +
763 800 });
764 801 \ No newline at end of file
... ...
pages/index/index/index.wxml
... ... @@ -340,6 +340,7 @@
340 340 </view>
341 341 </block>
342 342 </view>
  343 +
343 344 <!-- 蒙尘 -->
344 345 <block wx:if="{{is_disgraceful}}">
345 346 <view class="disgraceful">
... ... @@ -357,4 +358,8 @@
357 358 </view>
358 359 </view>
359 360 </view>
360   -</block>
361 361 \ No newline at end of file
  362 +</block>
  363 +
  364 +
  365 +
  366 +
... ...