|
@@ -277,9 +277,9 @@ async function toggleFavorite() {
|
|
try {
|
|
try {
|
|
if (detail.value.favoriteFlag) {
|
|
if (detail.value.favoriteFlag) {
|
|
// 取消收藏
|
|
// 取消收藏
|
|
- const res = await myFavoriteDel({ id: productId.value })
|
|
|
|
|
|
+ const res = await myFavoriteDel({ id: detail.value.favoriteId })
|
|
if (res.code === '200') {
|
|
if (res.code === '200') {
|
|
- detail.value.favoriteFlag = false
|
|
|
|
|
|
+ await queryDetail()
|
|
toast.success(t('productDetail.unfavoriteSuccess'))
|
|
toast.success(t('productDetail.unfavoriteSuccess'))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -287,7 +287,7 @@ async function toggleFavorite() {
|
|
// 添加收藏
|
|
// 添加收藏
|
|
const res = await myFavoriteAdd({ productIdList: [productId.value] })
|
|
const res = await myFavoriteAdd({ productIdList: [productId.value] })
|
|
if (res.code === '200') {
|
|
if (res.code === '200') {
|
|
- detail.value.favoriteFlag = true
|
|
|
|
|
|
+ await queryDetail() // 重新获取详情,更新 favoriteId
|
|
toast.success(t('productDetail.favoriteSuccess'))
|
|
toast.success(t('productDetail.favoriteSuccess'))
|
|
}
|
|
}
|
|
}
|
|
}
|