fix: share token
This commit is contained in:
@@ -182,11 +182,7 @@
|
||||
import { ref, computed } from "vue";
|
||||
import { onShareAppMessage, onLoad, onReachBottom } from "@dcloudio/uni-app";
|
||||
import { useUserStore } from "@/stores/user";
|
||||
import {
|
||||
createShareToken,
|
||||
getShareReward,
|
||||
abilityCheck,
|
||||
} from "@/api/system.js";
|
||||
import { getShareReward, abilityCheck } from "@/api/system.js";
|
||||
import {
|
||||
getAvatarSystemList,
|
||||
getAvatarFrameList,
|
||||
@@ -200,7 +196,6 @@ import {
|
||||
uploadImage,
|
||||
} from "@/utils/common.js";
|
||||
import NavBar from "@/components/NavBar/NavBar.vue";
|
||||
import { getBavBarHeight } from "@/utils/system";
|
||||
|
||||
const userStore = useUserStore();
|
||||
const loginPopupRef = ref(null);
|
||||
@@ -676,20 +671,22 @@ const completeCardInfo = async (id) => {
|
||||
onShareAppMessage(async () => {
|
||||
getShareReward({ scene: "avatar_download" });
|
||||
if (!isLoggedIn.value) {
|
||||
const shareTokenRes = await getShareToken("avatar_download_not_login", "");
|
||||
const shareToken = await getShareToken("avatar_download_not_login", "");
|
||||
return {
|
||||
title: "新春祝福",
|
||||
path: `/pages/index/index?shareToken=${shareTokenRes.shareToken}`,
|
||||
path: `/pages/index/index?shareToken=${shareToken}`,
|
||||
};
|
||||
}
|
||||
uni.showLoading({ title: "分享中...", mask: true });
|
||||
const id = createAvatarId();
|
||||
const shareTokenRes = await getShareToken("avatar_download", id);
|
||||
const imageUrl = await completeCardInfo(id);
|
||||
const [shareToken, imageUrl] = await Promise.all([
|
||||
getShareToken("avatar_download", id),
|
||||
completeCardInfo(id),
|
||||
]);
|
||||
uni.hideLoading();
|
||||
return {
|
||||
title: "我做了一个新头像,真的太好看了",
|
||||
path: `/pages/avatar/detail?shareToken=${shareTokenRes.shareToken}`,
|
||||
path: `/pages/avatar/detail?shareToken=${shareToken}`,
|
||||
imageUrl, // 使用默认封面或 popularCards 的封面
|
||||
};
|
||||
});
|
||||
|
||||
@@ -119,10 +119,14 @@ import { getDeviceInfo } from "@/utils/system";
|
||||
import { onLoad, onShow, onShareAppMessage } from "@dcloudio/uni-app";
|
||||
import { abilityCheck } from "@/api/system.js";
|
||||
import { drawFortune } from "@/api/fortune.js";
|
||||
import { createShareToken, getShareReward } from "@/api/system.js";
|
||||
import { getShareReward } from "@/api/system.js";
|
||||
import LoginPopup from "@/components/LoginPopup/LoginPopup.vue";
|
||||
import { useUserStore } from "@/stores/user";
|
||||
import { saveRemoteImageToLocal, saveRecordRequest } from "@/utils/common.js";
|
||||
import {
|
||||
getShareToken,
|
||||
saveRemoteImageToLocal,
|
||||
saveRecordRequest,
|
||||
} from "@/utils/common.js";
|
||||
import NavBar from "@/components/NavBar/NavBar.vue";
|
||||
|
||||
const userStore = useUserStore();
|
||||
@@ -158,16 +162,11 @@ onUnmounted(() => {
|
||||
});
|
||||
|
||||
onShareAppMessage(async () => {
|
||||
const deviceInfo = getDeviceInfo();
|
||||
const shareTokenRes = await createShareToken({
|
||||
targetId: cardId.value,
|
||||
scene: "fortune_draw",
|
||||
...deviceInfo,
|
||||
});
|
||||
const shareToken = await getShareToken("fortune_draw", cardId.value);
|
||||
getRewardByShare();
|
||||
return {
|
||||
title: "马年运势我已经抽过了,你的会是什么?",
|
||||
path: `${cardId.value ? `/pages/fortune/detail?shareToken=${shareTokenRes.shareToken}` : `/pages/fortune/index?shareToken=${shareTokenRes.shareToken}`}`,
|
||||
path: `${cardId.value ? `/pages/fortune/detail?shareToken=${shareToken}` : `/pages/fortune/index?shareToken=${shareTokenRes.shareToken}`}`,
|
||||
imageUrl:
|
||||
"https://file.lihailezzc.com/resource/cfed2edbfa19250b836a87a4bbf0d5ad.png",
|
||||
};
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -407,7 +407,6 @@ import {
|
||||
getCardTemplateTitleList,
|
||||
} from "@/api/make";
|
||||
import {
|
||||
createShareToken,
|
||||
abilityCheck,
|
||||
getShareReward,
|
||||
msgCheckApi,
|
||||
@@ -843,24 +842,19 @@ onShareAppMessage(async (options) => {
|
||||
};
|
||||
}
|
||||
|
||||
const deviceInfo = getDeviceInfo();
|
||||
const shareTokenRes = await createShareToken({
|
||||
scene: "card_generate",
|
||||
targetId: id,
|
||||
...deviceInfo,
|
||||
});
|
||||
const shareToken = await getShareToken("card_generate", id);
|
||||
shareOrSave(id);
|
||||
return {
|
||||
title: "我刚做了一张祝福卡片,送给你",
|
||||
path: "/pages/detail/index?shareToken=" + shareTokenRes.shareToken,
|
||||
path: "/pages/detail/index?shareToken=" + shareToken,
|
||||
imageUrl:
|
||||
"https://file.lihailezzc.com/resource/13ec1134e6614feadeeaaa9ef21ea96e.png",
|
||||
};
|
||||
} else {
|
||||
const shareTokenRes = await getShareToken("card_generate_index", "");
|
||||
const shareToken = await getShareToken("card_generate_index", "");
|
||||
return {
|
||||
title: "新春祝福",
|
||||
path: `/pages/index/index?shareToken=${shareTokenRes.shareToken}`,
|
||||
path: `/pages/index/index?shareToken=${shareToken}`,
|
||||
imageUrl:
|
||||
"https://file.lihailezzc.com/resource/cfed2edbfa19250b836a87a4bbf0d5ad.png",
|
||||
};
|
||||
|
||||
@@ -126,21 +126,21 @@ onReachBottom(() => {
|
||||
|
||||
onShareAppMessage(async (options) => {
|
||||
if (options.from === "button") {
|
||||
const shareTokenRes = await getShareToken(
|
||||
const shareToken = await getShareToken(
|
||||
"card_generate",
|
||||
options?.target?.dataset?.item?.id,
|
||||
);
|
||||
return {
|
||||
title: "我刚做了一张祝福卡片,送给你",
|
||||
path: "/pages/detail/index?shareToken=" + shareTokenRes.shareToken,
|
||||
path: "/pages/detail/index?shareToken=" + shareToken,
|
||||
imageUrl:
|
||||
"https://file.lihailezzc.com/resource/13ec1134e6614feadeeaaa9ef21ea96e.png",
|
||||
};
|
||||
} else {
|
||||
const shareTokenRes = await getShareToken("greeting_page", "");
|
||||
const shareToken = await getShareToken("greeting_page", "");
|
||||
return {
|
||||
title: "新春祝福",
|
||||
path: `/pages/index/index?shareToken=${shareTokenRes.shareToken}`,
|
||||
path: `/pages/index/index?shareToken=${shareToken}`,
|
||||
imageUrl:
|
||||
"https://file.lihailezzc.com/resource/cfed2edbfa19250b836a87a4bbf0d5ad.png",
|
||||
};
|
||||
|
||||
@@ -106,19 +106,19 @@ const isRefreshing = ref(false);
|
||||
onShareAppMessage(async (options) => {
|
||||
getShareReward({ scene: "wallpaper_download" });
|
||||
if (options.from === "button") {
|
||||
const shareTokenRes = await getShareToken(
|
||||
const shareToken = await getShareToken(
|
||||
"wallpaper_download",
|
||||
options?.target?.dataset?.item?.id,
|
||||
);
|
||||
return {
|
||||
title: "快来挑选喜欢的新春壁纸吧",
|
||||
path: `/pages/wallpaper/detail?shareToken=${shareTokenRes.shareToken}`,
|
||||
path: `/pages/wallpaper/detail?shareToken=${shareToken}`,
|
||||
};
|
||||
} else {
|
||||
const shareTokenRes = await getShareToken("wallpaper_download", "");
|
||||
const shareToken = await getShareToken("wallpaper_download", "");
|
||||
return {
|
||||
title: "新春祝福",
|
||||
path: `/pages/index/index?shareToken=${shareTokenRes.shareToken}`,
|
||||
path: `/pages/index/index?shareToken=${shareToken}`,
|
||||
imageUrl:
|
||||
"https://file.lihailezzc.com/resource/cfed2edbfa19250b836a87a4bbf0d5ad.png",
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user