From a9156cc000ace2c4c945e0c4dd7989c764d476cf Mon Sep 17 00:00:00 2001 From: qiaofie Date: Fri, 7 Mar 2025 14:49:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E6=B8=B8=E6=88=8F=EF=BC=9A=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E5=B7=AE=E5=80=BC=EF=BC=9B=E5=8E=86=E5=8F=B2=E9=9A=90?= =?UTF-8?q?=E8=97=8F=E7=AD=89=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../activity/gameChallenge/js/index.js | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/view/molistar/activity/gameChallenge/js/index.js b/view/molistar/activity/gameChallenge/js/index.js index a5838284..83426252 100644 --- a/view/molistar/activity/gameChallenge/js/index.js +++ b/view/molistar/activity/gameChallenge/js/index.js @@ -31,6 +31,7 @@ const toastMsg = (content = langReplace(localLang.demoModule.layerIndex2), time var countupTime;//倒计时容器 var loadedCount = 0; // 已加載的數據數量 var pageSize = 7; // 每次加載的數據數量 +var listTo3 = []; var notListTo3 = []; // 每次加載的數據數量 // 初始化函數 $(function () { @@ -121,7 +122,7 @@ function getInit() { $('.coins_pop .btn').html(langReplace(localLang.demoModule.done)); $('.coins_pop .btn').addClass('done'); } - if(jackpotNum !== 0) { + if (jackpotNum !== 0) { $('.header .coin_bg').show() $('.header .receive').show() } @@ -134,8 +135,9 @@ function getInit() { }; }); // 处理榜单 - var listTo3 = res.data.rankList.slice(0, 3); - notListTo3 = res.data.rankList.slice(3); + let rankList = res.data.rankList; + listTo3 = rankList.slice(0, 3); + notListTo3 = rankList.slice(3); // 处理前三 if (listTo3.length < 3) { let arr = new Array(3 - listTo3.length).fill({ @@ -146,12 +148,16 @@ function getInit() { }) listTo3.push(...arr) } + let prevScore = null; // 记录上一名的score listTo3.forEach((res, i) => { $(`.page1 .top .top${i + 1} .tx`).attr('src', res.avatar); $(`.page1 .top .top${i + 1} .name`).html(res.name); $(`.page1 .top .top${i + 1} .icon`).attr('src', res.vipLevel ? `./images/vip/${res.vipLevel}.png` : ''); $(`.page1 .top .top${i + 1} .id`).html('ID:' + res.erbanNo); - $(`.page1 .top .top${i + 1} .score b`).html(langReplace(localLang.demoModule.Behind) + unitProcessingAr(res.score, 2)); + // 计算当前与上一名的差值 + let diff = prevScore !== null ? prevScore - res.score : 0; // 计算差值 + prevScore = res.score; // 更新上一名的分数 + $(`.page1 .top .top${i + 1} .score b`).html(langReplace(localLang.demoModule.Behind) + unitProcessingAr((diff), 2)); if (res.erbanNo == null) { $(`.page1 .top .top${i + 1} .icon`).hide(); $(`.page1 .top .top${i + 1} .id`).hide(); @@ -170,7 +176,16 @@ function getInit() { $('.page1 .my .info p').text(my.nick); $('.page1 .my .icon').attr('src', `./images/vip/${my.vipLevel}.png`); $('.page1 .my .info span').text(`ID:${my.erbanNo}`); - $('.page1 .my .score b').text(langReplace(localLang.demoModule.Behind) + unitProcessingAr(my.score, 2)); + if (my.ranking == 0) { + let lastScore = rankList[rankList.length - 1].score; + $('.page1 .my .score b').text(langReplace(localLang.demoModule.Behind) + unitProcessingAr(lastScore - my.score, 2)); + } else if(my.ranking == 1){ + $('.page1 .my .score').hide(); + }else { + let lastScore = rankList[my.ranking - 2].score; + console.log('lastScore', lastScore); + $('.page1 .my .score b').text(langReplace(localLang.demoModule.Behind) + unitProcessingAr((lastScore - my.score), 2)); + } if (my.vipLevel == 0) { $('.page1 .my .icon').hide(); } @@ -193,9 +208,12 @@ function loadMore() { pageSize = loadedCount == 0 ? 7 : 10; const nextItems = notListTo3.slice(loadedCount, loadedCount + pageSize); let str = ''; - // 拼接 HTML + let prevScore = loadedCount == 0 ? listTo3[2].score : notListTo3[loadedCount - 1].score; nextItems.forEach((res, i) => { + // 计算当前与上一名的差值 + let diff = prevScore - res.score; + prevScore = res.score; str += `
  • ${res.ranking}
    @@ -206,7 +224,7 @@ function loadMore() { ID:${res.erbanNo}
    - ${langReplace(localLang.demoModule.Behind) + unitProcessingAr(res.score, 2)} + ${langReplace(localLang.demoModule.Behind) + unitProcessingAr(diff, 2)}
  • @@ -258,11 +276,10 @@ function getHisRank() {
  • -

    ${user.nick}

    ID: ${user.erbanNo}

    - Win ${user.jackpot}K + ${langReplace(localLang.demoModule.win)} ${unitProcessingAr(user.jackpot,2)}
  • @@ -403,7 +420,7 @@ $(".coins_pop .close").click(function () { $(".header .receive").click(function () { bodyScroolFun(false); $('.coins_pop').show(); - + }) $(".coins_pop .btn").click(function () { if (jackpotNum != 0) {