diff --git a/pages.json b/pages.json index a67ed12..3d9e4e8 100644 --- a/pages.json +++ b/pages.json @@ -8,6 +8,14 @@ "enablePullDownRefresh": false } }, + { + "path": "pages/greeting/share", + "style": { + "navigationBarTitleText": "问候分享", + "navigationStyle": "custom", + "enablePullDownRefresh": false + } + }, { "path": "pages/index/index", "style": { diff --git a/pages/greeting/daily.vue b/pages/greeting/daily.vue index 0fca434..6849621 100644 --- a/pages/greeting/daily.vue +++ b/pages/greeting/daily.vue @@ -125,7 +125,7 @@ 保存 - @@ -138,6 +138,10 @@ import { ref, computed, onMounted, watch } from "vue"; import { getBavBarHeight } from "@/utils/system"; import NavBar from "@/components/NavBar/NavBar.vue"; +import { onShareAppMessage } from "@dcloudio/uni-app"; +import { useUserStore } from "@/stores/user"; + +const userStore = useUserStore(); const navBarHeight = getBavBarHeight(); const streakDays = ref(5); @@ -249,13 +253,33 @@ const saveCard = () => { uni.showToast({ title: "保存功能开发中", icon: "none" }); }; -const sendGreeting = () => { - uni.navigateTo({ - url: `/pages/make/index?scene=daily&content=${encodeURIComponent( +// const sendGreeting = () => { +// // Use uni.navigateTo for normal flow if not open-type="share" +// // But here we might want to trigger share directly or just navigate to make page as before +// // Based on user request "share after friend opens page", it implies we need to handle share +// // Let's keep the navigation to make page for "Sending" (which usually means making a card first) +// // BUT also add onShareAppMessage so the top right menu share works +// uni.navigateTo({ +// url: `/pages/make/index?scene=daily&content=${encodeURIComponent( +// currentQuote.value.text, +// )}&author=${encodeURIComponent(authorName.value)}`, +// }); +// }; + +onShareAppMessage(() => { + const fromUser = userStore.userInfo?.nickName || "神秘好友"; + const fromAvatar = userStore.userInfo?.avatarUrl || ""; + return { + title: `${fromUser}给你发来了一份今日问候`, + path: `/pages/greeting/share?content=${encodeURIComponent( currentQuote.value.text, - )}&author=${encodeURIComponent(authorName.value)}`, - }); -}; + )}&author=${encodeURIComponent( + authorName.value || currentQuote.value.author, + )}&fromUser=${encodeURIComponent(fromUser)}&fromAvatar=${encodeURIComponent( + fromAvatar, + )}`, + }; +});