Commit 6ab65a3f7b98e9b4ecb7db5f1708ae2c495c78f3
1 parent
498e5447
1. 小程序霸屏
2. 拼单和秒杀的自定义模板的优化,空的时候要隐藏
Showing
8 changed files
with
199 additions
and
110 deletions
components/diy_advertising/diy_advertising.wxss
components/diy_pingd_buy/diy_pingd_buy.js
| ... | ... | @@ -37,6 +37,20 @@ Component({ |
| 37 | 37 | timer: null, |
| 38 | 38 | iurl:o.imghost, |
| 39 | 39 | }, |
| 40 | + | |
| 41 | + pageLifetimes:{ | |
| 42 | + //要处理一下,游客登录后的界面的变化,主要还该是改变会员 | |
| 43 | + show: function () { | |
| 44 | + var th=this; | |
| 45 | + if(this.data.goods_array.length>0){ | |
| 46 | + th.data.timer = setInterval(function() { | |
| 47 | + th.countDown2(th); | |
| 48 | + }, 1000); | |
| 49 | + } | |
| 50 | + } | |
| 51 | + }, | |
| 52 | + | |
| 53 | + | |
| 40 | 54 | ready: function() { |
| 41 | 55 | console.log("ready"); |
| 42 | 56 | var g_id = this.data.object.data; |
| ... | ... | @@ -55,50 +69,85 @@ Component({ |
| 55 | 69 | app = getApp(), all_array = [], |
| 56 | 70 | index = 0, |
| 57 | 71 | goodsidlist=""; |
| 72 | + | |
| 73 | + //-- 当是默认的调用的时候 -- | |
| 74 | + if(!g_id || g_id.length<=0 ){ | |
| 75 | + th.no_gid_set(); | |
| 76 | + }else{ | |
| 77 | + //--先把商品ID串起来-- | |
| 78 | + g_id.forEach(function(val, ind) { | |
| 79 | + var item = {}; | |
| 80 | + goodsidlist+=val.goodsid+","; | |
| 81 | + }) | |
| 82 | + goodsidlist= goodsidlist.substr(0,goodsidlist.length-1); | |
| 58 | 83 | |
| 59 | - //--先把商品ID串起来-- | |
| 60 | - g_id.forEach(function(val, ind) { | |
| 61 | - var item = {}; | |
| 62 | - goodsidlist+=val.goodsid+","; | |
| 63 | - }) | |
| 64 | - goodsidlist= goodsidlist.substr(0,goodsidlist.length-1); | |
| 84 | + //--调用接口,读取拼单-- | |
| 85 | + app.request.promiseGet("/api/weshop/teamlist/getGoodsList?store_id=" | |
| 86 | + +os.stoid+"&goodsidlist="+goodsidlist, {}).then(res => { | |
| 65 | 87 | |
| 66 | - //--调用接口,读取拼单-- | |
| 67 | - app.request.promiseGet("/api/weshop/teamlist/getGoodsList?store_id=" | |
| 68 | - +os.stoid+"&goodsidlist="+goodsidlist, {}).then(res => { | |
| 69 | - | |
| 70 | - //如果拼单的数组为空的时候 | |
| 71 | - var goodslist=res.data.data; | |
| 72 | - if(!goodslist || goodslist.length==0) return false; | |
| 73 | - | |
| 74 | - /*--商品队列按照添加的顺序排列--*/ | |
| 75 | - g_id.forEach(function(val, ind) { | |
| 76 | - goodslist.forEach(function (vy,indy) { | |
| 77 | - if(val.goodsid==vy.goods_id){ | |
| 78 | - all_array.push(vy); | |
| 79 | - } | |
| 80 | - }) | |
| 81 | - }) | |
| 82 | - if(all_array.length==0){ | |
| 83 | - all_array=goodslist; | |
| 84 | - } | |
| 85 | - | |
| 86 | - var arr = new Array(); | |
| 87 | - //--三个三个一组--- | |
| 88 | - for(var i=0;i< all_array.length;i+=3){ | |
| 89 | - arr.push(all_array.slice(i,i+3)); | |
| 90 | - } | |
| 91 | - /*--熏染到前台--*/ | |
| 92 | - th.setData({goods_array:arr}); | |
| 93 | - var newTime = ut.gettimestamp(); | |
| 94 | - th.setData({ newTime: newTime }); | |
| 95 | - | |
| 96 | - th.data.timer = setInterval(function() { | |
| 97 | - th.countDown2(th); | |
| 98 | - }, 1000); | |
| 99 | - }); | |
| 88 | + //如果拼单的数组为空的时候 | |
| 89 | + var goodslist=res.data.data; | |
| 90 | + if(!goodslist || goodslist.length==0){ | |
| 91 | + th.no_gid_set(); | |
| 92 | + }else{ | |
| 93 | + th.set_goods_list(g_id,goodslist); | |
| 94 | + } | |
| 95 | + | |
| 96 | + }); | |
| 97 | + } | |
| 100 | 98 | }, |
| 101 | - //---小于10的格式化函数---- | |
| 99 | + | |
| 100 | + no_gid_set(){ | |
| 101 | + var url= "/api/weshop/teamlist/pageteam/2?page=1&pageSize=9"; | |
| 102 | + getApp().request.promiseGet(url, { | |
| 103 | + data: { | |
| 104 | + store_id: os.stoid,is_end: 0,is_show: 1, | |
| 105 | + } | |
| 106 | + }).then(res => { | |
| 107 | + if(res.data.code==0 && res.data.data.pageData && e.data.data.pageData.length>0){ | |
| 108 | + goodsidlist=res.data.data.pageData; | |
| 109 | + th.set_goods_list(null,goodslist); | |
| 110 | + } | |
| 111 | + }) | |
| 112 | + }, | |
| 113 | + | |
| 114 | + //设置商品列表 | |
| 115 | + set_goods_list:function(g_id,goodslist){ | |
| 116 | + var th=this,all_array=[]; | |
| 117 | + if(g_id){ | |
| 118 | + /*--商品队列按照添加的顺序排列--*/ | |
| 119 | + g_id.forEach(function(val, ind) { | |
| 120 | + goodslist.forEach(function (vy,indy) { | |
| 121 | + if(val.goodsid==vy.goods_id){ | |
| 122 | + all_array.push(vy); | |
| 123 | + //th.setData({goods_array:arr}); | |
| 124 | + } | |
| 125 | + }) | |
| 126 | + }) | |
| 127 | + }else{ | |
| 128 | + all_array=goodslist; | |
| 129 | + } | |
| 130 | + | |
| 131 | + if(all_array.length==0){ | |
| 132 | + all_array=goodslist; | |
| 133 | + } | |
| 134 | + | |
| 135 | + var arr = new Array(); | |
| 136 | + //--三个三个一组--- | |
| 137 | + for(var i=0;i< all_array.length;i+=3){ | |
| 138 | + arr.push(all_array.slice(i,i+3)); | |
| 139 | + } | |
| 140 | + /*--熏染到前台--*/ | |
| 141 | + th.setData({goods_array:arr}); | |
| 142 | + var newTime = ut.gettimestamp(); | |
| 143 | + th.setData({ newTime: newTime }); | |
| 144 | + | |
| 145 | + th.data.timer = setInterval(function() { | |
| 146 | + th.countDown2(th); | |
| 147 | + }, 1000); | |
| 148 | + }, | |
| 149 | + | |
| 150 | + //---小于10的格式化函数---- | |
| 102 | 151 | timeFormat: function(param) { |
| 103 | 152 | return param < 10 ? '0' + param : param; |
| 104 | 153 | }, | ... | ... |
components/diy_pingd_buy/diy_pingd_buy.wxml
components/diy_seckill/diy_seckill.js
| ... | ... | @@ -36,6 +36,19 @@ Component({ |
| 36 | 36 | imghost: os.imghost, |
| 37 | 37 | timer: null, |
| 38 | 38 | }, |
| 39 | + | |
| 40 | + pageLifetimes:{ | |
| 41 | + //要处理一下,游客登录后的界面的变化,主要还该是改变会员 | |
| 42 | + show: function () { | |
| 43 | + var th=this; | |
| 44 | + if(this.data.goods_array.length>0){ | |
| 45 | + th.data.timer = setInterval(function() { | |
| 46 | + th.countDown2(th); | |
| 47 | + }, 1000); | |
| 48 | + } | |
| 49 | + } | |
| 50 | + }, | |
| 51 | + | |
| 39 | 52 | ready: function() { |
| 40 | 53 | console.log("ready"); |
| 41 | 54 | var g_id = this.data.object.data; |
| ... | ... | @@ -50,66 +63,84 @@ Component({ |
| 50 | 63 | // 这里是一个自定义方法 |
| 51 | 64 | customMethod: function() {}, |
| 52 | 65 | init: function(g_id) { |
| 53 | - var th = this, app = getApp(),all_array = [], goodsidlist=""; | |
| 54 | - | |
| 55 | - //--先把商品ID串起来-- | |
| 56 | - g_id.forEach(function(val, ind) { | |
| 57 | - var item = {}; | |
| 58 | - goodsidlist+=val.goodsid+","; | |
| 59 | - }) | |
| 60 | - goodsidlist=ut.sub_last(goodsidlist); | |
| 61 | - | |
| 62 | - //--调用接口,读取秒杀-- | |
| 63 | - app.request.promiseGet("/api/ms/flash_sale/getGoodsList?store_id=" | |
| 64 | - +os.stoid+"&goodsidlist="+goodsidlist, {}).then(res => { | |
| 65 | - //如果秒杀的数组为空的时候 | |
| 66 | - | |
| 67 | - var goodslist=res.data.data; | |
| 68 | - if(!goodslist || goodslist.length==0) return false; | |
| 69 | - | |
| 70 | - // 判断火热,预热 | |
| 71 | - var newTime = ut.gettimestamp(); | |
| 72 | - th.setData({newTime:newTime}); | |
| 73 | - // for(var a=0;a< goodslist.length;a++){ | |
| 74 | - // var starTime=goodslist[a].start_time; | |
| 75 | - // var msStr=[]; | |
| 76 | - // console.log(2222222222) | |
| 77 | - // console.log(starTime+":"+newTime) | |
| 78 | - // if (starTime>newTime){ | |
| 79 | - // msStr.push() | |
| 80 | - // //th.setData({msText:'即将开始'}); | |
| 81 | - // } | |
| 82 | - // if (starTime<newTime){ | |
| 83 | - // th.setData({msText:'火热进行'}); | |
| 84 | - // } | |
| 85 | - // } | |
| 86 | - /*--商品队列按照添加的顺序排列--*/ | |
| 87 | - g_id.forEach(function(val, ind) { | |
| 88 | - goodslist.forEach(function (vy,indy) { | |
| 89 | - if(val.goodsid==vy.goods_id){ | |
| 90 | - all_array.push(vy); | |
| 91 | - th.setData({goods_array:arr}); | |
| 92 | - } | |
| 93 | - }) | |
| 94 | - }) | |
| 95 | - if(all_array.length==0){ | |
| 96 | - all_array=goodslist; | |
| 97 | - } | |
| 98 | - | |
| 99 | - var arr = new Array(); | |
| 100 | - //--三个三个一组--- | |
| 101 | - for(var i=0;i< all_array.length;i+=3){ | |
| 102 | - arr.push(all_array.slice(i,i+3)); | |
| 103 | - } | |
| 104 | - /*--熏染到前台--*/ | |
| 105 | - | |
| 106 | - th.setData({goods_array:arr}); | |
| 107 | - | |
| 108 | - th.data.timer = setInterval(function() { | |
| 109 | - th.countDown2(th); | |
| 110 | - }, 1000); | |
| 111 | - }); | |
| 66 | + var th = this, app = getApp(), goodsidlist=""; | |
| 67 | + if(g_id && g_id.length>0){ | |
| 68 | + //--先把商品ID串起来-- | |
| 69 | + g_id.forEach(function(val, ind) { | |
| 70 | + var item = {}; | |
| 71 | + goodsidlist+=val.goodsid+","; | |
| 72 | + }) | |
| 73 | + goodsidlist=ut.sub_last(goodsidlist); | |
| 74 | + | |
| 75 | + //--调用接口,读取秒杀-- | |
| 76 | + app.request.promiseGet("/api/ms/flash_sale/getGoodsList?store_id=" | |
| 77 | + +os.stoid+"&goodsidlist="+goodsidlist, {}).then(res => { | |
| 78 | + //如果秒杀的数组为空的时候 | |
| 79 | + var goodslist=res.data.data; | |
| 80 | + //就算是添加的活动已经过期,就要用最新的进行中活动 | |
| 81 | + if(!goodslist || goodslist.length==0) { | |
| 82 | + th.no_gid_set(); | |
| 83 | + }else{ | |
| 84 | + th.set_goods_list(g_id,goodslist); | |
| 85 | + } | |
| 86 | + }); | |
| 87 | + }else{ | |
| 88 | + th.no_gid_set(); | |
| 89 | + } | |
| 112 | 90 | }, |
| 91 | + | |
| 92 | + //当是默认的情况 | |
| 93 | + no_gid_set(){ | |
| 94 | + getApp().request.promiseGet("/api/ms/flash_sale/spikepage?page=1&pageSize=9", | |
| 95 | + {isShowLoading:1,data:{store_id:os.stoid,is_end:0,is_show:1}} | |
| 96 | + ).then(res=>{ | |
| 97 | + if(res.data.code==0 && res.data.data.pageData && res.data.data.pageData.length>0) { | |
| 98 | + goodsidlist=res.data.data.pageData; | |
| 99 | + th.set_goods_list(null,goodslist); | |
| 100 | + } | |
| 101 | + }); | |
| 102 | + }, | |
| 103 | + | |
| 104 | + //就算是添加的活动已经过期,就要用最新的活动 | |
| 105 | + set_goods_list(g_id,goodslist){ | |
| 106 | + // 判断火热,预热 | |
| 107 | + var newTime = ut.gettimestamp(),all_array = [],th=this; | |
| 108 | + th.setData({newTime:newTime}); | |
| 109 | + if(g_id){ | |
| 110 | + /*--商品队列按照添加的顺序排列--*/ | |
| 111 | + g_id.forEach(function(val, ind) { | |
| 112 | + goodslist.forEach(function (vy,indy) { | |
| 113 | + if(val.goodsid==vy.goods_id){ | |
| 114 | + all_array.push(vy); | |
| 115 | + //th.setData({goods_array:arr}); | |
| 116 | + } | |
| 117 | + }) | |
| 118 | + }) | |
| 119 | + }else{ | |
| 120 | + all_array=goodslist; | |
| 121 | + } | |
| 122 | + | |
| 123 | + | |
| 124 | + if(all_array.length==0){ | |
| 125 | + all_array=goodslist; | |
| 126 | + } | |
| 127 | + | |
| 128 | + var arr = new Array(); | |
| 129 | + //--三个三个一组--- | |
| 130 | + for(var i=0;i< all_array.length;i+=3){ | |
| 131 | + arr.push(all_array.slice(i,i+3)); | |
| 132 | + } | |
| 133 | + /*--熏染到前台--*/ | |
| 134 | + | |
| 135 | + th.setData({goods_array:arr}); | |
| 136 | + | |
| 137 | + th.data.timer = setInterval(function() { | |
| 138 | + th.countDown2(th); | |
| 139 | + }, 1000); | |
| 140 | + }, | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 113 | 144 | //---小于10的格式化函数---- |
| 114 | 145 | timeFormat: function(param) { |
| 115 | 146 | return param < 10 ? '0' + param : param; | ... | ... |
components/diy_seckill/diy_seckill.wxml
components/full_screen/full_screen.js
| ... | ... | @@ -11,6 +11,7 @@ Component({ |
| 11 | 11 | full_ad:null, //全屏广告 |
| 12 | 12 | url:o.imghost, |
| 13 | 13 | full_screen:0, |
| 14 | + is_full_screen_men:1, | |
| 14 | 15 | }, |
| 15 | 16 | |
| 16 | 17 | pageLifetimes:{ |
| ... | ... | @@ -46,14 +47,14 @@ Component({ |
| 46 | 47 | }, |
| 47 | 48 | methods: { |
| 48 | 49 | close_full_screen(){ |
| 49 | - this.setData({is_full_screen_show:0,sec_show:0}); | |
| 50 | + this.setData({is_full_screen_show:0,sec_show:0,is_full_screen_men:0}); | |
| 50 | 51 | }, |
| 51 | 52 | //-- 跳转到满屏广告的链接 -- |
| 52 | 53 | go_full_ad(){ |
| 53 | 54 | if(!this.data.full_ad) return false; |
| 54 | 55 | if(!this.data.full_ad.ad_weapplink) return false; |
| 55 | 56 | getApp().goto(this.data.full_ad.ad_weapplink); |
| 56 | - this.setData({is_full_screen_show:0}); | |
| 57 | + this.setData({is_full_screen_show:0,is_full_screen_men:0}); | |
| 57 | 58 | }, |
| 58 | 59 | get_the_full_screen(){ |
| 59 | 60 | var th=this; |
| ... | ... | @@ -65,7 +66,7 @@ Component({ |
| 65 | 66 | if(res.data.code==0 && res.data.data.pageData && res.data.data.pageData.length>0){ |
| 66 | 67 | th.setData({ |
| 67 | 68 | is_full_screen_show:1, |
| 68 | - full_ad:res.data.data.pageData[0] | |
| 69 | + full_ad:res.data.data.pageData[0], | |
| 69 | 70 | }) |
| 70 | 71 | |
| 71 | 72 | //--定时关闭-- |
| ... | ... | @@ -78,7 +79,16 @@ Component({ |
| 78 | 79 | th.data.sec_show--; |
| 79 | 80 | th.setData({sec_show:th.data.sec_show}); |
| 80 | 81 | },1000) |
| 81 | - } | |
| 82 | + | |
| 83 | + | |
| 84 | + setTimeout(function(){ | |
| 85 | + th.setData({is_full_screen_men:0}); | |
| 86 | + },1000) | |
| 87 | + }else{ | |
| 88 | + th.setData({ | |
| 89 | + is_full_screen_men:0 | |
| 90 | + }) | |
| 91 | + } | |
| 82 | 92 | }) |
| 83 | 93 | } |
| 84 | 94 | }, | ... | ... |
components/full_screen/full_screen.wxml
| 1 | 1 | <!-- 全屏控制 --> |
| 2 | +<view hidden="{{!is_full_screen_men}}" class="full_screen" style="background-color: #fff;"></view> | |
| 2 | 3 | <view wx:if="{{is_full_screen_show}}" class="full_screen" bindtap="go_full_ad" style="background-image: url('{{url+full_ad.ad_code}}');"> |
| 3 | 4 | <view catchtap="close_full_screen" class="skip_box">跳过 <text>{{sec_show}}</text></view> |
| 4 | 5 | </view> | ... | ... |
pages/index/index/index.wxml