diff --git a/app/invite/[user_id]/page.jsx b/app/invite/[user_id]/page.jsx index 71f32c8..3374b1c 100644 --- a/app/invite/[user_id]/page.jsx +++ b/app/invite/[user_id]/page.jsx @@ -44,7 +44,7 @@ export default function Invite({ params }) { >

- 邀请功能1月8号开放,请耐心等待 + 邀请功能施工中,请等待开放。

); diff --git a/app/withdrawal/page.jsx b/app/withdrawal/page.jsx index 6dd357a..700e8f1 100644 --- a/app/withdrawal/page.jsx +++ b/app/withdrawal/page.jsx @@ -9,46 +9,9 @@ import baseRequest from "@/utils/baseRequest"; import Divider from "@/components/Divider"; import { Toast } from "antd-mobile"; import { generateSignature } from "@/utils/crypto"; +import { JSEncrypt } from "jsencrypt"; export default function WithDrawal() { - return ( -
- - - - - - - - - -

- 提现通道1月8号开放,请耐心等待 -

-
- ); - const router = useRouter(); const searchParams = useSearchParams(); const mid = searchParams.get("mid"); @@ -95,12 +58,33 @@ export default function WithDrawal() { Toast.show({ content: verificationData.msg, }); + } + 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, + }); return; } - //todo:查询账户可提现钻石数量 setData({ verificationStatus: - verificationData.data.realname_authentication_api_vo.status, + verificationData.data?.realname_authentication_api_vo?.status, + withdrawal_diamond: withdrawalData.data.withdraw_diamonds, }); } catch (error) { console.error(error); @@ -121,7 +105,7 @@ export default function WithDrawal() { //从cookie中读取mobile_phone并做脱敏处理 useEffect(() => { const mobilePhoneCache = getCookie("mobile_phone"); - const maskedNumber = mobilePhoneCache.replace( + const maskedNumber = mobilePhoneCache?.replace( /(\d{3})\d{4}(\d{4})/, "$1****$2" ); @@ -167,6 +151,24 @@ export default function WithDrawal() { const handleVerification = async () => { //开始倒计时 setIsCounting(true); + //发送短信验证码 + const base = baseRequest(); + const signature = generateSignature({ + ...base, + }); + try { + await fetch(`/api/vas/withdraw_send_verifycode?signature=${signature}`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + ...base, + }), + }); + } catch (error) { + console.error(error); + } }; //点击提交申请按钮 @@ -200,9 +202,51 @@ export default function WithDrawal() { //点击二次确认按钮 const [errorMessage, setErrorMessage] = useState(""); + const [isSubmitting, setIsSubmitting] = useState(false); const handleConfirm = async () => { - //todo:提交提现申请,如果出错则设置errorMessage,如果成功则跳转成功页面 - router.push("/withdrawal/success"); + try { + setIsSubmitting(true); + //对支付宝账号和真实姓名进行RSA加密 + const encrypt = new JSEncrypt(); + encrypt.setPublicKey(process.env.NEXT_PUBLIC_WITHDRAW_RSA_KEY); + const auth_alipay_id = encrypt.encrypt(alipayAccount); + const auth_alipay_name = encrypt.encrypt(payee); + const base = baseRequest(); + const signature = generateSignature({ + diamonds: parseInt(withdrawalNum, 10), + auth_alipay_id: auth_alipay_id, + auth_alipay_name: auth_alipay_name, + verify_code: veriCode, + ...base, + }); + const applyResponse = await fetch( + `/api/vas/withdraw_apply?signature=${signature}`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + diamonds: parseInt(withdrawalNum, 10), + auth_alipay_id: auth_alipay_id, + auth_alipay_name: auth_alipay_name, + verify_code: veriCode, + ...base, + }), + } + ); + const applyData = await applyResponse.json(); + if (applyData.ret === -1) { + setErrorMessage(applyData.msg); + setIsSubmitting(false); + return; + } + router.push("/withdrawal/success"); + } catch (error) { + console.error(error); + } finally { + setIsSubmitting(false); + } }; return ( @@ -350,7 +394,7 @@ export default function WithDrawal() { 3.单笔最低提现金额为200元(即2000钻石),若提现金额大于2000元(即20000钻石)请联系客服;

- 4.自助提现渠道每日提现上限为2000元(即20000钻石),若有更多提现需求,请联系客服。 + 4.自助提现渠道每日只能提现一次,若有更多提现需求,请联系客服。

@@ -371,10 +415,14 @@ export default function WithDrawal() { )}