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' }) } $(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) } }) getListUpgrade(); getListRank(); }, 100) }) // 获取榜单接口 function getListRank () { showLoading() networkRequest({ type: 'GET', url: urlPrefix + '/vip/listRank', success (res) { if (res.code === 200) { $('.listBox ul li').remove(); $('.myList ul li').remove(); // 前三 var top3 = res.data.ranks.slice(0, 3); var notTop3 = res.data.ranks.slice(3); if (top3.length < 3) { let arr = new Array(3 - top3.length).fill({ avatar: './images/logo.png', vipIcon: '', nick: '虚位以待', score: "", }) top3.push(...arr) } top3.forEach((res, i) => { $(`.header .no${i + 1} .tx`).attr('src', res.avatar); if (res.nick == '虚位以待') { $(`.header .no${i + 1} .icon`).hide(); $(`.header .no${i + 1} p`).hide(); } $(`.header .no${i + 1} .icon`).attr('src', res.vipIcon); $(`.header .no${i + 1} span`).text(res.nick.length > 5 ? res.nick.slice(0, 5) + '...' : res.nick); $(`.header .no${i + 1} b`).text(res.score > 10000 ? (Math.floor(res.score / 1000) / 10).toFixed(1) + 'w' : res.score); }); // 非前三 var str = ''; notTop3.forEach((res, i) => { str += `
  • ${i + 4}
    ${res.nick.length > 5 ? res.nick.slice(0, 5) + '...' : res.nick}

    ${res.score > 10000 ? (Math.floor(res.score / 1000) / 10).toFixed(1) + 'w' : res.score}

    权力值
  • ` }); $('.list').append(str); var res = res.data.myRank; console.log(res); //自己 $('.myInfo .div .tx').attr('src', res.avatar); $('.myInfo .div .name').text(res.nick.length > 5 ? res.nick.slice(0, 5) + '...' : res.nick); if (res.rankNo) { $('.myInfo .div .num').text(res.rankNo) } else { $('.myInfo .div .num').text('未上榜') } if (res.vipLevel) { $('.myInfo .div .tx').attr('src', res.icon); $('.myInfo .div .right p').text(res.score > 10000 ? (Math.floor(res.score / 1000) / 10).toFixed(1) + 'w' : res.score); } else { $('.myInfo .div .icon').hide(); $('.myInfo .div .right').hide(); $('.myInfo .div .acitve').show(); } } else { toastMsg(res.message) } hideLoading(layerIndex) }, error (err) { hideLoading(layerIndex) toastMsg('網絡錯誤,請退出重進') } }) } // 获取公告轮播接口 function getListUpgrade () { showLoading() networkRequest({ type: 'GET', url: urlPrefix + '/vip/listUpgrade', success (res) { if (res.code === 200) { var str = ''; res.data.forEach((res, i) => { str += `
  • 恭喜贵族${res.nick.length > 5 ? res.nick.slice(0, 5) + '...' : res.nick} 升级为${res.vipName}
  • ` }); $('.header .notice ul').append(str); notice(); } else { toastMsg(res.message) } hideLoading(layerIndex) }, error (err) { hideLoading(layerIndex) toastMsg('網絡錯誤,請退出重進') } }) } // 公告轮播 function notice () { var num = $(".notice_ul").find("li").length; if (num > 1) { setInterval(function () { $('.notice_ul').animate({ marginTop: "-0.96rem" }, 1000, function () { $(this).css({ marginTop: "0" }).find("li:first").appendTo(this); }); }, 5000); } } // 关闭当前页面 $('.myInfo .div .acitve').click(function () { if (browser.android) { window.androidJsObj.closeWebView() } else { window.webkit.messageHandlers.closeWebView.postMessage(null) } })