pull/1/head
liudan 1 year ago
parent 9251c47341
commit 5753ea20ad
  1. 67
      pages/qianggou/productDetails.vue

@ -47,7 +47,7 @@
立即抢购
</view>
<view class="page-footer" v-if="!isDeadLine">
还剩{{secondNum}}抢购
还剩{{finalSecondNum}}抢购
</view>
</view>
@ -77,6 +77,7 @@ export default {
},
secondNum:"",
isDeadLine:true,
finalSecondNum:"",
timer:null,
};
},
@ -104,32 +105,40 @@ export default {
expire_time=parseInt(expire_time/1000);//
return expire_time-timestamp;
},
// dateCalculation (second) { //
// if (second > 0) {
// var day = 0;
// var hour = 0;
// var minute = 0;
// var secondNum = 0;
// var data = {};
// minute = Math.floor(second / (60))
// if (parseInt(secondNum) > 60) {
// minute = parseInt(secondNum / 60);
// minute %= 60; //
// }
// if (parseInt(minute) > 60) {
// hour = parseInt(minute / 60);
// minute %= 60; //
// }
// if (parseInt(hour) > 24) {
// day = parseInt(hour / 24);
// hour %= 24; //
// }
// data.day = day;
// data.hour = hour;
// data.minute = minute;
// return data;
// }
// },
//
formatSeconds(value) {
var secondTime = parseInt(value);//
var minuteTime = 0;//
var hourTime = 0;//
if(secondTime > 60) {//60
//60
minuteTime = parseInt(secondTime / 60);
//
secondTime = parseInt(secondTime % 60);
//60
if(minuteTime > 60) {
//60
hourTime = parseInt(minuteTime / 60);
//60
minuteTime = parseInt(minuteTime % 60);
}
}
var result = "" + parseInt(secondTime) + "秒";
if(minuteTime > 0) {
result = "" + parseInt(minuteTime) + "分" + result;
}else{
result = "00时" + "00" + "分" + result;
}
if(hourTime > 0) {
result = "" + parseInt(hourTime) + "时" + result;
}else{
result = "00时" + result;
}
// console.log('result',result);
return result;
},
timestampToTime(val) {
var date = new Date();
var Y = date.getFullYear() + '-';
@ -156,7 +165,9 @@ export default {
let finishTime = this.dateDifference(new Date(time).getTime())
if(finishTime>0){
this.timer = setInterval(()=>{
this.secondNum = finishTime--
let secondNum = finishTime--;
this.secondNum = secondNum;
this.finalSecondNum = this.formatSeconds(this.secondNum)
},1000)
this.isDeadLine = false;
}else{

Loading…
Cancel
Save