let urlPrefix = getUrlPrefix() let browser = checkVersion() let env = EnvCheck(); if (env == 'test') { new VConsole(); } // 封裝layer消息提醒框 let layerIndex const showLoading = (content = '加載中...') => { layer.open({ type: 2, shadeClose: false, content, success (e) { layerIndex = $(e).attr('index') } }) } const hideLoading = (index) => { layer.close(index) } const toastMsg = (content = '操作完成', time = 2) => { layer.open({ content, time, skin: 'msg' }) } var roomUid = 77620; var round = null;//輪次 var countupTime = null;//倒計時 var endTime = null; // 初始化函數 $(function () { getInfoFromClient() setTimeout(function () { // 頁面全屏 if (browser.app) { if (browser.android) { window.androidJsObj.initShowNav(false) } else { window.webkit.messageHandlers.initShowNav.postMessage(0) } }; // 頂部返回事件 $('.back').click(() => { if (browser.android) { window.androidJsObj.closeWebView() } else { window.webkit.messageHandlers.closeWebView.postMessage(null) } }) var mySwiper = new Swiper('.swiper', { // direction: "vertical", loop: true, // autoplay: { // delay: 3500, // disableOnInteraction: false // }, // 如果需要分頁器 pagination: { el: '.swiper-pagination', }, }) getRank(); }, 100) }) // tab切換 $('.tabBox div').click(function () { var i = $(this).index() + 1; $('.tabBox div').removeClass('tabAct1').removeClass('tabAct2').removeClass('tabAct3').removeClass('tabAct4'); $(`.tabBox .tab${i}`).addClass(`tabAct${i}`); $('.page1,.page2,.page3,.page4').hide(); $(`.page${i}`).show(); if (i == 1) { round = i; getRank(); } }) // 前三跳轉 $('.page1 .top div').on('click', '.tx', function () { var uid = $(this).attr('uid'); // 跳轉個人資料頁 if (browser.ios) { window.webkit.messageHandlers.openPersonPage.postMessage(uid); } else if (browser.android) { if (androidJsObj && typeof androidJsObj === 'object') { window.androidJsObj.openPersonPage(uid); } } else { console.log('web'); } }) // 非前三跳轉 $('.page1 ul').on('click', 'li .tx', function () { var uid = $(this).attr('uid'); // 跳轉個人資料頁 if (browser.ios) { window.webkit.messageHandlers.openPersonPage.postMessage(uid); } else if (browser.android) { if (androidJsObj && typeof androidJsObj === 'object') { window.androidJsObj.openPersonPage(uid); } } else { console.log('web'); } }) // 獲取任務接口 function getRank () { $('ul li').remove(); showLoading() networkRequest({ type: 'GET', url: urlPrefix + '/act/2024Snooker/room/getRank', data: { round }, success (res) { if (res.code === 200) { // 當前頁面展示 $('.tabBox div').removeClass('tabAct1').removeClass('tabAct2').removeClass('tabAct3'); $(`.tabBox .tab${res.data.rankType}`).addClass(`tabAct${res.data.rankType}`); $('.page1,.page2,.page3').hide(); $(`.page${res.data.rankType}`).show(); // 處理倒計時 if (res.data.rankType == 1) { if (round == null) { endTime = res.data.roundList[0].endTime } if (endTime - res.timestamp > 0) { countup(endTime - res.timestamp); } else { $('.time').hide(); } var top3 = res.data.rankList.slice(0, 3); var notTop3 = res.data.rankList.slice(3); // 處理前三 if (top3.length < 3) { let arr = new Array(3 - top3.length).fill({ avatar: './images/logo.png', nick: '虛位以待', erbanNo: "虛位以待", score: "0" }) top3.push(...arr) } top3.forEach((res, i) => { $(`.top .no${i + 1} .tx`).attr('src', res.avatar); $(`.top .no${i + 1} .tx`).attr('uid', res.uid); $(`.top .no${i + 1} p`).text(res.nick); $(`.top .no${i + 1} span`).text(`ID:${res.erbanNo}`); $(`.top .no${i + 1} .score b`).text(res.score); }); // 處理非前三 var str = ''; notTop3.forEach((res, i) => { str += `
${res.nick}
ID:${res.erbanNo}