增加首页自动弹出签到
This commit is contained in:
@@ -56,7 +56,7 @@
|
||||
const popup = ref(null);
|
||||
const current = ref(0);
|
||||
const opacity = ref(1);
|
||||
let CloseComplete
|
||||
let CloseComplete
|
||||
const badgesList = ref([]);
|
||||
const pointsList = ref([]);
|
||||
const multiple = computed(() => badgesList.value.length > 1);
|
||||
|
||||
@@ -82,6 +82,9 @@
|
||||
const customStyle = {
|
||||
borderRadius: '40rpx' //圆角
|
||||
};
|
||||
let checkInClickCallback;
|
||||
let checkInSuccessCallback;
|
||||
|
||||
const dateGroups = ref([]);
|
||||
const expand = ref(false); // 展开状态
|
||||
const isSigned = ref(false); // 今日签到状态
|
||||
@@ -103,37 +106,32 @@
|
||||
// 退出签到
|
||||
const close = () => {
|
||||
popup.value.close();
|
||||
typeof checkInClickCallback === 'function' && checkInClickCallback({
|
||||
status:false
|
||||
})
|
||||
};
|
||||
const checkInLoading = ref(false);
|
||||
// 签到
|
||||
const checkIn = () => {
|
||||
if (checkInLoading.value) return;
|
||||
checkInLoading.value = true;
|
||||
addPointsByCheckIn({ days: continuousDay.value })
|
||||
.then((res) => {
|
||||
console.log('签到结果', res);
|
||||
// 函数执行成功的回调
|
||||
checkInClickCallback({
|
||||
status:true,
|
||||
days: continuousDay.value,
|
||||
successCb: ({ days, res }) => {
|
||||
console.log('签到成功', res);
|
||||
checkInLoading.value = false;
|
||||
isSigned.value = true;
|
||||
continuousDay.value = continuousDay.value + 1;
|
||||
// common.msg('签到成功,请明日继续!')
|
||||
emits(
|
||||
'checkInFun',
|
||||
true,
|
||||
res.body.points,
|
||||
res.body.pointsBadges,
|
||||
// [{ changePoints: 5 }],
|
||||
// [
|
||||
// {
|
||||
// pointsBadgeImg: '/traoss/tras3/show/S3F0250181220722025110713501700000661177',
|
||||
// pointsBadgeName: '黄金徽章'
|
||||
// }
|
||||
// ]
|
||||
);
|
||||
})
|
||||
.catch((err) => {
|
||||
continuousDay.value = days;
|
||||
checkInSuccessCallback(true, days, res.body.points, res.body.pointsBadges);
|
||||
},
|
||||
failCb: (res) => {
|
||||
checkInLoading.value = false;
|
||||
console.log('签到失败', res);
|
||||
common.msg('签到失败,请稍后再试');
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -207,17 +205,19 @@
|
||||
|
||||
return groupedList;
|
||||
}
|
||||
|
||||
const open = (checkInToday, days) => {
|
||||
isSigned.value = checkInToday === 'Y' ? true : false; // 今日签到状态
|
||||
// isSigned.value = false; // 今日签到状态
|
||||
|
||||
const open = (isSignedStatus, days, onCheckInClick = () => {}, onCheckInSuccess = () => {}) => {
|
||||
console.log('isSignedStatus', isSignedStatus);
|
||||
isSigned.value = isSignedStatus; // 今日签到状态
|
||||
continuousDay.value = days; // 连续签到
|
||||
checkInClickCallback = onCheckInClick;
|
||||
checkInSuccessCallback = onCheckInSuccess;
|
||||
// 示例:X=10时,以"10天前"为第1天,生成35天列表
|
||||
try {
|
||||
const X = continuousDay.value - (isSigned.value ? 1 : 0);
|
||||
// const X = 10;
|
||||
console.log(`以${continuousDay.value}天`);
|
||||
console.log(`以${X}天前为第1天的35天分组日期:`);
|
||||
// console.log(`以${continuousDay.value}天`);
|
||||
// console.log(`以${X}天前为第1天的35天分组日期:`);
|
||||
dateGroups.value = generateGroupedDateList(X);
|
||||
} catch (err) {
|
||||
console.error(err.message);
|
||||
|
||||
Reference in New Issue
Block a user