feat: add alert
This commit is contained in:
@@ -59,7 +59,7 @@ const handleBuy = async () => {
|
|||||||
if (buying.value) return
|
if (buying.value) return
|
||||||
buying.value = true
|
buying.value = true
|
||||||
try {
|
try {
|
||||||
const response = await postApi.buy(route.params.id)
|
const response = await postApi.buy(article.value.id)
|
||||||
const payData = response.data
|
const payData = response.data
|
||||||
|
|
||||||
// 调用微信支付
|
// 调用微信支付
|
||||||
@@ -88,8 +88,46 @@ const fetchArticle = async () => {
|
|||||||
const { id } = route.params
|
const { id } = route.params
|
||||||
const { data } = await postApi.show(id)
|
const { data } = await postApi.show(id)
|
||||||
article.value = data
|
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) {
|
} catch (error) {
|
||||||
console.error('Failed to fetch article:', error)
|
console.error('Failed to fetch article:', error)
|
||||||
|
alert("加载失败!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user