1.签到优化

master
sws 2023-09-11 10:27:21 +08:00
parent ec07d1c3fe
commit 025c3bc49c
1 changed files with 11 additions and 18 deletions

View File

@ -58,8 +58,9 @@
</block>
</block>
<block v-else>
<block v-if="col.is_signin">
<iconfont name="icon-qiandao-yixuan" size="48rpx"></iconfont>
<!-- 判断bool是否存在数组signinHistory中 true则表示存在于数组中 -->
<block v-if="user_signin_data.history_day.some(item => Number(item) === col.num)">
<iconfont name="icon-qiandao-yixuan" size="48rpx" color="#ccc"></iconfont>
</block>
<block v-else>
{{col.num}}
@ -180,6 +181,7 @@
});
//
this.get_data();
//
this.get_calendar();
},
@ -196,33 +198,26 @@
const days = [];
let day = [];
//
const first_day_week = new Date().getDay();
let firstday = new Date();
firstday.setDate(1); //
const first_day_week = firstday.getDay();
var defore_days = new Date(this.year, this.month, 0).getDate(); //
for (var i = first_day_week - 1; i > 0; i--) {
for (var i = first_day_week - 1; i >= 0; i--) {
//
day.push({
num: defore_days - i,
class: 'cr-grey-c',
today: false,
is_signin: false
today: false
});
}
console.log(first_day_week);
console.log(day);
//
for (let i = 1; i <= last_day; i++) {
// boolsigninHistory true
var bool = false;
if (this.user_signin_data) {
bool = this.user_signin_data.history_day.some(item => Number(item) === i);
}
//
var today = new Date().getDate();
day.push({
num: i,
class: 'cr-black',
today: i === today ? true : false,
is_signin: bool ? true : false
today: i === today ? true : false
});
if (day.length === 7) {
days.push(day);
@ -235,13 +230,11 @@
day.push({
num: i,
class: 'cr-grey-c',
today: false,
is_signin: false
today: false
});
}
days.push(day);
}
console.log(days);
this.setData({
day_count: days,
});