每日消费 - 修改宝箱进度条,底部轮播图还差奖励图

This commit is contained in:
2025-07-16 10:01:53 +08:00
parent 43eac638c7
commit af35aaf5b7

View File

@@ -188,7 +188,9 @@ function getConfig() {
gearPosition.forEach((item, index) => {
$(`.myBox .lineBox .box${index + 1} span b`).text(unitProcessingAr(item.usb, 1));
// 均匀分配每个档位的进度条宽度
$(`.myBox .lineBox .box${index + 1}`).css('left', `${((index + 1) / (gearPosition.length + 0.5)) * 100}%`);
const totalLevels = gearPosition.length;
const levelWidth = 100 / totalLevels; // 每个档位的宽度百分比
$(`.myBox .lineBox .box${index + 1}`).css('left', `${levelWidth * (index+1) -10}%`);
// 到达档位 - 宝箱高亮
if (res.data.goldNum >= item.usb) {
@@ -260,17 +262,17 @@ function getConfig() {
} else if (currentLevelIndex === 0) {
// 特殊处理第一个档位
let firstLevelValue = gearPosition[0].usb;
let progressWidth = (res.data.goldNum / firstLevelValue) * (100 / gearPosition.length + 0.2);
let progressWidth = (res.data.goldNum / firstLevelValue) * (50 / gearPosition.length );
$('.myBox .lineBox .line').css('width', `${progressWidth}%`);
} else {
let nextLevelValue = gearPosition[currentLevelIndex].usb;
let totalLevels = gearPosition.length + 0.2;
let totalLevels = gearPosition.length;
let prevLevelValue = gearPosition[currentLevelIndex - 1].usb;
// 防止除以零的情况
let levelRange = nextLevelValue - prevLevelValue;
let progress = levelRange === 0 ? 0 : (res.data.goldNum - prevLevelValue) / levelRange;
let progressWidth = (currentLevelIndex / totalLevels) * 100 + progress * (100 / totalLevels);
let progressWidth = (currentLevelIndex / totalLevels) * 100 + progress * (50 / totalLevels);
$('.myBox .lineBox .line').css('width', `${progressWidth}%`);
}