小游戏:计算差值;历史隐藏等级
This commit is contained in:
@@ -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 += `
|
||||
<li>
|
||||
<div class="num">${res.ranking}</div>
|
||||
@@ -206,7 +224,7 @@ function loadMore() {
|
||||
<span>ID:${res.erbanNo}</span>
|
||||
</div>
|
||||
<div class="score">
|
||||
<b>${langReplace(localLang.demoModule.Behind) + unitProcessingAr(res.score, 2)}</b>
|
||||
<b>${langReplace(localLang.demoModule.Behind) + unitProcessingAr(diff, 2)}</b>
|
||||
<img src="./images/m.png" alt="">
|
||||
</div>
|
||||
</li>
|
||||
@@ -258,11 +276,10 @@ function getHisRank() {
|
||||
<li>
|
||||
<img src="${user.avatar}" alt="" class="avatar">
|
||||
<img src="./images/h${user.rank > 3 ? "" : user.rank}.png" alt="" class="tx">
|
||||
<img src="./images/vip/${user.vipLevel}.png" alt="" class="icon" style="display: ${user.vipLevel == 0 ? 'none' : 'block'}">
|
||||
<p class="name">${user.nick}</p>
|
||||
<P class="id">ID: ${user.erbanNo}</P>
|
||||
<div class="score">
|
||||
<b>Win ${user.jackpot}K</b>
|
||||
<b>${langReplace(localLang.demoModule.win)} ${unitProcessingAr(user.jackpot,2)}</b>
|
||||
<img src="./images/m.png" alt="">
|
||||
</div>
|
||||
</li>
|
||||
@@ -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) {
|
||||
|
Reference in New Issue
Block a user