Commit d79dd8a8280470e03627e011d690b121921c09b2

Authored by yvan.ni
1 parent 0110fab5

拼团的优化

pages/activity/pind_list/pind_list.js
@@ -120,25 +120,50 @@ Page({ @@ -120,25 +120,50 @@ Page({
120 var o = endTimeList[i]; 120 var o = endTimeList[i];
121 var endTime = o.end_time; 121 var endTime = o.end_time;
122 if(th.data.type==0) endTime = o.start_time; 122 if(th.data.type==0) endTime = o.start_time;
123 - let obj = null;  
124 - // 如果活动未结束,对时间进行处理  
125 - if (endTime - newTime > 0){  
126 - let time = (endTime - newTime);  
127 - // 获取天、时、分、秒  
128 - let day = parseInt(time / (60 * 60 * 24));  
129 - let hou = parseInt(time % (60 * 60 * 24) / 3600);  
130 - let min = parseInt(time % (60 * 60 * 24) % 3600 / 60);  
131 - let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);  
132 - obj = {  
133 - day: this.timeFormat(day), hou: this.timeFormat(hou), min: this.timeFormat(min), sec: this.timeFormat(sec),hide:1 123 +
  124 + // 创建查询对象
  125 + let query = wx.createSelectorQuery();
  126 + // 获取目标元素,并获取目标元素的信息
  127 + query.select("#kill-item"+i).boundingClientRect();
  128 + // 获取视口,并获取视口信息
  129 + query.selectViewport().boundingClientRect();
  130 + //-- 执行查询,元素要在显示中的才显示定时器 --
  131 + query.exec(([target, view]) => {
  132 +
  133 + if (!th.data.is_timer) return;
  134 + if (!target) return;
  135 + if (!target.id) return;
  136 + let idx= target.id.replace('kill-item','');
  137 + // 条件1:当目标顶部距离视口顶部距离小于视口的高度时
  138 + // 条件2:当目标底部距离视口顶部距离大于0时
  139 + // 当以上两个条件同时成立时,目标元素在视口中
  140 + if (target.top < view.height && target.bottom > 0) {
  141 +
  142 + let obj = null;
  143 + // 如果活动未结束,对时间进行处理
  144 + if (endTime - newTime > 0) {
  145 + let time = (endTime - newTime);
  146 + // 获取天、时、分、秒
  147 + let day = parseInt(time / (60 * 60 * 24));
  148 + let hou = parseInt(time % (60 * 60 * 24) / 3600);
  149 + let min = parseInt(time % (60 * 60 * 24) % 3600 / 60);
  150 + let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);
  151 + obj = {
  152 + day: this.timeFormat(day),
  153 + hou: this.timeFormat(hou),
  154 + min: this.timeFormat(min),
  155 + sec: this.timeFormat(sec),
  156 + hide: 1
  157 + }
  158 + } else {
  159 + //活动已结束,全部设置为'00'
  160 + obj = {day: '00', hou: '00', min: '00', sec: '00'}
134 } 161 }
135 - }else{  
136 - //活动已结束,全部设置为'00'  
137 - obj = { day: '00', hou: '00', min: '00', sec: '00' }  
138 - }  
139 - var txt ="goodlist["+i+"].djs";  
140 - th.setData({ [txt]: obj});  
141 - } 162 + var txt = "goodlist[" + idx + "].djs";
  163 + th.setData({[txt]: obj});
  164 + }
  165 + });
  166 + }
142 }, 167 },
143 168
144 //读取数据 169 //读取数据
pages/activity/pind_list/pind_list.wxml
@@ -28,7 +28,7 @@ @@ -28,7 +28,7 @@
28 28
29 29
30 <view class="kill-list"> 30 <view class="kill-list">
31 - <view class="kill-item" wx:for="{{goodlist}}" wx:if="{{item.djs.hide==1}}"> 31 + <view id="kill-item{{index}}" class="kill-item" wx:for="{{goodlist}}" >
32 <navigator class="kill-pic " url="{{!item.goods_type ? ('/pages/goods/goodsInfo/goodsInfo?prom_type=6&goods_id=' + item.goods_id+ '&prom_id=' + item.id):('/packageA/pages/serviceCard_pd/goodsInfo/goodsInfo?prom_type=6&goods_id=' + item.goods_id + '&prom_id=' + item.id)}}"> 32 <navigator class="kill-pic " url="{{!item.goods_type ? ('/pages/goods/goodsInfo/goodsInfo?prom_type=6&goods_id=' + item.goods_id+ '&prom_id=' + item.id):('/packageA/pages/serviceCard_pd/goodsInfo/goodsInfo?prom_type=6&goods_id=' + item.goods_id + '&prom_id=' + item.id)}}">
33 <image class="wh100" src="{{url}}{{item.original_img}}" data-val="{{item.original_img}}" 33 <image class="wh100" src="{{url}}{{item.original_img}}" data-val="{{item.original_img}}"
34 data-errorimg="goodlist[{{index}}].original_img" binderror="bind_bnerr2" lazy-load="true"></image> 34 data-errorimg="goodlist[{{index}}].original_img" binderror="bind_bnerr2" lazy-load="true"></image>
pages/goods/goodsInfo/goodsInfo.js
@@ -403,8 +403,8 @@ Page({ @@ -403,8 +403,8 @@ Page({
403 403
404 //判断活动 404 //判断活动
405 if (prom_type) { 405 if (prom_type) {
406 - this.data.prom_type = prom_type;  
407 - this.data.prom_id = prom_id; 406 + this.data.prom_type = parseInt(prom_type);
  407 + this.data.prom_id = parseInt(prom_id);
408 408
409 //-- 基础的活动类型 -- 409 //-- 基础的活动类型 --
410 this.data.base_nor_prom_type = prom_type; 410 this.data.base_nor_prom_type = prom_type;
@@ -5770,7 +5770,7 @@ Page({ @@ -5770,7 +5770,7 @@ Page({
5770 }); 5770 });
5771 5771
5772 // s.my_warnning('超出商品限购', 0, th); 5772 // s.my_warnning('超出商品限购', 0, th);
5773 - var num = 0;//th.data.prom_buy_limit - th.data.prom_buy_num; 5773 + var num = th.data.sele_g.viplimited - th.data.g_buy_num.get(th.data.sele_g.goods_id);
5774 if (num <= 0) num = 1; 5774 if (num <= 0) num = 1;
5775 th.setData({ 5775 th.setData({
5776 goodsInputNum: num 5776 goodsInputNum: num