diff --git a/pages/index/index/index.js b/pages/index/index/index.js index 616368d..cffefd4 100644 --- a/pages/index/index/index.js +++ b/pages/index/index/index.js @@ -46,6 +46,12 @@ Page({ banner_index:0, flash_index:0, pt_index:0, + + pt_timer_item:null, + pt_timer_arr:null, + pt_timer:null, + pt_timer_active:0, + }, onLoad: function () { var th = this; @@ -62,16 +68,34 @@ Page({ }else{ await this.init_fir(); } + + //--正再拼团中的处理-- + var url="/api/weshop/order/pageTuan?pt_status=1&is_pt=1&store_id="+os.stoid+"&pageSize=6&page=1" + await getApp().request.promiseGet(url,{}).then(res=>{ + if(res.data.code==0 && res.data.data && res.data.data.pageData){ + th.data.pt_timer_arr=res.data.data.pageData; + } + }) + if(th.data.pt_timer_arr && th.data.pt_timer_arr.length>0){ + for(var i in th.data.pt_timer_arr){ + var p_item=th.data.pt_timer_arr[i]; + await getApp().request.promiseGet("/api/weshop/users/get/"+os.stoid+"/"+p_item.user_id,{1:1}).then(res=>{ + th.data.pt_timer_arr[i].head_pic=res.data.data.head_pic; + }) + } + th.Interval_pt(); + } + }, //当隐藏的时候就关闭计时器 onHide:function(){ this.data.is_timer=0; + clearInterval(this.data.pt_timer) }, //同步初始加载 async init_load(){ - var th=this; await getApp().get_isbuy(); this.setappdata(getApp().globalData.wxapp_buy_obj); @@ -467,7 +491,17 @@ Page({ ptSwiperChange:function (e) { var index=e.detail.current; this.setData({pt_index:index}); - } + }, + Interval_pt() { + var th=this; + this.data.pt_timer=setInterval(function () { + var item=ut.get_rand_item(th.data.pt_timer_arr); + th.setData({pt_timer_active:1,pt_timer_item:item}); + setTimeout(function () { + th.setData({pt_timer_active:0}); + },1000) + },3000); + } }); \ No newline at end of file diff --git a/utils/util.js b/utils/util.js index f15123d..53568d6 100644 --- a/utils/util.js +++ b/utils/util.js @@ -345,5 +345,6 @@ module.exports = { sub_last: sub_last,//去掉末尾一个字符 measureText: measureText,//画布需要的函数 check_mobile: check_mobile,//验证手机 + get_rand_item:get_rand_item, //随机获取元素 };