let urlPrefix = getUrlPrefix() let browser = checkVersion() var rankDataType = 1; var rankType = 1; // 封装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' }) } $(function () { getInfoFromClient() // debug if (EnvCheck() == 'test') { new VConsole(); } setTimeout(function () { getData(rankDataType, rankType); }, 50) }) function getData (rankDataType, rankType) { showLoading(); $('.listBox ul li').remove(); networkRequest({ type: 'GET', url: urlPrefix + '/luckybag/rank/listRank', data: { rankDataType, rankType },//rankDataType(1:日榜 3:总榜);rankType(1:神豪榜 2:魅力榜) success (res) { console.log(res.code == 200); if (res.code == 200) { var str = ''; var listTo3 = res.data.slice(0, 3); var notListTo3 = res.data.slice(3); console.log(listTo3); if (listTo3.length < 3) { let arr = new Array(3 - listTo3.length).fill({ avatar: './images/null.png', nick: '', score: "" }) listTo3.push(...arr) } // 处理前三 listTo3.forEach((res, index) => { if(res.score > 10000) { res.score = ( ( Math.floor(res.score/1000) ) / 10 ).toFixed(1) + 'W' } $(`.listBox .ranking${index + 1} .imagesBox img`).attr("src", res.avatar); $(`.listBox .ranking${index + 1} .nick`).text(res.nick); $(`.listBox .ranking${index + 1} .integral`).text(res.score+'积分'); }); notListTo3.forEach((res, index) => { if(res.score > 10000) { res.score = ( ( Math.floor(res.score/1000) ) / 10 ).toFixed(1) + 'W' } str += `