...
|
...
|
@@ -4,93 +4,95 @@ Component({ |
|
|
* 组件的属性列表
|
|
|
*/
|
|
|
properties: {
|
|
|
endTime: {//结束时间
|
|
|
type: Number
|
|
|
floorData: {
|
|
|
type: Object,
|
|
|
value: {},
|
|
|
observer: '_dataChange'
|
|
|
},
|
|
|
formatTime: {
|
|
|
type: Array
|
|
|
}
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 组件的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
banner:[
|
|
|
{'src': "http://img11.static.yhbimg.com/yhb-img01/2019/07/08/16/01ebb6ff346dc35b904fd42a5118f2472c.jpg?imageView2/{mode}/w/{width}/h/{height}"},
|
|
|
{'src': "http://img10.static.yhbimg.com/yhb-img01/2019/07/08/16/015af7151eb026ebb776fac720eb227b0d.jpg?imageView2/{mode}/w/{width}/h/{height}"},
|
|
|
{'src': "http://img10.static.yhbimg.com/yhb-img01/2019/07/08/16/01055d8fc10a714574bf5cdcb57017abe0.jpg?imageView2/{mode}/w/{width}/h/{height}"}
|
|
|
],
|
|
|
formatTime: [],
|
|
|
},
|
|
|
|
|
|
ready: function() {
|
|
|
this.setData({
|
|
|
formatTime: this.formatCountDown(this.properties.endTime)
|
|
|
})
|
|
|
this.formatTime()
|
|
|
this.loadFontFace()
|
|
|
},
|
|
|
/**
|
|
|
* 组件的方法列表
|
|
|
*/
|
|
|
methods: {
|
|
|
formatTime:function() {
|
|
|
let self = this
|
|
|
setInterval(function() {
|
|
|
self.setData({
|
|
|
formatTime: self.formatCountDown(self.properties.endTime)
|
|
|
})
|
|
|
},1000)
|
|
|
},
|
|
|
formatCountDown:function formatCountDown(end) {
|
|
|
if (end === 0 || (end * 1000 - Date.now() < 0)) {
|
|
|
return '00000000'
|
|
|
}
|
|
|
var timeInSecond = (end * 1000 - Date.now()) / 1000
|
|
|
_dataChange(newValue, oldValue){
|
|
|
this._formatTime()
|
|
|
},
|
|
|
|
|
|
var day = 24 * 60 * 60
|
|
|
var numberOfDay = Math.floor(timeInSecond / day)
|
|
|
timeInSecond = timeInSecond - numberOfDay * day
|
|
|
numberOfDay = Math.min(numberOfDay, 99)
|
|
|
_formatTime:function() {
|
|
|
let that = this;
|
|
|
setInterval(function() {
|
|
|
that.setData({
|
|
|
formatTime: that.formatCountDown(that.properties.floorData.startTime),
|
|
|
})
|
|
|
},1000)
|
|
|
},
|
|
|
|
|
|
var hour = 60 * 60
|
|
|
var numberOfHour = Math.floor(timeInSecond / hour)
|
|
|
timeInSecond = timeInSecond - numberOfHour * hour
|
|
|
formatCountDown(end) {
|
|
|
if (end === 0 || (end * 1000 - Date.now() < 0)) {
|
|
|
return '00000000'
|
|
|
}
|
|
|
var timeInSecond = (end * 1000 - Date.now()) / 1000
|
|
|
|
|
|
var minute = 60
|
|
|
var numberOfMinute = Math.floor(timeInSecond / minute)
|
|
|
timeInSecond = timeInSecond - numberOfMinute * minute
|
|
|
var day = 24 * 60 * 60
|
|
|
var numberOfDay = Math.floor(timeInSecond / day)
|
|
|
timeInSecond = timeInSecond - numberOfDay * day
|
|
|
numberOfDay = Math.min(numberOfDay, 99)
|
|
|
|
|
|
var numberOfSecond = parseInt(timeInSecond)
|
|
|
var hour = 60 * 60
|
|
|
var numberOfHour = Math.floor(timeInSecond / hour)
|
|
|
timeInSecond = timeInSecond - numberOfHour * hour
|
|
|
|
|
|
var list = [numberOfDay, numberOfHour, numberOfMinute, numberOfSecond]
|
|
|
var newList = []
|
|
|
var minute = 60
|
|
|
var numberOfMinute = Math.floor(timeInSecond / minute)
|
|
|
timeInSecond = timeInSecond - numberOfMinute * minute
|
|
|
|
|
|
for (var i = 0; i < list.length; i++) {
|
|
|
var item = list[i]
|
|
|
if (item < 10) {
|
|
|
list[i] = '0' + item
|
|
|
} else {
|
|
|
list[i] = '' + item
|
|
|
}
|
|
|
var numberOfSecond = parseInt(timeInSecond)
|
|
|
|
|
|
//新增拆分
|
|
|
var array = list[i].split('')
|
|
|
do {
|
|
|
let number = array.shift()
|
|
|
newList.push(number)
|
|
|
var list = [numberOfDay, numberOfHour, numberOfMinute, numberOfSecond]
|
|
|
var newList = []
|
|
|
|
|
|
} while (array.length > 0);
|
|
|
for (var i = 0; i < list.length; i++) {
|
|
|
var item = list[i]
|
|
|
if (item < 10) {
|
|
|
list[i] = '0' + item
|
|
|
} else {
|
|
|
list[i] = '' + item
|
|
|
}
|
|
|
return newList
|
|
|
},
|
|
|
|
|
|
loadFontFace() {
|
|
|
const self = this
|
|
|
wx.loadFontFace({
|
|
|
family: 'CAI978',
|
|
|
source: 'url("https://cdn.yoho.cn/miniapp/yohood/statics/font/064-CAI978.ttf")',
|
|
|
});
|
|
|
},
|
|
|
//新增拆分
|
|
|
var array = list[i].split('')
|
|
|
do {
|
|
|
let number = array.shift()
|
|
|
newList.push(number)
|
|
|
|
|
|
} while (array.length > 0);
|
|
|
}
|
|
|
return newList
|
|
|
},
|
|
|
|
|
|
loadFontFace() {
|
|
|
const self = this
|
|
|
wx.loadFontFace({
|
|
|
family: 'CAI978',
|
|
|
source: 'url("https://cdn.yoho.cn/miniapp/yohood/statics/font/064-CAI978.ttf")',
|
|
|
});
|
|
|
},
|
|
|
|
|
|
tapBanner(e) {
|
|
|
let href = e.detail.href;
|
|
|
let articleId = e.detail.articleId;
|
|
|
this.triggerEvent('tapBanner', { href:href, articleId:articleId });
|
|
|
}
|
|
|
}
|
|
|
}) |
...
|
...
|
|