用于微信渠道申诉
This commit is contained in:
parent
bc5e910a08
commit
ed1068cccf
app/pay
|
@ -5,21 +5,84 @@ import { useRouter } from "next/navigation";
|
|||
import { Toast } from "antd-mobile";
|
||||
import { generateSignature } from "@/utils/crypto";
|
||||
import webviewBaseRequest from "@/utils/webviewBaseRequest";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
export default function Pay() {
|
||||
const router = useRouter();
|
||||
|
||||
const handleClick = () => {
|
||||
Toast.show({
|
||||
content: "支付渠道不可用,请耐心等待",
|
||||
});
|
||||
};
|
||||
|
||||
const createOrder = async (type = "alipay_h5") => {
|
||||
const body = {
|
||||
product_id: "membership",
|
||||
pay_type: type,
|
||||
from: "app",
|
||||
b_did: "test",
|
||||
b_mid: 1,
|
||||
};
|
||||
|
||||
//如果是微信jsapi支付直接跳转到中间页
|
||||
if (type === "wxpay_jsapi") {
|
||||
router.push(`/pay/${encodeURIComponent(JSON.stringify(body))}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const signature = generateSignature(body);
|
||||
try {
|
||||
const response = await fetch(
|
||||
`/api/vas/create_order?signature=${signature}`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
}
|
||||
);
|
||||
const data = await response.json();
|
||||
if (data.ret === -1) {
|
||||
Toast.show({
|
||||
content: data.msg,
|
||||
});
|
||||
return;
|
||||
}
|
||||
switch (type) {
|
||||
case "yeepay_alipay_h5":
|
||||
router.push(`${data.data.yeepay_alipay_h5_param_str}`);
|
||||
break;
|
||||
case "yeepay_wxpay_h5":
|
||||
router.push(`${data.data.yeepay_wxpay_h5_param_str}`);
|
||||
break;
|
||||
case "alipay_h5":
|
||||
router.push(`${data.data.alipay_h5_param_str}`);
|
||||
break;
|
||||
case "wxpay_h5":
|
||||
router.push(
|
||||
`https://shop.tiefen.fun/pay/wxpay_h5/${encodeURIComponent(
|
||||
data.data.wxpay_h5_param_str
|
||||
)}`
|
||||
);
|
||||
break;
|
||||
default:
|
||||
router.push(`${data.data.alipay_h5_param_str}`);
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<section className="flex flex-1 justify-center container">
|
||||
<div className="flex flex-1 flex-col items-center py-16 p-4">
|
||||
<p className="text-secondary text-base font-semibold my-2">
|
||||
您的订单价格为
|
||||
</p>
|
||||
<p className="text-white text-3xl font-semibold my-2">¥50</p>
|
||||
<p className="text-white text-3xl font-semibold my-2">¥10</p>
|
||||
<div className="flex flex-col w-full gap-4 mt-4">
|
||||
<div className="w-full px-2">
|
||||
<button
|
||||
|
@ -37,7 +100,7 @@ export default function Pay() {
|
|||
</div>
|
||||
<div className="w-full px-2">
|
||||
<button
|
||||
onClick={handleClick}
|
||||
onClick={() => createOrder("yeepay_wxpay_h5")}
|
||||
className="flex flex-row h-12 w-full items-center justify-center bg-primary rounded-full py-2"
|
||||
>
|
||||
<svg viewBox="0 0 1228 1024" width="18" height="18">
|
||||
|
|
Loading…
Reference in New Issue