Skip to content

Commit

Permalink
fix:本周bug
Browse files Browse the repository at this point in the history
  • Loading branch information
fifthThirteen committed Dec 3, 2023
1 parent e57344b commit 13c1281
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
25 changes: 22 additions & 3 deletions src/components/gonggao/Daily.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,18 @@ export default {
return { ...acc, [cur["key"]]: cur.name };
}, {});
},
date() {
// 当7点以前,请求前面一天的日常 当7~24点,请求当天的日常
const hour = dayjs.tz().get("hours");
return 0 <= hour && hour < 7
? dayjs.tz().subtract(1, "day").format("YYYY-MM-DD")
: dayjs.tz().format("YYYY-MM-DD");
},
isCurrentWeek() {
let week = dayjs.tz(this.date).isoWeek();
let currentWeek = dayjs.tz().isoWeek();
return week === currentWeek;
},
},
methods: {
loadDailyNew() {
Expand All @@ -147,13 +159,20 @@ export default {
},
getFurniture() {
if (!this.isOrigin) {
const start = this.isCurrentWeek
? dayjs.tz().startOf("isoWeek").format("YYYY-MM-DD")
: dayjs.tz().add(-1, "week").startOf("isoWeek").format("YYYY-MM-DD");
const end = this.isCurrentWeek
? dayjs.tz().endOf("isoWeek").format("YYYY-MM-DD")
: dayjs.tz().add(-1, "week").endOf("isoWeek").format("YYYY-MM-DD");
const params = {
subtypes: "category,property,next_match",
start: dayjs.tz().startOf("isoWeek").format("YYYY-MM-DD"),
end: dayjs.tz().endOf("isoWeek").format("YYYY-MM-DD"),
start,
end,
};
getFurniture(params).then((res) => {
const list = res.data?.data;
const list = res.data?.data || [];
if (list.some((item) => !item)) return;
this.currentFurniture = {
property: list.find((item) => item.subtype === "property")?.content || "",
category: list.find((item) => item.subtype === "category")?.content || "",
Expand Down
2 changes: 1 addition & 1 deletion src/components/gonggao/daily/SimpleDaily.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="m-simple-daily">
<div class="m-daily-wrap">
<div class="m-simple-daily-item" :class="item.isDone && 'is-done'" v-for="item in daily" :key="item.type">
<div class="m-simple-daily-item" :class="item.isDone && 'is-done'" v-for="item in daily" :key="item.name">
<div class="u-name">
<span>{{ item.name }}</span>
</div>
Expand Down

0 comments on commit 13c1281

Please sign in to comment.