From ff93b3664a1bd33329c2ad4ae27bb8ee5acd20eb Mon Sep 17 00:00:00 2001 From: yvan.ni <765199919@qq.com> Date: Mon, 16 Mar 2020 16:15:29 +0800 Subject: [PATCH] 小程序弹出节日有礼的图片 --- app.js | 13 +++++++++++++ pages/index/index/index.js | 59 ++++++++++++++++++++++++++++++++++++++++++++++++----------- pages/index/index/index.wxml | 7 ++++++- 3 files changed, 67 insertions(+), 12 deletions(-) diff --git a/app.js b/app.js index 3df75a3..909d5f6 100644 --- a/app.js +++ b/app.js @@ -381,5 +381,18 @@ App({ } }); }, + + //------定时等待某个值,有值才进行运算-------- + waitfor:function(time,pop_value,func){ + if(!time){ + time=setInterval(function(){ + console.log(time); + if(pop_value) { + clearInterval(time); + func(); + } + },1000); + } + } }); diff --git a/pages/index/index/index.js b/pages/index/index/index.js index a94c78e..dc76955 100644 --- a/pages/index/index/index.js +++ b/pages/index/index/index.js @@ -70,6 +70,8 @@ Page({ is_disgraceful: 0, //是否显示新人广告 new_image: "", //新人有礼弹窗图片 new_nav: "", //新人页面跳转地址 + + w_holiday_pop:0 }, @@ -90,7 +92,7 @@ Page({ }); } }) - th.is_festival(); + }, //关闭新用户领取广告 @@ -102,10 +104,7 @@ Page({ }, async onShow() { var th = this; - var new_nav = th.data.new_nav; - if (new_nav == "") { - th.is_new(); - } + if (getApp().globalData.user_id) getApp().requestCardNum(); await this.init_load(); //显示的时候要开启计时器 @@ -113,7 +112,14 @@ Page({ //如果是自定义模板 if (this.data.isTemplate) { //---先获取会员--- - t.getUserFir(function() {}); + t.getUserFir(function() { + th.is_festival(); + var new_nav = th.data.new_nav; + if (new_nav == "") { + th.is_new(); + } + + }); } else { await this.init_fir(); } @@ -159,7 +165,8 @@ Page({ //当隐藏的时候就关闭计时器 onHide: function() { this.data.is_timer = 0; - clearInterval(this.data.pt_timer) + clearInterval(this.data.pt_timer); + clearInterval(this.data.w_holiday_pop); }, //同步初始加载 @@ -368,7 +375,12 @@ Page({ }); //---先获取会员--- t.getUserFir(function() { - + th.is_festival(); + var new_nav = th.data.new_nav; + if (new_nav == "") { + th.is_new(); + } + }); var goods_list = this.selectComponent("#goods_list"); //组件的id goods_list.init(); @@ -727,12 +739,19 @@ Page({ th.setData({ is_disgraceful: 1 }) - } + }else{ + th.check_holiday_pop(); //节日的弹窗 + } + }) - } + }else{ + th.check_holiday_pop(); //节日的弹窗 + } + }) }, + is_festival: function(e) { var th = this; var url = "/api/weshop/marketing/holiday/act/judge"; @@ -747,7 +766,11 @@ Page({ var giftBagId = res.data.data.gifBagId; //礼包id var nav_url = "/pages/giftpack/festival/festival?actId=" + actid + '&' + 'actType=' + 3 + '&' + 'giftBagId=' + giftBagId; var swiperimage = th.data.swiperimage; - var actBoundImg = res.data.data.actBoundImg; actBoundImg + var actBoundImg = res.data.data.actBoundImg; + + th.data.holiday_image= res.data.data.actImg; + th.data.holiday_url=nav_url; + var img = { image: actBoundImg, nav_url: nav_url @@ -759,5 +782,19 @@ Page({ }) } }) + }, + + //弹出节日有礼 + check_holiday_pop:function(){ + var th=this; + getApp().waitfor(th.data.w_holiday_pop,th.data.holiday_image,function(){ + console.log(th.data.holiday_image); + th.setData({ + new_image: th.data.holiday_image, + new_nav: th.data.holiday_url, + is_disgraceful: 1 + }) + }) } + }); \ No newline at end of file diff --git a/pages/index/index/index.wxml b/pages/index/index/index.wxml index b512855..34af204 100644 --- a/pages/index/index/index.wxml +++ b/pages/index/index/index.wxml @@ -340,6 +340,7 @@ + @@ -357,4 +358,8 @@ - \ No newline at end of file + + + + + -- libgit2 0.21.4