fix: daily page

This commit is contained in:
zzc
2026-03-02 21:14:37 +08:00
parent b9bec457a7
commit d5012753c1
2 changed files with 48 additions and 18 deletions

View File

@@ -142,33 +142,32 @@
</button>
</view>
</view>
<!-- 登录弹窗 -->
<LoginPopup />
</view>
</template>
<script setup>
import { ref, computed, onMounted, watch } from "vue";
import { getBavBarHeight } from "@/utils/system";
import { ref, computed, onMounted } from "vue";
import NavBar from "@/components/NavBar/NavBar.vue";
import {
onShareAppMessage,
onShareTimeline,
onShow,
onLoad,
} from "@dcloudio/uni-app";
import { onShareAppMessage, onShareTimeline } from "@dcloudio/uni-app";
import { useUserStore } from "@/stores/user";
import { getDailyInfo, getDailyRandomGreeting } from "@/api/daily";
import {
getDailyInfo,
getDailyRandomGreeting,
saveDailyGreeting,
} from "@/api/daily";
import {
getShareToken,
saveViewRequest,
generateObjectId,
} from "@/utils/common.js";
import LoginPopup from "@/components/LoginPopup/LoginPopup.vue";
const userStore = useUserStore();
const navBarHeight = getBavBarHeight();
const streakDays = ref(0);
const dateStr = computed(() => {
const date = new Date();
return `${date.getFullYear()} 灵马送福 · 每日精选`;
});
const greetingTitle = computed(() => {
const hour = new Date().getHours();
if (hour < 9) return "早安,今天也要好运";
@@ -227,6 +226,7 @@ const loadDailyInfo = async () => {
author: authorName.value, // Will be reactive in template via authorName ref
backgroundUrl: backgroundUrl || "",
id: greetingId,
content: greetingContent,
};
if (greetingScene) {
@@ -276,6 +276,7 @@ const refreshQuote = async () => {
highlight,
backgroundUrl: backgroundUrl || "",
id: greetingId,
content: greetingContent,
};
}
} catch (e) {
@@ -309,7 +310,15 @@ const saveCard = () => {
// });
// };
onShareAppMessage((res) => {
onShareAppMessage(async (options) => {
const id = createGreeting();
const shareToken = await getShareToken("daily_greeting", id);
return {
title: `${authorName.value}给你发来了一份今日问候`,
path: "/pages/greeting/share?shareToken=" + shareToken,
};
const fromUser = userStore.userInfo?.nickName || "神秘好友";
const fromAvatar = userStore.userInfo?.avatarUrl || "";
@@ -336,6 +345,19 @@ onShareAppMessage((res) => {
};
});
const createGreeting = () => {
const id = generateObjectId();
saveDailyGreeting({
id,
greetingId: currentQuote.value.id,
content: currentQuote.value.content,
signature: authorName.value,
imageUrl: currentQuote.value.backgroundUrl,
sceneId: currentCategory.value,
});
return id;
};
onShareTimeline(() => {
const fromUser = userStore.userInfo?.nickName || "神秘好友";
return {