Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
飞
飞鹤小程序
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
FH
飞鹤小程序
Commits
968ba0f0
Commit
968ba0f0
authored
Sep 04, 2025
by
spc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
back
parent
6f2a1424
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
8 deletions
+22
-8
XingmaLabDetailPage.vue
pages/XingmaLabDetailPage/XingmaLabDetailPage.vue
+22
-8
No files found.
pages/XingmaLabDetailPage/XingmaLabDetailPage.vue
View file @
968ba0f0
...
...
@@ -59,7 +59,7 @@
</
template
>
<
script
setup
>
import
{
ref
,
onMounted
,
computed
}
from
'vue'
import
{
ref
,
onMounted
,
computed
,
onUnmounted
}
from
'vue'
import
{
xingmaLabDetailConfig
,
getImageUrl
}
from
'./config.js'
import
{
fetchRecordDetail
,
fetchFavoriteAdd
,
fetchFavoriteRemove
}
from
'@/api/xingmaLab.js'
import
{
useHomeStore
}
from
'@/stores/home.js'
...
...
@@ -100,6 +100,18 @@ const formatTime = (timeStr) => {
return
`
${
year
}
-
${
month
}
-
${
day
}
`
}
// 同步收藏状态到上一页
const
syncCollectionStatusToPrevPage
=
()
=>
{
const
pages
=
getCurrentPages
()
if
(
pages
.
length
>
1
)
{
let
prevPage
=
pages
[
pages
.
length
-
2
]
prevPage
.
setData
({
isFavorite
:
detailData
.
value
.
collection
?
1
:
-
1
})
console
.
log
(
'✅ 收藏状态已同步到上一页:'
,
detailData
.
value
.
collection
?
1
:
-
1
)
}
}
// 获取详情数据
const
fetchDetailData
=
async
(
id
)
=>
{
try
{
...
...
@@ -114,6 +126,9 @@ const fetchDetailData = async (id) => {
detailData
.
value
=
result
.
data
recordId
.
value
=
id
// 保存记录ID
console
.
log
(
'✅ 详情数据获取成功:'
,
detailData
.
value
)
// 初始化时同步收藏状态到上一页
syncCollectionStatusToPrevPage
()
}
else
{
throw
new
Error
(
result
.
message
||
'获取详情失败'
)
}
...
...
@@ -180,6 +195,8 @@ const handleLikeClick = async () => {
const
result
=
await
fetchFavoriteRemove
({
relationId
:
recordId
})
if
(
result
.
success
)
{
detailData
.
value
.
collection
=
false
// 更新时同步收藏状态到上一页
syncCollectionStatusToPrevPage
()
uni
.
showToast
({
title
:
'已取消收藏'
,
icon
:
'none'
...
...
@@ -192,6 +209,8 @@ const handleLikeClick = async () => {
const
result
=
await
fetchFavoriteAdd
({
relationId
:
recordId
})
if
(
result
.
success
)
{
detailData
.
value
.
collection
=
true
// 更新时同步收藏状态到上一页
syncCollectionStatusToPrevPage
()
uni
.
showToast
({
title
:
'收藏成功'
,
icon
:
'none'
...
...
@@ -228,20 +247,15 @@ const handleShareClick = () => {
// })
}
// 返回上一页
const
handleGoBack
=
()
=>
{
// 检查是否有上一页
const
pages
=
getCurrentPages
()
console
.
log
(
'pages'
,
pages
)
if
(
pages
.
length
>
1
)
{
let
prevPage
=
pages
[
pages
.
length
-
2
]
prevPage
.
setData
({
isFavorite
:
detailData
.
value
.
collection
?
1
:
-
1
})
// 有上一页,返回上一页
// 有上一页,直接返回上一页(收藏状态已在更新时同步)
uni
.
navigateBack
({
delta
:
1
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment