feat: add alert

This commit is contained in:
yanghao05
2025-04-29 15:35:45 +08:00
parent 1dbdfba3cb
commit 844cd9d558

View File

@@ -59,7 +59,7 @@ const handleBuy = async () => {
if (buying.value) return
buying.value = true
try {
const response = await postApi.buy(route.params.id)
const response = await postApi.buy(article.value.id)
const payData = response.data
// 调用微信支付
@@ -88,8 +88,46 @@ const fetchArticle = async () => {
const { id } = route.params
const { data } = await postApi.show(id)
article.value = data
// 定义“分享给朋友”及“分享到QQ”按钮的分享内容
const shareContent = {
title: data.title,
desc: data.content,
link: window.location.href,
imgUrl: data.head_images[0]
}
// 调用微信 JS SDK 分享接口
if (window.wx) {
wx.ready(function () {
wx.updateTimelineShareData({
title: shareContent.title,
link: shareContent.link,
imgUrl: shareContent.imgUrl,
success: function () {
console.log('分享成功')
},
cancel: function () {
console.log('分享取消')
}
})
wx.updateAppMessageShareData({
title: shareContent.title,
desc: shareContent.desc,
link: shareContent.link,
imgUrl: shareContent.imgUrl,
success: function () {
console.log('分享成功')
},
cancel: function () {
console.log('分享取消')
}
})
})
}
} catch (error) {
console.error('Failed to fetch article:', error)
alert("加载失败!")
}
}