fix: wechat pay issues
Some checks failed
build quyun abc / Build (push) Failing after 57s

This commit is contained in:
2025-08-11 10:35:58 +08:00
parent 4bddcfef9c
commit 4d0b5a8961
2 changed files with 56 additions and 35 deletions

View File

@@ -100,43 +100,45 @@ const handleBuy = async () => {
const payData = response.data;
if (payData.appId != "balance") {
// 调用微信支付
window.WeixinJSBridge.invoke(
"getBrandWCPayRequest",
{
...payData,
},
async function (res) {
if (res.err_msg === "get_brand_wcpay_request:ok") {
// 支付成功,刷新文章数据
fetchArticle();
await updateMediaSource();
} else if (res.err_msg === "get_brand_wcpay_request:cancel") {
// 用户取消支付
console.log("Payment cancelled");
alert("支付已取消");
} else {
// 支付失败或取消
console.error("Payment failed:", res.err_msg);
alert(
"支付失败:" +
(res.err_msg === "get_brand_wcpay_request:cancel"
? "支付已取消"
: "支付异常")
);
}
}
);
return
}
// 暂停使用微支付
// if (payData.appId != "balance") {
// // 调用微信支付
// window.WeixinJSBridge.invoke(
// "getBrandWCPayRequest",
// {
// ...payData,
// },
// async function (res) {
// if (res.err_msg === "get_brand_wcpay_request:ok") {
// // 支付成功,刷新文章数据
// fetchArticle();
// await updateMediaSource();
// } else if (res.err_msg === "get_brand_wcpay_request:cancel") {
// // 用户取消支付
// console.log("Payment cancelled");
// alert("支付已取消");
// } else {
// // 支付失败或取消
// console.error("Payment failed:", res.err_msg);
// alert(
// "支付失败:" +
// (res.err_msg === "get_brand_wcpay_request:cancel"
// ? "支付已取消"
// : "支付异常")
// );
// }
// }
// );
// return
// }
alert("余额支付成功");
fetchArticle();
await updateMediaSource();
} catch (error) {
console.error("Failed to initiate payment:", error);
alert("发起支付失败,请稍后重试");
// alert("发起支付失败,请稍后重试");
alert(error.response?.data?.message || "发起支付失败,请稍后重试");
} finally {
buying.value = false;
}
@@ -229,6 +231,9 @@ onUnmounted(() => {
<div class="text-sm bg-orange-500 text-white px-4 py-2">
注意未购买视频仅可预览 1 分钟购买后可观看全集
</div>
<div class="bg-orange-300 text-white px-4 py-4">
账户充值购买联系微信<span class="font-bold">13932043996</span>
</div>
<div class="flex items-center justify-between max-w-md mx-auto p-4">
<div class="text-orange-600 text-2xl">
<span class="mr-2 text-xl">&yen;</span>