<view class='end_time'> <view class='reset_time'> <text class='time'>{{oDay}}</text> <text>:</text> <text class='time'>{{oHours}}</text> <text>:</text> <text class='time'>{{oMinutes}}</text> <text>:</text> <text class='time'>{{oSeconds}}</text> </view> <text>拼团失败</text> </view>
newTime: function (time) { const that = this; function resetTime() { //定义当前时间 var startTime = new Date(); //除以1000将毫秒数转化成秒数方便运算 startTime = startTime.getTime() / 1000 //定义结束时间 var endTime = time; //算出中间差并且已秒数返回; ; var countDown = endTime - startTime; //获取天数 1天 = 24小时 1小时= 60分 1分 = 60秒 var oDay = parseInt(countDown / (24 * 60 * 60)); if (oDay < 10) { oDay = '0' + oDay } //获取小时数 //特别留意 %24 这是因为需要剔除掉整的天数; var oHours = parseInt(countDown / (60 * 60) % 24); if (oHours < 10) { oHours = '0' + oHours } //获取分钟数 //同理剔除掉分钟数 var oMinutes = parseInt(countDown / 60 % 60); if (oMinutes < 10) { oMinutes = '0' + oMinutes } //获取秒数 //因为就是秒数 所以取得余数即可 var oSeconds = parseInt(countDown % 60); if (oSeconds < 10 && oSeconds >= 0) { oSeconds = '0' + oSeconds } that.setData({ oDay: oDay, oHours: oHours, oMinutes: oMinutes, oSeconds: oSeconds, finish_status:'false', }) //别忘记当时间为0的,要让其知道结束了; if (countDown < 0) { clearInterval(timer); that.setData({ finish_status:'true' }) } } var timer = setInterval(resetTime, 1000); },
.group_good .good_info .end_time{ display: flex; } .group_good .good_info .reset_time{ color: #f44; } .group_good .good_info .reset_time .time{ color: #fff; background-color: #f44; padding: 2rpx 4rpx; border-radius: 5rpx; margin: 0 4rpx; }
 
                    
                 
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号