From ffbdae5c95bed6f3c4e354bb105bb34d54aac52d Mon Sep 17 00:00:00 2001
From: yezian
Date: Mon, 8 Jan 2024 22:26:35 +0800
Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E6=94=BE=E6=8F=90=E7=8E=B0=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=EF=BC=9B=E4=BF=AE=E6=94=B9=E9=82=80=E8=AF=B7=E5=88=86?=
=?UTF-8?q?=E6=88=90=E9=A1=B5=E9=9D=A2=E5=BE=85=E5=BC=80=E6=94=BE=E6=96=87?=
=?UTF-8?q?=E6=A1=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/invite/[user_id]/page.jsx | 2 +-
app/withdrawal/page.jsx | 138 +++++++++++++++++++++++-----------
2 files changed, 94 insertions(+), 46 deletions(-)
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.自助提现渠道每日只能提现一次,若有更多提现需求,请联系客服。