feat: 新增签到功能模块并优化详情页样式
- 添加签到功能相关HTML/CSS/JS文件 - 在详情页增加图片预览组件 - 调整详情页文本行高和标题样式 - 修复评论时间显示问题 - 优化本地开发环境授权处理
This commit is contained in:
63
js/signIn.js
Normal file
63
js/signIn.js
Normal file
@@ -0,0 +1,63 @@
|
||||
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");
|
||||
Reference in New Issue
Block a user