Component({ properties: { info: Object, formData: Array }, data: { day: "", hour: "", minute: "", second: "", swiperHeight: 240, sell_times: null, startTime: [] }, observers: { info: function(t) { 1 == t.status ? this.setTime() : -1 == t.status ? this.setStartTime(t.sell_times[0]) : -2 == t.status && this.setStartTime(t.sell_times[1]); } }, timer: null, methods: { setStartTime: function(t) { var e = new Date(1e3 * t), i = [ e.getFullYear(), this.changeNum(e.getMonth() + 1), this.changeNum(e.getDate()) ].join("/"), s = [ this.changeNum(e.getHours()), this.changeNum(e.getMinutes()), this.changeNum(e.getSeconds()) ].join(":"); console.log(i), console.log(s), this.setData({ startTime: [ i, s ] }); }, changeNum: function(t) { return t > 9 ? t : "0" + t; }, setTime: function() { var t = 1e3 * this.properties.info.sell_times[1] - new Date().getTime(); if (t <= 0) clearTimeout(this.timer); else { var e, i, s, a, o = t / 1e3 / 3600 / 24, n = 24 * (o - (e = Math.floor(o))), r = 60 * (n - (i = Math.floor(n))), h = 60 * (r - (s = Math.floor(r))); a = Math.floor(h), this.setData({ day: (e + "").padStart(2, "0"), hour: (i + "").padStart(2, "0"), minute: (s + "").padStart(2, "0"), second: (a + "").padStart(2, "0") }); } setTimeout(function() { this.setTime(); }.bind(this), 1e3); }, load: function(t) { var e = wx.getSystemInfoSync().windowWidth; this.setData({ swiperHeight: Math.max(e * t.detail.height / t.detail.width, this.data.swiperHeight) }); } } });