fix: share token
This commit is contained in:
@@ -105,9 +105,11 @@ import {
|
||||
onPullDownRefresh,
|
||||
onShareAppMessage,
|
||||
onReachBottom,
|
||||
onLoad,
|
||||
} from "@dcloudio/uni-app";
|
||||
import { getBavBarHeight } from "@/utils/system";
|
||||
import { getRecommendList } from "@/api/system";
|
||||
import { getRecommendList, getRandomGreeting } from "@/api/system";
|
||||
import { getShareToken, saveViewRequest } from "@/utils/common.js";
|
||||
|
||||
const countdownText = ref("");
|
||||
|
||||
@@ -146,31 +148,40 @@ const updateCountdown = () => {
|
||||
const todayDate = ref("");
|
||||
const dailyGreeting = ref("");
|
||||
|
||||
const inspirationList = [
|
||||
"岁岁常欢愉,年年皆胜意。愿你新的一年,多喜乐,长安宁。",
|
||||
"新的一年,愿日子如熹光,温柔又安详。你我赤诚且勇敢,欣喜也在望。",
|
||||
"祝你:百事无忌,平安喜乐。万事胜意,得偿所愿。",
|
||||
"凡是过往,皆为序章。愿2026年,烟火向星辰,所愿皆成真。",
|
||||
"愿新的一年,仍有阳光满路,温暖如初。",
|
||||
"辞暮尔尔,烟火年年。朝朝暮暮,岁岁平安。",
|
||||
"愿你即使单枪匹马,也能勇敢无畏。新的一年,万事尽可期待。",
|
||||
"所求皆如愿,所行化坦途。多喜乐,长安宁。",
|
||||
"愿你手握山河,且行且歌。新年快乐,万事大吉。",
|
||||
"长路浩浩荡荡,万物尽可期待。祝你新年好运。",
|
||||
"何其有幸,年岁并进。新的一年,愿你快乐,不止新年。",
|
||||
"愿新年,胜旧年。无病无灾,岁岁平安。",
|
||||
"烟火起,照人间,举杯敬此年。烟花落,看人间,家家户户皆团圆。",
|
||||
"家人闲坐,灯火可亲。新年伊始,喜乐安宁。",
|
||||
"愿今年所有的遗憾,都是明年惊喜的铺垫。",
|
||||
];
|
||||
onLoad((options) => {
|
||||
if (options.shareToken) saveViewRequest(options.shareToken, "index");
|
||||
|
||||
const copyGreeting = () => {
|
||||
uni.setClipboardData({
|
||||
data: dailyGreeting.value,
|
||||
success: () => {
|
||||
uni.showToast({ title: "复制成功", icon: "none" });
|
||||
},
|
||||
});
|
||||
updateCountdown();
|
||||
getRandomGreetingText();
|
||||
fetchRecommendList();
|
||||
|
||||
const date = new Date();
|
||||
todayDate.value = `${date.getMonth() + 1}月${date.getDate()}日`;
|
||||
|
||||
// Daily Inspiration Logic
|
||||
// const startOfYear = new Date(date.getFullYear(), 0, 0);
|
||||
// const diff = date - startOfYear;
|
||||
// const oneDay = 1000 * 60 * 60 * 24;
|
||||
// const dayOfYear = Math.floor(diff / oneDay);
|
||||
|
||||
// const index = dayOfYear % inspirationList.length;
|
||||
// dailyGreeting.value = inspirationList[index];
|
||||
});
|
||||
|
||||
onShareAppMessage(async () => {
|
||||
const shareToken = await getShareToken("index");
|
||||
return {
|
||||
title: "新春祝福",
|
||||
path: `/pages/index/index?shareToken=${shareToken}`,
|
||||
imageUrl:
|
||||
"https://file.lihailezzc.com/resource/cfed2edbfa19250b836a87a4bbf0d5ad.png",
|
||||
};
|
||||
});
|
||||
|
||||
const getRandomGreetingText = async () => {
|
||||
const content = await getRandomGreeting();
|
||||
dailyGreeting.value =
|
||||
content || "烟火起,照人间,举杯敬此年。烟花落,看人间,家家户户皆团圆。";
|
||||
};
|
||||
|
||||
const useGreeting = () => {
|
||||
@@ -180,23 +191,6 @@ const useGreeting = () => {
|
||||
});
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
updateCountdown();
|
||||
const date = new Date();
|
||||
todayDate.value = `${date.getMonth() + 1}月${date.getDate()}日`;
|
||||
|
||||
// Daily Inspiration Logic
|
||||
const startOfYear = new Date(date.getFullYear(), 0, 0);
|
||||
const diff = date - startOfYear;
|
||||
const oneDay = 1000 * 60 * 60 * 24;
|
||||
const dayOfYear = Math.floor(diff / oneDay);
|
||||
|
||||
const index = dayOfYear % inspirationList.length;
|
||||
dailyGreeting.value = inspirationList[index];
|
||||
|
||||
fetchRecommendList();
|
||||
});
|
||||
|
||||
const features = ref([
|
||||
{
|
||||
title: "新春祝福卡片",
|
||||
@@ -342,10 +336,6 @@ onReachBottom(() => {
|
||||
fetchRecommendList();
|
||||
});
|
||||
|
||||
const onMore = () => {
|
||||
uni.showToast({ title: "更多模板即将上线~", icon: "none" });
|
||||
};
|
||||
|
||||
onPullDownRefresh(async () => {
|
||||
await fetchRecommendList(true);
|
||||
setTimeout(() => {
|
||||
@@ -353,15 +343,6 @@ onPullDownRefresh(async () => {
|
||||
uni.showToast({ title: "已为你更新内容", icon: "success" });
|
||||
}, 600);
|
||||
});
|
||||
|
||||
onShareAppMessage(() => {
|
||||
return {
|
||||
title: "新春祝福",
|
||||
path: "/pages/index/index",
|
||||
imageUrl:
|
||||
"https://file.lihailezzc.com/resource/cfed2edbfa19250b836a87a4bbf0d5ad.png",
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
Reference in New Issue
Block a user