🐛 修复获取下个生日数据错误

This commit is contained in:
目棃
2024-04-04 01:04:07 +08:00
parent e5b30af48f
commit 983be395fa
4 changed files with 69 additions and 16 deletions

View File

@@ -1,11 +1,13 @@
<!-- todo ui 优化结合 birth_calendar/birth_role 数据 -->
<template>
<div class="tcb-container">
<img v-if="!isBirthday" src="/source/UI/empty.webp" alt="empty" />
<img @click="toPost()" v-else src="/source/UI/act_birthday.png" alt="empty" class="active" />
<span>{{
isBirthday ? `今天是 ${cur.map((i) => i.name).join("、")} 的生日!` : "没有角色今天过生日哦~"
}}</span>
<span v-if="next.length > 0"
<span v-if="isBirthday" class="tcb-label" @click="toBirth('today')">
今天是{{ cur.map((i) => i.name).join("、") }}的生日哦~
</span>
<span v-else>今天没有角色过生日哦~</span>
<span v-if="next.length > 0" @click="toBirth('next')" class="tcb-label"
>即将到来{{ next[0].birthday[0] }}{{ next[0].birthday[1] }}</span
>
<span v-if="next.length > 0">{{ next.map((i) => i.name).join("、") }}</span>
@@ -34,6 +36,21 @@ onBeforeMount(async () => {
async function toPost() {
await router.push("/news/2");
}
function toBirth(type: "today" | "next") {
let dateStr;
if (type === "today") {
const date = new Date();
const month = date.getMonth() + 1;
const day = date.getDate();
dateStr = `${month}/${day}`;
} else {
const month = next.value[0].birthday[0];
const day = next.value[0].birthday[1];
dateStr = `${month}/${day}`;
}
router.push({ name: "留影叙佳期", params: { date: dateStr } });
}
</script>
<style lang="css" scoped>
.tcb-container {
@@ -61,4 +78,10 @@ span {
margin-top: 10px;
text-align: center;
}
.tcb-label {
flex-wrap: wrap;
cursor: pointer;
word-break: break-all;
}
</style>