Authored by huangyCode

修改商品详情

... ... @@ -24,6 +24,28 @@ function hiddenTips($ele) {
}
}
function add0(m) {
return m < 10 ? '0' + m : m;
}
function formatDate(shijianchuo) {
// 秒数
let second = Math.floor(shijianchuo);
// 小时位
let hr = Math.floor(second / 3600);
// 分钟位
let min = Math.floor((second - hr * 3600) / 60);
// 秒位
let sec = (second - hr * 3600 - min * 60);
return add0(hr) + ':' + add0(min) + ':' + add0(sec);
}
let timer;
class Detail extends Page {
constructor() {
super();
... ... @@ -36,6 +58,7 @@ class Detail extends Page {
this.getIntro();
this.goSwiper();
this.toTop();
this.startTimer();
}
getIntro() {
... ... @@ -145,6 +168,29 @@ class Detail extends Page {
}
});
}
startTimer() {
let list = [];
let activityGroupDetailList = document.querySelectorAll('.left-time');
for (let item of activityGroupDetailList) {
list.push(item.getAttribute('data-value'));
}
timer = setInterval(function() {
for (let i = 0; i < activityGroupDetailList.length; i++) {
list[i] = Number(list[i]) - 1;
if (list[i]) {
activityGroupDetailList[i].innerText = formatDate(list[i]);
} else {
clearInterval(timer);
window.reload();
}
}
}, 1000);
}
stopTimer() {
clearInterval(timer);
}
}
$(() => {
new Detail();
... ...