但是我在微信浏览器里没有调起微信支付,然后没有用开发者工具,所以没法看报错,这个要怎么处理?
const handleRecharge = () => {
if (!amount.value) {
showToast(t("PleaseEnterRechargeAmount"));
return;
}
orderNo.value = generateOrderNo();
// 处理充值逻辑
showLoadingToast({
message: t("Recharging"),
forbidClick: true,
});
try {
console.log("amount", amount.value);
passageApi
.getWeChatRecharge(amount.value * 100, orderNo.value)
.then((res) => {
console.log("res", res);
// 请求成功后关闭loading
document.querySelector(".van-loading-toast")?.remove();
// 可以根据响应结果显示成功消息
if (res && res.success) {
const payParams = res.data.pay_params;
console.log("payParams", payParams);
wx.requestPayment({
timeStamp: payParams.timeStamp,
nonceStr: payParams.nonceStr,
package: payParams.package,
signType: payParams.signType,
paySign: payParams.paySign,
success: function (res) {
console.log("支付成功", res);
// 支付成功
// showSuccessToast(t('RechargeSuccess'));
// amount.value = '';
// 支付成功后更新卡片信息
// fetchCardInfo().then(() => {
// setTimeout(() => {
// router.push({ name: "home" });
// }, 1500);
// });
},
fail: function (err) {
// 支付失败
console.error("支付失败:", err);
// if (err.errMsg !== 'requestPayment:fail cancel') {
// // showToast(t('PaymentFailed'));
// }
},
});
amount.value = "";
// setTimeout(() => {
// router.push({ name: "home" });
// }, 1500);
} else {
// showToast(res?.message || t('RechargeFailed'));
console.log("充值接口失败");
}
}).catch(error => {
// 请求失败时也关闭loading
document.querySelector(".van-loading-toast")?.remove();
console.error("充值请求失败:", error);
// showToast(t("NetworkError"));
});;
} catch (error) {
// 请求失败时也关闭loading
document.querySelector(".van-loading-toast")?.remove();
console.error("充值请求失败:", error);
showToast(t("NetworkError"));
}
}; <van-button type="primary" block @click="handleRecharge">{{
t("ConfirmRecharge")
}}</van-button>在微信浏览器里点击确认充值后没有调起微信支付