h5一键解锁微信改为微信支付

This commit is contained in:
yezian 2024-03-18 21:40:55 +08:00
parent 7037a5768d
commit 3dd4609edf
1 changed files with 20 additions and 6 deletions

View File

@ -21,7 +21,7 @@ export default function WechatBar({
const router = useRouter();
const [showBuyWechat, setShowBuyWechat] = useState(false);
const handlePurchase = async () => {
const handlePurchase = async (type = "alipay_h5") => {
const isLogined = await checkAuth();
if (!isLogined) {
router.push("/auth/login/phonenumlogin");
@ -31,7 +31,7 @@ export default function WechatBar({
const base = baseRequest();
const signature = generateSignature({
uid: streamerMid,
pay_type: "alipay_h5",
pay_type: type,
...base,
});
const response = await fetch(
@ -43,7 +43,7 @@ export default function WechatBar({
},
body: JSON.stringify({
uid: streamerMid,
pay_type: "alipay_h5",
pay_type: type,
...base,
}),
}
@ -61,8 +61,22 @@ export default function WechatBar({
router.push("/purchased");
return;
}
//
router.push(temData.data.alipay_h5_param_str);
//
switch (type) {
case "alipay_h5":
router.push(`${temData.data.alipay_h5_param_str}`);
break;
case "wxpay_h5":
router.push(
`https://weixin.tiefen.fun/pay/wxpay_h5/${encodeURIComponent(
temData.data.wxpay_h5_param_str
)}`
);
break;
default:
router.push(`${temData.data.alipay_h5_param_str}`);
break;
}
} catch (error) {
console.error(error);
}
@ -125,7 +139,7 @@ export default function WechatBar({
<div className="flex flex-row">
<button
className="flex flex-row flex-1 mx-2 items-center justify-center bg-[#FF669E] rounded-lg py-2"
onClick={handlePurchase}
onClick={() => handlePurchase("wxpay_h5")}
>
<p className="text-white text-base ml-1">立即购买</p>
</button>