diff --git a/pages/user/History/index.vue b/pages/user/History/index.vue index 11ed76c..1697e24 100644 --- a/pages/user/History/index.vue +++ b/pages/user/History/index.vue @@ -1,36 +1,75 @@ @@ -42,6 +81,7 @@ export default { currentWeek: [], actived: 0, webUrl: this.$VUE_APP_RESOURCES_URL, + isLoad: false, items: [] } }, @@ -50,7 +90,7 @@ export default { }, mounted() { this.currentWeek = this.getWeek() - this.getActived() + this.actived = this.getActived() }, methods: { getActived() { @@ -59,23 +99,25 @@ export default { return weekMap.indexOf(today) }, getWeek() { - let dates = []; - let now = new Date(); - let dayOfWeek = now.getDay(); // 0-6, 0是周日 - let numDate = now.getDate(); // 当前日 - let numDaysToMonday = dayOfWeek ? dayOfWeek - 1 : 6; + const dates = [] + const now = new Date(); + // 0-6, 0是周日 + const dayOfWeek = now.getDay() + // 当前日 + const numDate = now.getDate() + const numDaysToMonday = dayOfWeek ? dayOfWeek - 1 : 6 // 得到本周周一的日期 - let monday = new Date(now); - monday.setDate(numDate - numDaysToMonday); + const monday = new Date(now) + monday.setDate(numDate - numDaysToMonday) // 生成本周剩余的日期 for (let i = 0; i < 7; i++) { - dates.push(new Date(monday).toISOString().slice(0, 10)); - monday.setDate(monday.getDate() + 1); + dates.push(new Date(monday).toISOString().slice(0, 10)) + monday.setDate(monday.getDate() + 1) } - return dates; + return dates }, getDay(date) { return new Date(date).getDate() @@ -106,8 +148,21 @@ export default { }) }, queryHistory() { + this.items = [] + this.isLoad = false getHistory().then(res => { - this.items = res.data + const { data = [] } = res + if (data.length > 0) { + data.map(item => { + if (item.histories) { + if (item.histories.length > 0) { + this.items.push(item) + } + } + }) + } + }).finally(() => { + this.isLoad = true }) } @@ -116,21 +171,48 @@ export default {