From 3dd4609edfbea98a423e9dd21c1e496f470313be Mon Sep 17 00:00:00 2001 From: yezian Date: Mon, 18 Mar 2024 21:40:55 +0800 Subject: [PATCH] =?UTF-8?q?h5=E4=B8=80=E9=94=AE=E8=A7=A3=E9=94=81=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E6=94=B9=E4=B8=BA=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/[user_id]/_components/WechatBar/index.jsx | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/app/[user_id]/_components/WechatBar/index.jsx b/app/[user_id]/_components/WechatBar/index.jsx index 3b40251..a1d5e09 100644 --- a/app/[user_id]/_components/WechatBar/index.jsx +++ b/app/[user_id]/_components/WechatBar/index.jsx @@ -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({