解决2个bug

This commit is contained in:
田岩
2025-12-01 14:06:03 +08:00
parent 88f617819d
commit 7520cde133
4 changed files with 33 additions and 28 deletions
+21 -18
View File
@@ -89,17 +89,23 @@
const expand = ref(false); // 展开状态
const isSigned = ref(false); // 今日签到状态
const continuousDay = ref(0); // 连续签到
const continuousDay30 = computed(() => continuousDay.value % 30); // 连续签到取模30的天数
const continuousDay30 = computed(() => {
// 连续签到取30的天数
const mod = continuousDay.value % 30;
// 关键:取模为0时返回30(代表满30天),否则返回mod(1-29天)
return mod === 0 ? (continuousDay.value === 0 ? 0 : 30) : mod;
});
// 判断一下当前的签到显示在第几周
const nowLine = computed(() => {
// 计算当前需要显示图标的天数(已签到则是连续天数,未签到则是下一天)
const currentDay = isSigned.value ? continuousDay30.value : continuousDay30.value + 1;
// 按每周7天分行,行数从0开始(例如:1-7天 → 第0行,8-14天 → 第1行...
// 注意:如果天数从1开始(不是0),需要减1再计算
console.log('nowLine', Math.floor((currentDay - 1) / 7));
return Math.floor((currentDay - 1) / 7);
const line = Math.floor((currentDay - 1) / 7);
console.log('nowLine', Math.max(line, 0)); // 避免输出 -1
return Math.max(line, 0); // 核心修复:-1 会被转为 0
});
const emits = defineEmits(['checkInFun']);
// 切换显示状态
const switchStatus = () => {
@@ -108,9 +114,10 @@
// 退出签到
const close = () => {
popup.value.close();
typeof checkInClickCallback === 'function' && checkInClickCallback({
status:false
})
typeof checkInClickCallback === 'function' &&
checkInClickCallback({
status: false
});
};
const checkInLoading = ref(false);
// 签到
@@ -119,7 +126,7 @@
checkInLoading.value = true;
// 函数执行成功的回调
checkInClickCallback({
status:true,
status: true,
days: continuousDay.value,
successCb: ({ days, res }) => {
console.log('签到成功', res);
@@ -176,7 +183,7 @@
// 计算当前是第几天(以"前X天"为第1天)
const dayNumber = i - -X + 1; // 核心计算:转换为从1开始的序列
// 计算text字段
let text = '1'; // 默认显示1
if (dayNumber === 30) {
@@ -207,23 +214,20 @@
return groupedList;
}
const open = (isSignedStatus, days, onCheckInClick = () => {}, onCheckInSuccess = () => {}) => {
isSigned.value = isSignedStatus; // 今日签到状态
continuousDay.value = days; // 连续签到
// isSigned.value = false; // 今日签到状态
// continuousDay.value = 1; // 连续签到
// continuousDay.value = 30; // 连续签到
checkInClickCallback = onCheckInClick;
checkInSuccessCallback = onCheckInSuccess;
// 示例:X=10时,以"10天前"为第1天,生成35天列表
try {
const X = continuousDay30.value - (isSigned.value ? 1 : 0);
// const X = 10;
// console.log(`以${continuousDay.value}天`);
// console.log(`以${X}天前为第1天的35天分组日期:`);
// console.log('取', X);
const subtractNum = isSigned.value ? 1 : 0;
const X = Math.max(continuousDay30.value - subtractNum, 0);
console.log('取', X);
dateGroups.value = generateGroupedDateList(X);
} catch (err) {
console.error(err.message);
}
@@ -239,7 +243,6 @@
text-align: center;
// 隐藏展开时超过30天的样式
&.hide.expand {
.calendar-day-title {
width: 70rpx;
color: #fff;
+7 -5
View File
@@ -56,7 +56,7 @@
</view>
<view class="ranking-self">
<view class="list-header list-item">
<view class="rank-column">我的排名</view>
<view class="rank-column my_pai">我的排名</view>
</view>
<view class="list-item item-me">
<view class="rank-column">
@@ -227,7 +227,6 @@
overflow: hidden;
display: flex;
&.list-header {
height: 54rpx;
line-height: 54rpx;
@@ -315,7 +314,7 @@
}
.rank-column {
width: 130rpx;
width: 140rpx;
padding-left: 40rpx;
float: left;
font-weight: 600;
@@ -326,10 +325,13 @@
font-style: italic;
text-indent: 8rpx;
}
.my_pai{
padding-top: 10rpx;
padding-left: 26rpx;
}
.user-column {
// background-color: red;
// width: 330rpx;
max-width: 370rpx;
flex: 1;
float: left;
padding: 15rpx 0;
+4 -4
View File
@@ -179,6 +179,10 @@
setTimeout(() => {
queryCompetitionAnswerResult({ execId: pkData.execId, autoSub:autoSub.value }).then(({ body }) => {
if (mode.value === 'pk_in') {
console.log('调用它');
pointAndBadgesRun('11');
}
// 计算需要额外延时的时间
const currentTime = Math.floor(Date.now() / 1000);
// 2. 计算对手的答题结束时间(秒)
@@ -211,10 +215,6 @@
nextTick(() => {
action.value = 'result';
});
if (mode.value === 'pk_in') {
console.log('调用它');
pointAndBadgesRun('11');
}
}, delayTime * 1000);
});
}, mode.value === 'pk_result'?0:1000);