Files
PC-Light-Forum/js/signIn.js
DESKTOP-RQ919RC\Pc f73a662141 feat: 新增签到功能模块并优化详情页样式
- 添加签到功能相关HTML/CSS/JS文件
- 在详情页增加图片预览组件
- 调整详情页文本行高和标题样式
- 修复评论时间显示问题
- 优化本地开发环境授权处理
2025-11-21 19:07:03 +08:00

64 lines
2.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const { createApp, ref, onMounted, nextTick, onUnmounted, computed, watch, provide } = Vue;
const appSectionIndex = createApp({
setup() {
onMounted(() => {
console.log("signIn");
getFirstDay();
});
let dayOfWeek = ref(0); // 当月第一天是星期几
let totalDaysInMonth = ref(0); // 当月第一共今天
let currentDay = ref(0); // 今天几号
let showList = ref([]); // 展示的 签到列表
const getFirstDay = () => {
const firstDayOfMonth = new Date();
firstDayOfMonth.setDate(1);
// 获取当月第一天是星期几0 表示星期日1 表示星期一,依此类推)
dayOfWeek.value = firstDayOfMonth.getDay();
const currentDate = new Date();
const currentMonth = currentDate.getMonth() + 1;
const currentYear = currentDate.getFullYear();
currentDay.value = currentDate.getDate();
// 获取当前月份的总天数
totalDaysInMonth.value = new Date(currentYear, currentMonth, 0).getDate();
init();
};
// 初始化
const init = () => {
ajaxGet("https://api.gter.net/v2/api/forum/getSignInfo").then((res) => {
if (res.code != 200) return;
console.log("res", res);
const data = res.data;
const list = data.list || {};
this.getDateList(list);
const issign = data.issign || 0;
if (issign == 1) wx.setStorageSync("signInState", util.getCurrentDate()); // 存储签到时间
this.setData({
tips: data.tips || [],
integral: Number(data.integral) || 0,
token: data.token || "",
signnum: data.signnum || 0,
signreward: data.signreward || 0,
issign,
});
console.log("integral", this.data.integral);
});
};
return { dayOfWeek };
},
});
appSectionIndex.mount("#signInBox");