let urlPrefix = getUrlPrefix() let browser = checkVersion() let queryObj = getQueryString() if (EnvCheck() === 'test') new VConsole var langReplace; var localLang; // 页面全屏 if(browser.app) { if (browser.android) { window.androidJsObj.initShowNav(false) } else { window.webkit.messageHandlers.initShowNav.postMessage(0) } } // 封装layer消息提醒框 let layerIndex const showLoading = () => { layer.open({ type: 2, shadeClose: false, content: langReplace(localLang.demoModule.hour_text5), success(e) { layerIndex = $(e).attr('index') } }) } const hideLoading = (index) => { layer.close(index) } const toastMsg = (content = langReplace(localLang.demoModule.hour_text6), time = 2) => { layer.open({ content, time, skin: 'msg' }) } let currHourRank = [] let lastHourRank = [] let currRoomInfo = {} let timestamp let page = 1 let pageSize = 10 let rankList = [] let canNext = true let isLock = true // 获取小时榜数据 const getHourList = () => { networkRequest({ type: 'GET', url: urlPrefix + '/single/broadcast/listHourRank', data: { roomUid: queryObj.roomUid }, success(res) { if (res.code === 200) { currHourRank = res.data.currHourRank lastHourRank = res.data.lastHourRank currRoomInfo = res.data.currRoomInfo timestamp = res.timestamp countDown() renderLastHourThree() renderCurrentList() renderCurrentRoomInfo() } else { toastMsg(res.message) } }, error(err) { toastMsg(langReplace(localLang.demoModule.hour_text7)) } }) } // 渲染小时榜上一小时前三 const renderLastHourThree = () => { lastHourRank = lastHourRank.slice(0, 3) if(lastHourRank.length < 3) { let len = 3 - lastHourRank.length let arr = new Array(len).fill({ nick: '', score: '' }) lastHourRank.push(...arr) } let str = '' lastHourRank.map((item, index) => { str += `
${score}
` ) } `) } $(function () { getInfoFromClient() fuzzyMatchUpdateQueryStringParameterFun(); // 判断语言 setTimeout(() => { langReplace = window.lang.replace; localLang = window.lang; translateFun(); getHourList() setTimeout(function () { $('#body').show(); }, 300) }, 50) function translateFun() { var langReplace = window.lang.replace; var localLang = window.lang; $('#hour_title').html(langReplace(localLang.demoModule.hour_title)); $('.hour_title').html(langReplace(localLang.demoModule.hour_title)); $('#hore_text1').html(langReplace(localLang.demoModule.hore_text1)); $('#hour_text33').html(langReplace(localLang.demoModule.hour_text33)); $('#hour_text2').html(langReplace(localLang.demoModule.hour_text2)); $('#hour_text4').html(langReplace(localLang.demoModule.hour_text4)); } $('.rule_icon').click(() => { window.location.href = './rule.html' }) //跳转个人主页 function openPerson(document, dom) { $(document).on('click', dom, function () { let erbanUid = $(this).data('uid') if (!browser.app) return if (browser.ios) { window.webkit.messageHandlers.openPersonPage.postMessage(erbanUid); } else if (browser.android) { if (androidJsObj && typeof androidJsObj === 'object') { window.androidJsObj.openPersonPage(erbanUid); } } }) } openPerson('.top_three_wrap', '.avatar') openPerson('ul', '.others_avatar') openPerson('.mine', '.mine_avatar') })