Commit bb0d9f77b3700effceda938d017093cc069cd784

Authored by 后端开发-许程
1 parent 238592bb

首页拼单修改

pages/index/index/index.js
... ... @@ -75,8 +75,11 @@ Page({
75 75  
76 76  
77 77 },
  78 +
  79 +
78 80 async onShow() {
79 81 var th=this;
  82 +
80 83 await this.init_load();
81 84 //显示的时候要开启计时器
82 85 this.data.is_timer = 1;
... ... @@ -117,7 +120,7 @@ Page({
117 120 }
118 121 })
119 122 },
120   -
  123 +
121 124 //当隐藏的时候就关闭计时器
122 125 onHide:function(){
123 126 this.data.is_timer=0;
... ... @@ -141,8 +144,8 @@ Page({
141 144 th.setData({ template_arr: t_arr, isTemplate: 1, bgcolor_t: temp_data.bkcolor});
142 145 }
143 146 })
144   - console.log("init_load");
145   - console.log(getApp().globalData.config);
  147 +
  148 +
146 149 //--首页的问题--
147 150 if(getApp().globalData.config && getApp().globalData.config.store_name!=undefined && getApp().globalData.config.store_name!=null ){
148 151 wx.setNavigationBarTitle({
... ... @@ -192,8 +195,7 @@ Page({
192 195 flash_data = e.data.data.pageData;
193 196 if (flash_data == null || flash_data.length <= 0) return false;
194 197  
195   - console.log('flash_data');
196   - console.log(flash_data);
  198 +
197 199 //当前时间戳
198 200 var nt = ut.gettimestamp();
199 201 console.log(nt);
... ... @@ -212,7 +214,7 @@ Page({
212 214 th.setData({
213 215 saleGoods: arr
214 216 });
215   - th.countDown();
  217 + //th.countDown();
216 218 }
217 219 });
218 220  
... ... @@ -228,27 +230,39 @@ Page({
228 230 var e = res;
229 231 if (e.data.code == 0) {
230 232 var pd_data = e.data.data.pageData;
231   - console.log("拼团列表的所有的数据在这里", pd_data);
  233 +
232 234 if (pd_data.length == 0) return;
233   -
234   - //当前时间戳
  235 +
  236 + //获取当前
235 237 var nt = ut.gettimestamp();
236 238 pd_data.forEach(function (val,ind) {
237 239 if(val.start_time>nt) pd_data[ind].status=0;
238 240 else if(val.end_time>nt) pd_data[ind].status=1;
239 241 if(val.buy_num>=val.goods_num) pd_data[ind].status=2;
240 242 });
241   -
  243 +
  244 + //获取当前时间,比较拼团中还在未开始
  245 + var timestamp = new Date().getTime();
  246 + var is_team_tepy;
  247 + for (var j = 0; j < pd_data.length;j++ ){
  248 + pd_data[j].is_team_tepy = 1;
  249 + if (timestamp<pd_data[j].start_time*1000){
  250 + var is_team_tepy;
  251 + pd_data[j].is_team_tepy = 0;
  252 + }
  253 + }
  254 +
242 255 var arr = new Array();
243 256 //--2个2个一组---
244 257 for(var i=0;i< pd_data.length;i+=2){
  258 +
245 259 arr.push(pd_data.slice(i,i+2));
246 260 }
247 261  
248 262 th.setData({
249 263 pindGoods: arr
250 264 });
251   - //th.countDown2();
  265 + th.countDown2();
252 266 }
253 267 })
254 268  
... ... @@ -463,6 +477,9 @@ Page({
463 477 //----拼单倒计时函数-----
464 478 countDown2() {
465 479 if(!this.data.is_timer) return false;
  480 +
  481 +
  482 +
466 483 var th = this;
467 484 // 获取当前时间,同时得到活动结束时间数组
468 485 var newTime = ut.gettimestamp();
... ... @@ -500,6 +517,9 @@ Page({
500 517 }
501 518 }
502 519 var txt = "pindGoods[" + j + "][" + i + "].djs";
  520 +
  521 +
  522 +
503 523 th.setData({
504 524 [txt]: obj
505 525 });
... ...
pages/index/index/index.wxml
1 1 <!--普通界面-->
2 2 <wxs module="filter" src="../../../utils/filter.wxs"></wxs>
3 3 <view class="container rel" wx:if="{{ishow}}">
4   -<block wx:if="{{banner}}">
  4 +<block wx:if="{{banner}}">
5 5 <image class="xc-top-img abs" src="{{url}}/miniapp/images/top-img.png"></image>
6 6 </block>
7 7 <!--搜索框-->
... ... @@ -199,23 +199,33 @@
199 199  
200 200 </navigator>
201 201 <view class="flex left">
202   - <view class="tneirong red-b flex-vertical rel">
  202 + <view class="tneirong red-b flex-vertical rel" wx:if="{{aitem.is_team_tepy!=0}}">
203 203 <image class="xc-team-img abs" src="{{url}}/miniapp/images/fril.png"></image>
204 204 已拼{{aitem.buy_num}}份</view>
205 205 <view class="fs20 flex xc-people-val-frame"
206   - style="border-color:{{type==1?'#059de5':'#d60021'}};margin-left:8rpx">
207   - <view class=" flex-center val-img {{type==1?'blue_b':'red-b'}}">
  206 + style="border-color:{{aitem.is_team_tepy==0?'#059de5':'#d60021'}};margin-left:{{aitem.is_team_tepy==0?'':'8rpx'}}">
  207 + <view class=" flex-center val-img {{aitem.is_team_tepy==0?'blue_b':'red-b'}}">
208 208 <image class="people-img"src="{{url}}/miniapp/images/bai-ren.png"></image>
209 209 </view>
210   - <text class="{{type==1?'blue_c':'red-co'}}" style="margin-left:8rpx; margin-right:8rpx">{{aitem.ct_num}}人团</text>
  210 + <text class="{{aitem.is_team_tepy==0?'blue_c':'red-co'}}" style="margin-left:8rpx; margin-right:8rpx">{{aitem.ct_num}}人团</text>
211 211 </view>
  212 +
  213 + <view class="fs20 blue_c time-blue" wx:if="{{aitem.is_team_tepy==0}}">
  214 + 距开始:
  215 + <text class='tui-conutdown-box'>{{aitem.djs.day}}</text>天
  216 + <text class='tui-conutdown-box'>{{aitem.djs.hou}}</text>时
  217 + <text class='tui-conutdown-box'>{{aitem.djs.min}}</text>分
  218 + <text class='tui-conutdown-box tui-countdown-bg'>{{aitem.djs.sec}}</text>
  219 + 秒
  220 + </view>
212 221 </view>
  222 +
213 223  
214 224 <view class="goods-num"style="margin-top:{{type==0?'70rpx':'40rpx'}}">
215 225 <view>
216 226  
217   - <view class="fs40 flex xc-top15 {{type==1?'blue_c':' red-co ai-bas'}}">
218   - <text class="fs28 {{type==0?'martop13':''}}">¥</text>
  227 + <view class="fs40 flex xc-top15 {{aitem.is_team_tepy==0?'blue_c':' red-co ai-bas'}}">
  228 + <text class="fs28 {{aitem.is_team_tepy==0?'martop4':''}}">¥</text>
219 229 <text style="margin-left:-5rpx">{{aitem.price}}</text>
220 230 <span class="underline {{type==0?'martop18':''}}">零售价¥{{aitem.market_price}}</span>
221 231 </view>
... ...
pages/index/index/index.wxss
... ... @@ -499,10 +499,10 @@ margin-top: 10rpx;
499 499 }
500 500 .xc-top15{
501 501 padding-top: 15rpx;
502   - margin-top: 4rpx;
  502 + margin-top: 43rpx;
503 503 }
504 504 .underline {
505   - text-decoration: line-through; color:#999999; font-size: 20rpx; margin-left: 5rpx;
  505 + text-decoration: line-through; color:#999999; font-size: 20rpx; margin-left: 5rpx;margin-top: 5rpx;
506 506 }
507 507 .navigator.navwidth{
508 508 width: 100%;
... ... @@ -708,4 +708,11 @@ left: 43%;
708 708 }
709 709 .m-left{
710 710 margin-left: 18rpx;
  711 +}
  712 +.martop4{
  713 +margin-top: 4rpx;
  714 +
  715 +}
  716 +.time-blue{
  717 +margin-left: 10rpx;
711 718 }
712 719 \ No newline at end of file
... ...