h5一键解锁微信改为微信支付
This commit is contained in:
parent
7037a5768d
commit
3dd4609edf
|
@ -21,7 +21,7 @@ export default function WechatBar({
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [showBuyWechat, setShowBuyWechat] = useState(false);
|
const [showBuyWechat, setShowBuyWechat] = useState(false);
|
||||||
|
|
||||||
const handlePurchase = async () => {
|
const handlePurchase = async (type = "alipay_h5") => {
|
||||||
const isLogined = await checkAuth();
|
const isLogined = await checkAuth();
|
||||||
if (!isLogined) {
|
if (!isLogined) {
|
||||||
router.push("/auth/login/phonenumlogin");
|
router.push("/auth/login/phonenumlogin");
|
||||||
|
@ -31,7 +31,7 @@ export default function WechatBar({
|
||||||
const base = baseRequest();
|
const base = baseRequest();
|
||||||
const signature = generateSignature({
|
const signature = generateSignature({
|
||||||
uid: streamerMid,
|
uid: streamerMid,
|
||||||
pay_type: "alipay_h5",
|
pay_type: type,
|
||||||
...base,
|
...base,
|
||||||
});
|
});
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
|
@ -43,7 +43,7 @@ export default function WechatBar({
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
uid: streamerMid,
|
uid: streamerMid,
|
||||||
pay_type: "alipay_h5",
|
pay_type: type,
|
||||||
...base,
|
...base,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
@ -61,8 +61,22 @@ export default function WechatBar({
|
||||||
router.push("/purchased");
|
router.push("/purchased");
|
||||||
return;
|
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) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
@ -125,7 +139,7 @@ export default function WechatBar({
|
||||||
<div className="flex flex-row">
|
<div className="flex flex-row">
|
||||||
<button
|
<button
|
||||||
className="flex flex-row flex-1 mx-2 items-center justify-center bg-[#FF669E] rounded-lg py-2"
|
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>
|
<p className="text-white text-base ml-1">立即购买</p>
|
||||||
</button>
|
</button>
|
||||||
|
|
Loading…
Reference in New Issue