| @@ -51,6 +51,9 @@ Page({ | |||||
| todayDate: todayDate, | todayDate: todayDate, | ||||
| showButton:false | showButton:false | ||||
| }) | }) | ||||
| if(that.data.pressEndDate){ | |||||
| that.countdown(that.data.pressEndDate) | |||||
| } | |||||
| }, | }, | ||||
| goback:function(){ | goback:function(){ | ||||
| wx.switchTab({ | wx.switchTab({ | ||||
| @@ -145,6 +148,9 @@ Page({ | |||||
| file.createDate = diffTime(file.createDate) | file.createDate = diffTime(file.createDate) | ||||
| }) | }) | ||||
| that.countdown(res.data.pressEndDate); | that.countdown(res.data.pressEndDate); | ||||
| that.setData({ | |||||
| pressEndDate: res.data.pressEndDate | |||||
| }) | |||||
| res.data.orderPressList.map(file=>{ | res.data.orderPressList.map(file=>{ | ||||
| compare(file.first); | compare(file.first); | ||||
| }) | }) | ||||
| @@ -165,14 +171,15 @@ Page({ | |||||
| wx.stopPullDownRefresh(); | wx.stopPullDownRefresh(); | ||||
| }) | }) | ||||
| }, | }, | ||||
| countdown(end_time) { | |||||
| setIntervalTime(end_time) { | |||||
| let that = this; | let that = this; | ||||
| var EndTime = end_time; | var EndTime = end_time; | ||||
| var NowTime = new Date().getTime(); | var NowTime = new Date().getTime(); | ||||
| var total_micro_second = EndTime - NowTime || []; | var total_micro_second = EndTime - NowTime || []; | ||||
| // 渲染倒计时时钟 | // 渲染倒计时时钟 | ||||
| let obj = that.dateformat(total_micro_second); | let obj = that.dateformat(total_micro_second); | ||||
| console.log(obj); | |||||
| if (total_micro_second > 0) { | if (total_micro_second > 0) { | ||||
| that.setData({ | that.setData({ | ||||
| clock: obj, | clock: obj, | ||||
| @@ -189,13 +196,23 @@ Page({ | |||||
| min: "00", | min: "00", | ||||
| sec: "00", | sec: "00", | ||||
| }) | }) | ||||
| //如果倒计时结束,需要重新查询一下券的状态 | |||||
| // 给getDetail一个标识 | |||||
| } | } | ||||
| setTimeout(function() { | |||||
| total_micro_second -= 1000; | |||||
| that.countdown(end_time); | |||||
| total_micro_second -= 1000; | |||||
| }, | |||||
| countdown: function (end_time) { | |||||
| let that = this; | |||||
| that.setIntervalTime(end_time); | |||||
| that.data.setInterval = setInterval(function () { | |||||
| that.setIntervalTime(end_time); | |||||
| }, 1000) | }, 1000) | ||||
| }, | }, | ||||
| // 时间格式化输出,如11:03 25:19 每1s都会调用一次 | // 时间格式化输出,如11:03 25:19 每1s都会调用一次 | ||||
| dateformat(micro_second) { | dateformat(micro_second) { | ||||
| // 总秒数 | // 总秒数 | ||||
| @@ -457,6 +474,14 @@ Page({ | |||||
| } | } | ||||
| }) | }) | ||||
| }, | }, | ||||
| onUnload: function () { | |||||
| let that = this; | |||||
| clearInterval(that.data.setInterval) | |||||
| }, | |||||
| onHide: function () { | |||||
| let that = this; | |||||
| clearInterval(that.data.setInterval) | |||||
| }, | |||||
| /** | /** | ||||
| * | * | ||||
| * @param {朋友邀请砍价} e | * @param {朋友邀请砍价} e | ||||