fix: share token
This commit is contained in:
@@ -59,3 +59,10 @@ export const msgCheckApi = async (content) => {
|
|||||||
method: "get",
|
method: "get",
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getRandomGreeting = async () => {
|
||||||
|
return request({
|
||||||
|
url: "/api/blessing/random/greeting",
|
||||||
|
method: "get",
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|||||||
@@ -182,11 +182,7 @@
|
|||||||
import { ref, computed } from "vue";
|
import { ref, computed } from "vue";
|
||||||
import { onShareAppMessage, onLoad, onReachBottom } from "@dcloudio/uni-app";
|
import { onShareAppMessage, onLoad, onReachBottom } from "@dcloudio/uni-app";
|
||||||
import { useUserStore } from "@/stores/user";
|
import { useUserStore } from "@/stores/user";
|
||||||
import {
|
import { getShareReward, abilityCheck } from "@/api/system.js";
|
||||||
createShareToken,
|
|
||||||
getShareReward,
|
|
||||||
abilityCheck,
|
|
||||||
} from "@/api/system.js";
|
|
||||||
import {
|
import {
|
||||||
getAvatarSystemList,
|
getAvatarSystemList,
|
||||||
getAvatarFrameList,
|
getAvatarFrameList,
|
||||||
@@ -200,7 +196,6 @@ import {
|
|||||||
uploadImage,
|
uploadImage,
|
||||||
} from "@/utils/common.js";
|
} from "@/utils/common.js";
|
||||||
import NavBar from "@/components/NavBar/NavBar.vue";
|
import NavBar from "@/components/NavBar/NavBar.vue";
|
||||||
import { getBavBarHeight } from "@/utils/system";
|
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const loginPopupRef = ref(null);
|
const loginPopupRef = ref(null);
|
||||||
@@ -676,20 +671,22 @@ const completeCardInfo = async (id) => {
|
|||||||
onShareAppMessage(async () => {
|
onShareAppMessage(async () => {
|
||||||
getShareReward({ scene: "avatar_download" });
|
getShareReward({ scene: "avatar_download" });
|
||||||
if (!isLoggedIn.value) {
|
if (!isLoggedIn.value) {
|
||||||
const shareTokenRes = await getShareToken("avatar_download_not_login", "");
|
const shareToken = await getShareToken("avatar_download_not_login", "");
|
||||||
return {
|
return {
|
||||||
title: "新春祝福",
|
title: "新春祝福",
|
||||||
path: `/pages/index/index?shareToken=${shareTokenRes.shareToken}`,
|
path: `/pages/index/index?shareToken=${shareToken}`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
uni.showLoading({ title: "分享中...", mask: true });
|
uni.showLoading({ title: "分享中...", mask: true });
|
||||||
const id = createAvatarId();
|
const id = createAvatarId();
|
||||||
const shareTokenRes = await getShareToken("avatar_download", id);
|
const [shareToken, imageUrl] = await Promise.all([
|
||||||
const imageUrl = await completeCardInfo(id);
|
getShareToken("avatar_download", id),
|
||||||
|
completeCardInfo(id),
|
||||||
|
]);
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
return {
|
return {
|
||||||
title: "我做了一个新头像,真的太好看了",
|
title: "我做了一个新头像,真的太好看了",
|
||||||
path: `/pages/avatar/detail?shareToken=${shareTokenRes.shareToken}`,
|
path: `/pages/avatar/detail?shareToken=${shareToken}`,
|
||||||
imageUrl, // 使用默认封面或 popularCards 的封面
|
imageUrl, // 使用默认封面或 popularCards 的封面
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -119,10 +119,14 @@ import { getDeviceInfo } from "@/utils/system";
|
|||||||
import { onLoad, onShow, onShareAppMessage } from "@dcloudio/uni-app";
|
import { onLoad, onShow, onShareAppMessage } from "@dcloudio/uni-app";
|
||||||
import { abilityCheck } from "@/api/system.js";
|
import { abilityCheck } from "@/api/system.js";
|
||||||
import { drawFortune } from "@/api/fortune.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 LoginPopup from "@/components/LoginPopup/LoginPopup.vue";
|
||||||
import { useUserStore } from "@/stores/user";
|
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";
|
import NavBar from "@/components/NavBar/NavBar.vue";
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
@@ -158,16 +162,11 @@ onUnmounted(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onShareAppMessage(async () => {
|
onShareAppMessage(async () => {
|
||||||
const deviceInfo = getDeviceInfo();
|
const shareToken = await getShareToken("fortune_draw", cardId.value);
|
||||||
const shareTokenRes = await createShareToken({
|
|
||||||
targetId: cardId.value,
|
|
||||||
scene: "fortune_draw",
|
|
||||||
...deviceInfo,
|
|
||||||
});
|
|
||||||
getRewardByShare();
|
getRewardByShare();
|
||||||
return {
|
return {
|
||||||
title: "马年运势我已经抽过了,你的会是什么?",
|
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:
|
imageUrl:
|
||||||
"https://file.lihailezzc.com/resource/cfed2edbfa19250b836a87a4bbf0d5ad.png",
|
"https://file.lihailezzc.com/resource/cfed2edbfa19250b836a87a4bbf0d5ad.png",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -105,9 +105,11 @@ import {
|
|||||||
onPullDownRefresh,
|
onPullDownRefresh,
|
||||||
onShareAppMessage,
|
onShareAppMessage,
|
||||||
onReachBottom,
|
onReachBottom,
|
||||||
|
onLoad,
|
||||||
} from "@dcloudio/uni-app";
|
} from "@dcloudio/uni-app";
|
||||||
import { getBavBarHeight } from "@/utils/system";
|
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("");
|
const countdownText = ref("");
|
||||||
|
|
||||||
@@ -146,31 +148,40 @@ const updateCountdown = () => {
|
|||||||
const todayDate = ref("");
|
const todayDate = ref("");
|
||||||
const dailyGreeting = ref("");
|
const dailyGreeting = ref("");
|
||||||
|
|
||||||
const inspirationList = [
|
onLoad((options) => {
|
||||||
"岁岁常欢愉,年年皆胜意。愿你新的一年,多喜乐,长安宁。",
|
if (options.shareToken) saveViewRequest(options.shareToken, "index");
|
||||||
"新的一年,愿日子如熹光,温柔又安详。你我赤诚且勇敢,欣喜也在望。",
|
|
||||||
"祝你:百事无忌,平安喜乐。万事胜意,得偿所愿。",
|
|
||||||
"凡是过往,皆为序章。愿2026年,烟火向星辰,所愿皆成真。",
|
|
||||||
"愿新的一年,仍有阳光满路,温暖如初。",
|
|
||||||
"辞暮尔尔,烟火年年。朝朝暮暮,岁岁平安。",
|
|
||||||
"愿你即使单枪匹马,也能勇敢无畏。新的一年,万事尽可期待。",
|
|
||||||
"所求皆如愿,所行化坦途。多喜乐,长安宁。",
|
|
||||||
"愿你手握山河,且行且歌。新年快乐,万事大吉。",
|
|
||||||
"长路浩浩荡荡,万物尽可期待。祝你新年好运。",
|
|
||||||
"何其有幸,年岁并进。新的一年,愿你快乐,不止新年。",
|
|
||||||
"愿新年,胜旧年。无病无灾,岁岁平安。",
|
|
||||||
"烟火起,照人间,举杯敬此年。烟花落,看人间,家家户户皆团圆。",
|
|
||||||
"家人闲坐,灯火可亲。新年伊始,喜乐安宁。",
|
|
||||||
"愿今年所有的遗憾,都是明年惊喜的铺垫。",
|
|
||||||
];
|
|
||||||
|
|
||||||
const copyGreeting = () => {
|
updateCountdown();
|
||||||
uni.setClipboardData({
|
getRandomGreetingText();
|
||||||
data: dailyGreeting.value,
|
fetchRecommendList();
|
||||||
success: () => {
|
|
||||||
uni.showToast({ title: "复制成功", icon: "none" });
|
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 = () => {
|
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([
|
const features = ref([
|
||||||
{
|
{
|
||||||
title: "新春祝福卡片",
|
title: "新春祝福卡片",
|
||||||
@@ -342,10 +336,6 @@ onReachBottom(() => {
|
|||||||
fetchRecommendList();
|
fetchRecommendList();
|
||||||
});
|
});
|
||||||
|
|
||||||
const onMore = () => {
|
|
||||||
uni.showToast({ title: "更多模板即将上线~", icon: "none" });
|
|
||||||
};
|
|
||||||
|
|
||||||
onPullDownRefresh(async () => {
|
onPullDownRefresh(async () => {
|
||||||
await fetchRecommendList(true);
|
await fetchRecommendList(true);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -353,15 +343,6 @@ onPullDownRefresh(async () => {
|
|||||||
uni.showToast({ title: "已为你更新内容", icon: "success" });
|
uni.showToast({ title: "已为你更新内容", icon: "success" });
|
||||||
}, 600);
|
}, 600);
|
||||||
});
|
});
|
||||||
|
|
||||||
onShareAppMessage(() => {
|
|
||||||
return {
|
|
||||||
title: "新春祝福",
|
|
||||||
path: "/pages/index/index",
|
|
||||||
imageUrl:
|
|
||||||
"https://file.lihailezzc.com/resource/cfed2edbfa19250b836a87a4bbf0d5ad.png",
|
|
||||||
};
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
@@ -407,7 +407,6 @@ import {
|
|||||||
getCardTemplateTitleList,
|
getCardTemplateTitleList,
|
||||||
} from "@/api/make";
|
} from "@/api/make";
|
||||||
import {
|
import {
|
||||||
createShareToken,
|
|
||||||
abilityCheck,
|
abilityCheck,
|
||||||
getShareReward,
|
getShareReward,
|
||||||
msgCheckApi,
|
msgCheckApi,
|
||||||
@@ -843,24 +842,19 @@ onShareAppMessage(async (options) => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const deviceInfo = getDeviceInfo();
|
const shareToken = await getShareToken("card_generate", id);
|
||||||
const shareTokenRes = await createShareToken({
|
|
||||||
scene: "card_generate",
|
|
||||||
targetId: id,
|
|
||||||
...deviceInfo,
|
|
||||||
});
|
|
||||||
shareOrSave(id);
|
shareOrSave(id);
|
||||||
return {
|
return {
|
||||||
title: "我刚做了一张祝福卡片,送给你",
|
title: "我刚做了一张祝福卡片,送给你",
|
||||||
path: "/pages/detail/index?shareToken=" + shareTokenRes.shareToken,
|
path: "/pages/detail/index?shareToken=" + shareToken,
|
||||||
imageUrl:
|
imageUrl:
|
||||||
"https://file.lihailezzc.com/resource/13ec1134e6614feadeeaaa9ef21ea96e.png",
|
"https://file.lihailezzc.com/resource/13ec1134e6614feadeeaaa9ef21ea96e.png",
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
const shareTokenRes = await getShareToken("card_generate_index", "");
|
const shareToken = await getShareToken("card_generate_index", "");
|
||||||
return {
|
return {
|
||||||
title: "新春祝福",
|
title: "新春祝福",
|
||||||
path: `/pages/index/index?shareToken=${shareTokenRes.shareToken}`,
|
path: `/pages/index/index?shareToken=${shareToken}`,
|
||||||
imageUrl:
|
imageUrl:
|
||||||
"https://file.lihailezzc.com/resource/cfed2edbfa19250b836a87a4bbf0d5ad.png",
|
"https://file.lihailezzc.com/resource/cfed2edbfa19250b836a87a4bbf0d5ad.png",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -126,21 +126,21 @@ onReachBottom(() => {
|
|||||||
|
|
||||||
onShareAppMessage(async (options) => {
|
onShareAppMessage(async (options) => {
|
||||||
if (options.from === "button") {
|
if (options.from === "button") {
|
||||||
const shareTokenRes = await getShareToken(
|
const shareToken = await getShareToken(
|
||||||
"card_generate",
|
"card_generate",
|
||||||
options?.target?.dataset?.item?.id,
|
options?.target?.dataset?.item?.id,
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
title: "我刚做了一张祝福卡片,送给你",
|
title: "我刚做了一张祝福卡片,送给你",
|
||||||
path: "/pages/detail/index?shareToken=" + shareTokenRes.shareToken,
|
path: "/pages/detail/index?shareToken=" + shareToken,
|
||||||
imageUrl:
|
imageUrl:
|
||||||
"https://file.lihailezzc.com/resource/13ec1134e6614feadeeaaa9ef21ea96e.png",
|
"https://file.lihailezzc.com/resource/13ec1134e6614feadeeaaa9ef21ea96e.png",
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
const shareTokenRes = await getShareToken("greeting_page", "");
|
const shareToken = await getShareToken("greeting_page", "");
|
||||||
return {
|
return {
|
||||||
title: "新春祝福",
|
title: "新春祝福",
|
||||||
path: `/pages/index/index?shareToken=${shareTokenRes.shareToken}`,
|
path: `/pages/index/index?shareToken=${shareToken}`,
|
||||||
imageUrl:
|
imageUrl:
|
||||||
"https://file.lihailezzc.com/resource/cfed2edbfa19250b836a87a4bbf0d5ad.png",
|
"https://file.lihailezzc.com/resource/cfed2edbfa19250b836a87a4bbf0d5ad.png",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -106,19 +106,19 @@ const isRefreshing = ref(false);
|
|||||||
onShareAppMessage(async (options) => {
|
onShareAppMessage(async (options) => {
|
||||||
getShareReward({ scene: "wallpaper_download" });
|
getShareReward({ scene: "wallpaper_download" });
|
||||||
if (options.from === "button") {
|
if (options.from === "button") {
|
||||||
const shareTokenRes = await getShareToken(
|
const shareToken = await getShareToken(
|
||||||
"wallpaper_download",
|
"wallpaper_download",
|
||||||
options?.target?.dataset?.item?.id,
|
options?.target?.dataset?.item?.id,
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
title: "快来挑选喜欢的新春壁纸吧",
|
title: "快来挑选喜欢的新春壁纸吧",
|
||||||
path: `/pages/wallpaper/detail?shareToken=${shareTokenRes.shareToken}`,
|
path: `/pages/wallpaper/detail?shareToken=${shareToken}`,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
const shareTokenRes = await getShareToken("wallpaper_download", "");
|
const shareToken = await getShareToken("wallpaper_download", "");
|
||||||
return {
|
return {
|
||||||
title: "新春祝福",
|
title: "新春祝福",
|
||||||
path: `/pages/index/index?shareToken=${shareTokenRes.shareToken}`,
|
path: `/pages/index/index?shareToken=${shareToken}`,
|
||||||
imageUrl:
|
imageUrl:
|
||||||
"https://file.lihailezzc.com/resource/cfed2edbfa19250b836a87a4bbf0d5ad.png",
|
"https://file.lihailezzc.com/resource/cfed2edbfa19250b836a87a4bbf0d5ad.png",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export const saveRecordRequest = async (path, targetId, scene, imageUrl) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const saveViewRequest = async (shareToken, scene, targetId) => {
|
export const saveViewRequest = async (shareToken, scene, targetId = "") => {
|
||||||
const deviceInfo = getDeviceInfo();
|
const deviceInfo = getDeviceInfo();
|
||||||
viewRecord({
|
viewRecord({
|
||||||
shareToken,
|
shareToken,
|
||||||
@@ -92,7 +92,12 @@ export const saveRemoteImageToLocal = (imageUrl) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getShareToken = async (scene, targetId) => {
|
export const getShareToken = async (scene, targetId = "") => {
|
||||||
const deviceInfo = getDeviceInfo();
|
const deviceInfo = getDeviceInfo();
|
||||||
return await createShareToken({ scene, targetId, ...deviceInfo });
|
const shareTokenRes = await createShareToken({
|
||||||
|
scene,
|
||||||
|
targetId,
|
||||||
|
...deviceInfo,
|
||||||
|
});
|
||||||
|
return shareTokenRes?.shareToken || "";
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user