diff --git a/src/components/Header.vue b/src/components/Header.vue index 2b19086..5c9c481 100644 --- a/src/components/Header.vue +++ b/src/components/Header.vue @@ -71,7 +71,10 @@ const updateHot = (value) => { onMounted(() => { const pages = getCurrentPages(); const currentPage = pages[pages.length - 1]; - if (currentPage.route === "pages/point-book-edit") { + if ( + currentPage.route === "pages/point-book-edit" || + currentPage.route === "pages/point-book-detail" + ) { pointBook.value = uni.getStorageSync("point-book"); } if ( diff --git a/src/pages/point-book-detail.vue b/src/pages/point-book-detail.vue index b7c8530..e8ada3b 100644 --- a/src/pages/point-book-detail.vue +++ b/src/pages/point-book-detail.vue @@ -7,19 +7,26 @@ import ScreenHint2 from "@/components/ScreenHint2.vue"; import RingBarChart from "@/components/RingBarChart.vue"; import { getPointBookDetailAPI, addNoteAPI } from "@/apis"; +import { generateShareCardImage } from "@/util"; + +import useStore from "@/store"; +import { storeToRefs } from "pinia"; +const store = useStore(); +const { user, device } = storeToRefs(store); const selectedIndex = ref(0); const showTip = ref(false); const showTip2 = ref(false); const showTip3 = ref(false); -const groups = ref([]); const data = ref({}); const targetId = ref(0); const targetSrc = ref(""); const arrows = ref([]); const notes = ref(""); const draftNotes = ref(""); -const recordId = ref(""); +const record = ref({ + groups: [], +}); const openTip = (index) => { if (index === 1) showTip.value = true; @@ -37,23 +44,31 @@ const saveNote = async () => { notes.value = draftNotes.value; draftNotes.value = ""; showTip3.value = false; - if (recordId.value) { - await addNoteAPI(recordId.value, notes.value); + if (record.value.id) { + await addNoteAPI(record.value.id, notes.value); } }; const onSelect = (index) => { selectedIndex.value = index; - data.value = groups.value[index]; - arrows.value = groups.value[index].list.filter((item) => item.x && item.y); + data.value = record.value.groups[index]; + arrows.value = record.value.groups[index].list.filter( + (item) => item.x && item.y + ); }; const goBack = () => { const pages = getCurrentPages(); - const currentPage = pages[pages.length - 2]; - uni.navigateBack({ - delta: currentPage.route === "pages/point-book" ? 1 : 2, - }); + if (pages.length > 1) { + const currentPage = pages[pages.length - 2]; + uni.navigateBack({ + delta: currentPage.route === "pages/point-book" ? 1 : 2, + }); + } else { + uni.redirectTo({ + url: "/pages/index", + }); + } }; const ringRates = computed(() => { @@ -68,7 +83,7 @@ const ringRates = computed(() => { onLoad(async (options) => { if (options.id) { const result = await getPointBookDetailAPI(options.id || 194); - recordId.value = result.id; + record.value = result; notes.value = result.remark || ""; const config = uni.getStorageSync("point-book-config"); config.targetOption.some((item) => { @@ -78,27 +93,36 @@ onLoad(async (options) => { } }); if (result.groups) { - groups.value = result.groups; data.value = result.groups[0]; arrows.value = result.groups[0].list; } } }); -onShareAppMessage(() => { +onShareAppMessage(async () => { + const imageUrl = await generateShareCardImage( + "shareCanvas", + record.value.recordDate, + data.value.userTotalRing, + data.value.totalRing + ); return { title: "射箭打卡,今日又精进了一些~", - path: "/pages/point-book-detail?id=" + recordId.value, - imageUrl: - "https://static.shelingxingqiu.com/attachment/2025-09-12/dcqoz26q0268wxmzjg.png", + path: "/pages/point-book-detail?id=" + record.value.id, + imageUrl, }; }); -onShareTimeline(() => { +onShareTimeline(async () => { + const imageUrl = await generateShareCardImage( + "shareCanvas", + record.value.recordDate, + data.value.userTotalRing, + data.value.totalRing + ); return { title: "射箭打卡,今日又精进了一些~", - query: "from=timeline", - imageUrl: - "https://static.shelingxingqiu.com/attachment/2025-09-12/dcqoz26q0268wxmzjg.png", + query: "id=" + record.value.id, + imageUrl, }; }); @@ -108,7 +132,7 @@ onShareTimeline(() => { :bgType="2" bgColor="#F5F5F5" :whiteBackArrow="false" - title="分析" + title="" :onBack="goBack" > @@ -129,6 +153,11 @@ onShareTimeline(() => { > --> + { 总环数 {{ data.userTotalRing }}/{{ data.totalRing }} - @@ -199,7 +232,7 @@ onShareTimeline(() => { }} --> - + {{ index }}: {{ @@ -231,9 +264,22 @@ onShareTimeline(() => { - + - + { 展示用户某次练习中射箭的点位 - 笔记 + 备注 {{ notes }}