2024-01-03 01:07:16 +08:00
|
|
|
|
"use client";
|
|
|
|
|
import React, { useState, useEffect } from "react";
|
|
|
|
|
import { useSearchParams } from "next/navigation";
|
|
|
|
|
import { setCookie, getCookie } from "cookies-next";
|
|
|
|
|
import { useRouter } from "next/navigation";
|
|
|
|
|
import baseRequest from "@/utils/baseRequest";
|
|
|
|
|
import { Toast } from "antd-mobile";
|
|
|
|
|
import { generateSignature } from "@/utils/crypto";
|
|
|
|
|
|
|
|
|
|
export default function WithDrawal() {
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
const searchParams = useSearchParams();
|
|
|
|
|
const mid = searchParams.get("mid");
|
|
|
|
|
const token = searchParams.get("token");
|
|
|
|
|
const mobile_phone = searchParams.get("mobile_phone");
|
|
|
|
|
|
|
|
|
|
//将searchParams中的mid和token写入cookie,并重定向到没有searchParams的路由
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (mid && token && mobile_phone) {
|
|
|
|
|
setCookie("mid", mid);
|
|
|
|
|
setCookie("token", token);
|
|
|
|
|
setCookie("mobile_phone", mobile_phone);
|
|
|
|
|
router.replace("/withdrawal");
|
|
|
|
|
}
|
|
|
|
|
}, [mid, token, mobile_phone]);
|
|
|
|
|
|
2024-06-25 17:38:49 +08:00
|
|
|
|
//查看主播实名认证情况和可提现数额
|
2024-01-03 01:07:16 +08:00
|
|
|
|
const [data, setData] = useState({});
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const getData = async () => {
|
|
|
|
|
const mid = getCookie("mid");
|
|
|
|
|
if (!mid) return;
|
|
|
|
|
try {
|
|
|
|
|
const base = baseRequest();
|
2024-06-25 17:38:49 +08:00
|
|
|
|
const body = {
|
2024-01-03 01:07:16 +08:00
|
|
|
|
...base,
|
2024-06-25 17:38:49 +08:00
|
|
|
|
};
|
|
|
|
|
const signature = generateSignature(body);
|
2024-01-03 01:07:16 +08:00
|
|
|
|
const verificationResponse = await fetch(
|
2024-06-25 17:38:49 +08:00
|
|
|
|
`/api/hvyogo/query_agree_state?signature=${signature}`,
|
2024-01-03 01:07:16 +08:00
|
|
|
|
{
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
},
|
2024-06-25 17:38:49 +08:00
|
|
|
|
body: JSON.stringify(body),
|
2024-01-03 01:07:16 +08:00
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
const verificationData = await verificationResponse.json();
|
|
|
|
|
if (verificationData.ret === -1) {
|
|
|
|
|
Toast.show({
|
|
|
|
|
content: verificationData.msg,
|
|
|
|
|
});
|
2024-01-08 22:26:35 +08:00
|
|
|
|
}
|
|
|
|
|
const signature2 = generateSignature({
|
|
|
|
|
...base,
|
|
|
|
|
});
|
|
|
|
|
const withdrawalResponse = await fetch(
|
|
|
|
|
`/api/vas/withdraw_page?signature=${signature2}`,
|
|
|
|
|
{
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify({
|
|
|
|
|
...base,
|
|
|
|
|
}),
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
const withdrawalData = await withdrawalResponse.json();
|
|
|
|
|
if (withdrawalData.ret === -1) {
|
|
|
|
|
Toast.show({
|
|
|
|
|
content: withdrawalData.msg,
|
|
|
|
|
});
|
2024-01-03 01:07:16 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
setData({
|
2024-06-25 17:38:49 +08:00
|
|
|
|
verificationStatus: verificationData.data?.agree_state,
|
2024-01-08 22:26:35 +08:00
|
|
|
|
withdrawal_diamond: withdrawalData.data.withdraw_diamonds,
|
2024-06-28 23:14:36 +08:00
|
|
|
|
diamonds: withdrawalData.data.diamonds,
|
2024-01-03 01:07:16 +08:00
|
|
|
|
});
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(error);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
getData();
|
|
|
|
|
}, []);
|
|
|
|
|
|
2024-06-25 17:38:49 +08:00
|
|
|
|
//跳转实名认证
|
|
|
|
|
const handleVerify = () => {
|
|
|
|
|
const token = getCookie("token");
|
2024-06-28 23:14:36 +08:00
|
|
|
|
const huiYongGongUrl = `https://h5-channel.hvyogo.com/?channel=CDLX&token=${token}`;
|
2024-06-25 17:38:49 +08:00
|
|
|
|
router.push(huiYongGongUrl);
|
2024-01-03 01:07:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<section className="container flex flex-col flex-1 p-4">
|
2024-06-25 17:38:49 +08:00
|
|
|
|
<div className="flex flex-row justify-between items-center bg-[#FFFFFF1A] rounded-2xl p-4">
|
|
|
|
|
<p className="text-secondary text-base font-medium">
|
|
|
|
|
可提现钻石:
|
|
|
|
|
<span className="text-white text-xl font-medium">
|
2024-01-03 01:07:16 +08:00
|
|
|
|
{data?.withdrawal_diamond}
|
2024-06-25 17:38:49 +08:00
|
|
|
|
</span>
|
2024-01-03 01:07:16 +08:00
|
|
|
|
</p>
|
2024-06-25 17:38:49 +08:00
|
|
|
|
{data?.verificationStatus === 2 ? (
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => router.push("/withdrawal/checkout")}
|
|
|
|
|
className="btn btn-sm btn-primary text-white rounded-full"
|
|
|
|
|
>
|
|
|
|
|
提现
|
|
|
|
|
</button>
|
|
|
|
|
) : (
|
2024-01-03 01:07:16 +08:00
|
|
|
|
<button
|
2024-06-25 17:38:49 +08:00
|
|
|
|
onClick={handleVerify}
|
|
|
|
|
className="btn btn-sm btn-primary text-white rounded-full"
|
2024-01-03 01:07:16 +08:00
|
|
|
|
>
|
2024-06-25 17:38:49 +08:00
|
|
|
|
实名认证
|
2024-01-03 01:07:16 +08:00
|
|
|
|
</button>
|
2024-06-25 17:38:49 +08:00
|
|
|
|
)}
|
2024-01-03 01:07:16 +08:00
|
|
|
|
</div>
|
2024-06-25 17:38:49 +08:00
|
|
|
|
<div className="flex flex-row justify-between items-center bg-[#FFFFFF1A] rounded-2xl p-4 my-4">
|
|
|
|
|
<p className="text-secondary text-base font-medium">
|
|
|
|
|
钻石总额:
|
2024-06-28 23:14:36 +08:00
|
|
|
|
<span className="text-white text-xl font-medium">
|
|
|
|
|
{data?.diamonds}
|
|
|
|
|
</span>
|
2024-06-25 17:38:49 +08:00
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
<p className="text-secondary text-base mt-2">注意事项:</p>
|
|
|
|
|
<p className="text-secondary text-sm">
|
|
|
|
|
1.需实名认证并绑定收款方式后方可提现;
|
|
|
|
|
</p>
|
|
|
|
|
<p className="text-secondary text-sm">
|
|
|
|
|
2.平台将收取提现金额的3%作为提现手续费用,该笔费用将用于为收款人缴纳相关税费;
|
2024-01-03 01:07:16 +08:00
|
|
|
|
</p>
|
2024-06-25 17:38:49 +08:00
|
|
|
|
<p className="text-secondary text-sm">
|
|
|
|
|
3.收款账户需与实名认证本人保持一致;
|
2024-01-03 01:07:16 +08:00
|
|
|
|
</p>
|
2024-06-25 17:38:49 +08:00
|
|
|
|
<p className="text-secondary text-sm">
|
|
|
|
|
4.单笔最低提现金额为100元(即1,000钻石),单月最高提现金额为95,000元(即950,000钻石);
|
2024-01-03 01:07:16 +08:00
|
|
|
|
</p>
|
2024-06-25 17:38:49 +08:00
|
|
|
|
<p className="text-secondary text-sm">
|
|
|
|
|
5.自助提现渠道每日只能提现一次,若有更多提现需求,请联系客服。
|
2024-01-03 01:07:16 +08:00
|
|
|
|
</p>
|
|
|
|
|
</section>
|
|
|
|
|
);
|
|
|
|
|
}
|