bug fix: 如果未登录, 只显示日期
This commit is contained in:
parent
5291890134
commit
53d3fa2f17
@ -5,10 +5,10 @@
|
||||
<div class="calen-list">
|
||||
<li v-for="(item,index) in current" :key="index">
|
||||
<div class="weiqiandao" v-if="item.type == -1">
|
||||
<img src="./../../assets/home/Icon_xross.png" alt="">
|
||||
<img src="@/assets/home/Icon_xross.png" alt="">
|
||||
</div>
|
||||
<div class="qiandao" v-if="item.type == 1">
|
||||
<img src="./../../assets/home/Checkmark.png" alt="">
|
||||
<img src="@/assets/home/Checkmark.png" alt="">
|
||||
</div>
|
||||
<div class="weidaoshijian" v-if="item.type == 0">{{ index+1 }}</div>
|
||||
</li>
|
||||
@ -17,7 +17,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getToken } from './../../utils/cookies.js'
|
||||
import { getToken } from '@/utils/cookies.js'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
@ -65,17 +65,31 @@ export default {
|
||||
|
||||
// 获取签到列表
|
||||
async getCheckInit(){
|
||||
let dayTime = Math.round(new Date())
|
||||
// let dayTime = Math.round(new Date())
|
||||
let token = getToken()
|
||||
let res = await this.$axios.get(`/api/user/checkin/list/1month`, {
|
||||
params: "",
|
||||
headers: { Authorization: `Bearer ${token}` }
|
||||
})
|
||||
let datas = []
|
||||
// 如果没登录, 就只显示日期
|
||||
if (!token) {
|
||||
this.current.forEach(item => {
|
||||
item.type = 0
|
||||
})
|
||||
return
|
||||
}
|
||||
try {
|
||||
let res = await this.$axios.get(`/api/user/checkin/list/1month`, {
|
||||
params: "",
|
||||
headers: { Authorization: `Bearer ${token}` }
|
||||
})
|
||||
datas = res.data?.data ? res.data.data : []
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
|
||||
for(let i = 0; i < this.current.length; i++) {
|
||||
for(let j = 0; j < res.data.data.length; j++) {
|
||||
if(this.current[i].time > res.data.data[0].day) {
|
||||
for(let j = 0; j < datas.length; j++) {
|
||||
if(this.current[i].time > datas[0].day) {
|
||||
this.current[i].type = 0
|
||||
} else if (this.current[i].time == res.data.data[j].day) {
|
||||
} else if (this.current[i].time == datas[j].day) {
|
||||
this.current[i].type = 1
|
||||
}
|
||||
}
|
||||
@ -152,15 +166,15 @@ export default {
|
||||
}
|
||||
}
|
||||
.weiqiandao {
|
||||
background: url('./../../assets/home/Missed.png') no-repeat;
|
||||
background: url('@/assets/home/Missed.png') no-repeat;
|
||||
background-size: 100% 100%;
|
||||
}
|
||||
.qiandao {
|
||||
background: url('./../../assets/home/Done.png') no-repeat;
|
||||
background: url('@/assets/home/Done.png') no-repeat;
|
||||
background-size: 100% 100%;
|
||||
}
|
||||
.weidaoshijian {
|
||||
background: url('./../../assets/home/Laag 5.png') no-repeat;
|
||||
background: url('@/assets/home/Laag 5.png') no-repeat;
|
||||
background-size: 100% 100%;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user