let urlPrefix = getUrlPrefix() let browser = checkVersion() let queryObj = getQueryString() if (EnvCheck() === 'test') new VConsole // 页面全屏 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: '加載中...', success(e) { layerIndex = $(e).attr('index') } }) } const hideLoading = (index) => { layer.close(index) } const toastMsg = (content = '操作完成', 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 + '/room/permitRoom/hourRank', 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('網絡錯誤') } }) } // 渲染小时榜上一小时前三 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) => { if(item.score > 10000) { item.score = ( Math.floor(item.score/1000) ) / 10 + 'W' } str += `
${score}
` ) } `) } $(function () { getInfoFromClient() setTimeout(() => { getHourList() }, 50) $('.rule_icon').click(() => { window.location.href = './ruleLicense.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); // } // } // }) // } // 跳转房间函数 function openRoomFun(document, dom){ $(document).on('click', dom, function () { let erbanUid = $(this).data('uid') // if (!browser.app) return if (browser.ios) { window.webkit.messageHandlers.openRoom.postMessage(erbanUid); } else if (browser.android) { if (androidJsObj && typeof androidJsObj === 'object') { window.androidJsObj.openRoom(erbanUid); } } }) } openRoomFun('.top_three_wrap', '.avatar') openRoomFun('ul', '.others_avatar') openRoomFun('.mine', '.mine_avatar') // openPerson('.top_three_wrap', '.avatar') // openPerson('ul', '.others_avatar') // openPerson('.mine', '.mine_avatar') })