完成接口对接,暂存

This commit is contained in:
dragon
2024-10-14 11:20:16 +08:00
parent 31a83a7ece
commit dc40dbcf55
2 changed files with 97 additions and 7 deletions

View File

@@ -37,22 +37,22 @@
<div class="myBox">
<img src="./images/txk.png" alt="" class="ts">
<img src="" alt="" class="tx">
<div class="name">迪迦</div>
<div class="name"></div>
<div class="lineBox">
<div class="line"></div>
<div class="box1 boxs">
<span>0K <img src="./images/gold.png" alt=""></span>
<span><b>0K</b> <img src="./images/gold.png" alt=""></span>
</div>
<div class="box2 boxs">
<span>0K <img src="./images/gold.png" alt=""></span>
<span><b>0K</b> <img src="./images/gold.png" alt=""></span>
</div>
<div class="box3 boxs">
<span>0K <img src="./images/gold.png" alt=""></span>
<span><b>0K</b> <img src="./images/gold.png" alt=""></span>
</div>
</div>
<div class="tetxBox">
<div class="l text6"></div>
<div class="r">0/70000</div>
<div class="r"><b>0</b>/<strong></strong></div>
</div>
</div>
<!-- tab -->

View File

@@ -57,6 +57,7 @@ $(function () {
langReplace = window.lang.replace;
localLang = window.lang;
translateFun();
getConfig();
}, 100)
})
// 处理SVGA
@@ -115,15 +116,66 @@ function translateFun() {
$('.null').text(langReplace(localLang.demoModule.text16));
}
}
console.log(unitProcessingAr(210000, 1));
// 配置接口
function getConfig() {
showLoading()
networkRequest({
type: 'get',
url: urlPrefix + '',
url: urlPrefix + '/activity/h5/dayConsume',
success(res) {
if (res.code === 200) {
// 分区规则
$('.rule .rule_in .box').html(res.data.partitionId == 2 ? langReplace(localLang.demoModule.arRule) : langReplace(localLang.demoModule.enRule));
// 处理倒计时
countup(res.data.endTime - res.timestamp);
// 处理顶部进度以及个人信息
$('.myBox .tx').attr('src', res.data.avatar);
$('.myBox .name').text(res.data.nick);
$('.myBox .tetxBox .r b').text(res.data.goldNum);
if (res.data.goldNum < 700000) {
$('.myBox .tetxBox .r strong').text(700000);
$('.myBox .lineBox .box1 span b').text('70K');
$('.myBox .lineBox .box1 span b').css('width', `${(70000 / 700000) * 100}%`);
$('.myBox .lineBox .box2 span b').text('350K');
$('.myBox .lineBox .box2 span b').css('width', `${(350000 / 700000) * 100}%`);
$('.myBox .lineBox .box3 span b').text('700K');
$('.myBox .lineBox .box3 span b').css('width', `${(700000 / 700000) * 100}%`);
$('.myBox .lineBox .line').css('width', `${(res.data.goldNum / 700000) * 100}%`);
res.data.goldNum >= 70000 ? $('.myBox .lineBox .box1').addClass('act') : res.data.goldNum >= 350000 ? $('.myBox .lineBox .box2').addClass('act') : res.data.goldNum >= 700000 ? $('.myBox .lineBox .box3').addClass('act') : ''
} else {
$('.myBox .tetxBox .r strong').text(7000000);
$('.myBox .lineBox .box1 span b').text('70K');
$('.myBox .lineBox .box1 span b').css('width', `${(70000 / 7000000) * 100}%`);
$('.myBox .lineBox .box2 span b').text('350K');
$('.myBox .lineBox .box2 span b').css('width', `${(3500000 / 7000000) * 100}%`);
$('.myBox .lineBox .box3 span b').text('700K');
$('.myBox .lineBox .box3 span b').css('width', `${(210000 / 7000000) * 100}%`);
$('.myBox .lineBox .line').css('width', `${(res.data.goldNum / 7000000) * 100}%`);
res.data.goldNum >= 210000 ? $('.myBox .lineBox .box1').addClass('act') : res.data.goldNum >= 3500000 ? $('.myBox .lineBox .box2').addClass('act') : res.data.goldNum >= 7000000 ? $('.myBox .lineBox .box3').addClass('act') : ''
}
// 处理每个档位的用户前四名
res.data.activityLevelUserVo.forEach((res, i) => {
var str = '';
if ((i + 1) <= 3) {
$(`.content1 .contentBox${i + 1} .priorityWinnersBox div`).remove();
} else {
$(`.content2 .contentBox${i + 1} .priorityWinnersBox div`).remove();
}
res.userVos.forEach(val => {
str += `
<div>
<img src="${val.avatar}" alt="">
<span>${val.name}</span>
</div>
`
})
if ((i + 1) <= 3) {
$(`.content1 .contentBox${i + 1} .priorityWinnersBox`).append(str);
} else {
$(`.content2 .contentBox${i + 1} .priorityWinnersBox`).append(str);
}
})
} else {
toastMsg(res.message)
}
@@ -135,6 +187,44 @@ function getConfig() {
}
})
}
// 倒計時
function countup(leftTime) {
clearTimeout(countupTime)
//獲取當前時間
// var now = nowTime;
var d = 0;
var h = 0;
var m = 0;
var s = 0;
//定義變數 d,h,m,s保存倒計時的時間
var d, h, m, s;
//遞歸每秒調⽤countTime⽅法顯⽰動態時間效果
if (leftTime > 0) {
d = getzf(Math.floor(leftTime / 1000 / 60 / 60 / 24));
h = getzf(Math.floor(leftTime / 1000 / 60 / 60 % 24));
m = getzf(Math.floor(leftTime / 1000 / 60 % 60));
s = getzf(Math.floor(leftTime / 1000 % 60));
//將倒計時賦值到div中
$('.header .time .hour b').text(h);
$('.header .time .min b').text(m);
$('.header .time .sec b').text(s);
} else {
getConfig();
}
if (leftTime > 0) {
leftTime = leftTime - 1000;
}
countupTime = setTimeout(function () {
countup(leftTime);
}, 1000);
}
//补0操作
function getzf(num) {
if (parseInt(num) < 10) {
num = '0' + num;
}
return num;
}
// tab切换
$('.tab div').click(function () {
var i = $(this).index() + 1;