product-detail-header.js
1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// page/subPackage/pages/zeroSell/components/product-detail-header.js
import { fomartCountdownTime } from '../../../../utils/util';
Component({
properties: {
product: {
type: Object,
observer() {
this.setData({
formatTimeList: this.formatCountDown(),
});
},
},
avatars: {
type: Array,
},
shareFlag: {
type: Boolean,
value: false,
observer(value) {
this.setData({ show: value });
},
},
},
data: {
show: false,
isEnd: false,
formatTimeList: [],
},
ready: function() {
const timeId = setInterval(() => {
if (this.data.isEnd) {
this.triggerEvent('changeStatus');
clearInterval(timeId);
}
const formatTimeList = this.formatCountDown();
this.setData({
formatTimeList: formatTimeList,
isEnd: formatTimeList.length === 0,
});
}, 1000);
},
methods: {
formatCountDown() {
// 时间单位为S
let { end_time: endTime = 0 } = this.properties.product || {};
return fomartCountdownTime({ endTime });
},
},
});