// 15分鐘計時
var timers = null;
var initMax = parseInt(900);//
var intDiff = parseInt(0);// 訂單時間
// 15分鐘計時
// 1分鐘倒計時
var fiveTimer = null;
var fiveInit = parseInt(60);// 倒計時總秒數(shù)量
// 1分鐘倒計時
// 上麥計時
var marketTime = null;// 麥上時間
var marketInit = parseInt(0);// 麥上時間初始化
// 上麥計時
// 緩存有時間讀緩存
if ('intDiff' in cacheOrder) {
? ? intDiff = cacheOrder.intDiff;
? ? console.log('15分鐘', intDiff)
}
// 15分鐘計時
function chronoscope(intDiff) {
? ? timers = window.setInterval(function () {
? ? ? ? var day = 0,
? ? ? ? ? ? hour = 0,
? ? ? ? ? ? minute = 0,
? ? ? ? ? ? second = 0;// 時間默認(rèn)值? ? ? ?
? ? ? ? if (intDiff < initMax) {
? ? ? ? ? ? minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
? ? ? ? ? ? second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
? ? ? ? ? ? intDiff++;
? ? ? ? ? ? cacheOrder.intDiff = intDiff; // 賦值時間
? ? ? ? ? ? sessionStorage.setItem('order', JSON.stringify(cacheOrder));// 儲存時間
? ? ? ? } else {
? ? ? ? ? ? clearInterval(timers); // 清除定時器
? ? ? ? ? ? orderClose(4); // 棄單
? ? ? ? }
? ? ? ? // console.log(intDiff,'15分鐘');
? ? ? ? if (minute <= 9) minute = '0' + minute;
? ? ? ? if (second <= 9) second = '0' + second;
? ? ? ? $('.minute_show').html('<s></s>' + minute + '分');
? ? ? ? $('.second_show').html('<s></s>' + second + '秒');
? ? }, 1000);
}
// 麥上時間計時器
function market(timeBox) {
? ? this.timeBox = timeBox;
? ? market.prototype.marketSet = function () {
? ? ? ? marketTime = window.setInterval(function () {
? ? ? ? ? ? let hour = 0,
? ? ? ? ? ? ? ? minute = 0,
? ? ? ? ? ? ? ? second = 0;// 時間默認(rèn)值
? ? ? ? ? ? day = Math.floor(marketInit / (60 * 60 * 24));
? ? ? ? ? ? hour = Math.floor(marketInit / (60 * 60)) - (day * 24);
? ? ? ? ? ? minute = Math.floor(marketInit / 60) - (day * 24 * 60) - (hour * 60);
? ? ? ? ? ? second = Math.floor(marketInit) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
? ? ? ? ? ? marketInit++;
? ? ? ? ? ? cacheOrder.marketInit = marketInit; // 賦值時間
? ? ? ? ? ? sessionStorage.setItem('order', JSON.stringify(cacheOrder));// 儲存時間? ? ? ? ? ?
? ? ? ? ? ? if (hour <= 9) hour = '0' + hour;
? ? ? ? ? ? if (minute <= 9) minute = '0' + minute;
? ? ? ? ? ? if (second <= 9) second = '0' + second;
? ? ? ? ? ? $(timeBox).html(`開啟時長:${hour} 小時 ${minute} 分鐘`);
? ? ? ? }, 1000)
? ? }
}
var wheat = new market('.voice-time');
// 麥上時間計時器
// 1分鐘倒計時
function countdown(fiveInit) {
? ? fiveTimer = window.setInterval(function () {
? ? ? ? console.log(fiveInit, '***************************************')
? ? ? ? if (fiveInit > 0) {
? ? ? ? ? ? $(".ts-order").addClass('un-click');
? ? ? ? ? ? $(".ts-order").attr('disabled', true);
? ? ? ? ? ? $('#five-times').html('推送更多大神(' + fiveInit + 's)');
? ? ? ? ? ? fiveInit--;
? ? ? ? ? ? cacheOrder.fiveInit = fiveInit; // 賦值時間
? ? ? ? ? ? sessionStorage.setItem('order', JSON.stringify(cacheOrder));// 儲存時間
? ? ? ? ? ? console.log(fiveInit);
? ? ? ? } else {
? ? ? ? ? ? console.log('禁用大神按鈕')
? ? ? ? ? ? clearInterval(fiveTimer);
? ? ? ? ? ? $(".ts-order").removeClass('un-click');
? ? ? ? ? ? $(".ts-order").attr('disabled', false);
? ? ? ? ? ? $('#five-times').html('推送更多大神');
? ? ? ? }
? ? }, 1000);
}