diff --git a/pages/greeting/share.vue b/pages/greeting/share.vue index b764537..811a2ee 100644 --- a/pages/greeting/share.vue +++ b/pages/greeting/share.vue @@ -20,7 +20,19 @@ - + @@ -29,6 +41,7 @@ {{ content }} + {{ highlight }} @@ -108,6 +121,7 @@ import { ref } from "vue"; import { onLoad, onShareAppMessage } from "@dcloudio/uni-app"; import { getBavBarHeight } from "@/utils/system"; import NavBar from "@/components/NavBar/NavBar.vue"; +import { getPageDetail } from "@/api/system"; const navBarHeight = getBavBarHeight(); const defaultAvatar = @@ -117,6 +131,8 @@ const fromUser = ref(""); const fromAvatar = ref(""); const content = ref("万事顺遂\n岁岁平安\n愿你的生活\n日日有小确幸"); const author = ref("陈小明"); +const highlight = ref(""); +const backgroundUrl = ref(""); const hotList = ref([ { @@ -133,12 +149,35 @@ const hotList = ref([ }, ]); -onLoad((options) => { - if (options.content) content.value = decodeURIComponent(options.content); - if (options.author) author.value = decodeURIComponent(options.author); - if (options.fromUser) fromUser.value = decodeURIComponent(options.fromUser); - if (options.fromAvatar) - fromAvatar.value = decodeURIComponent(options.fromAvatar); +onLoad(async (options) => { + if (options.shareToken) { + const detail = await getPageDetail(options.shareToken); + if (detail) { + if (detail.from) { + fromUser.value = detail.from.nickname; + fromAvatar.value = detail.from.avatar; + } + if (detail.content) { + const parts = detail.content.split(" "); + if (parts.length > 1) { + highlight.value = parts.pop(); + content.value = parts.join("\n"); + } else { + content.value = detail.content; + highlight.value = ""; + } + } + author.value = detail.signature || "专属问候"; + backgroundUrl.value = detail.imageUrl || ""; + } + } else { + // Fallback to query params if no shareToken (legacy support or direct link) + if (options.content) content.value = decodeURIComponent(options.content); + if (options.author) author.value = decodeURIComponent(options.author); + if (options.fromUser) fromUser.value = decodeURIComponent(options.fromUser); + if (options.fromAvatar) + fromAvatar.value = decodeURIComponent(options.fromAvatar); + } }); const navToMake = () => { @@ -273,6 +312,15 @@ onShareAppMessage(() => { white-space: pre-wrap; } +.card-highlight { + display: block; + font-size: 48rpx; + color: #d81e06; + font-weight: 800; + margin-top: 20rpx; + font-family: "Songti SC", serif; +} + .card-divider { width: 60rpx; height: 2rpx;