(function() {
var timerInterval;
function startCountdown(duration) {
var timer = duration, hours, minutes, seconds;
if (timerInterval) clearInterval(timerInterval);
timerInterval = setInterval(function () {
var display = document.getElementById(‘payment-timer-display’);
if (!display) return;
hours = parseInt(timer / 3600, 10);
minutes = parseInt((timer % 3600) / 60, 10);
seconds = parseInt(timer % 60, 10);
hours = hours < 10 ? "0" + hours : hours;
minutes = minutes < 10 ? "0" + minutes : minutes;
seconds = seconds < 10 ? "0" + seconds : seconds;
display.textContent = hours + ":" + minutes + ":" + seconds;
if (–timer < 0) {
clearInterval(timerInterval);
display.textContent = "已过期";
display.style.color = "#9ca3af";
}
}, 1000);
}
if (typeof jQuery !== 'undefined') {
jQuery(document).on('pumAfterOpen', '#pum-1194', function () {
startCountdown(2 * 60 * 60);
});
jQuery(document).on('pumAfterClose', '#pum-1194', function () {
if (timerInterval) clearInterval(timerInterval);
});
}
})();