From d54252598666de3164663de234a19f0c1cbf7d0e Mon Sep 17 00:00:00 2001 From: lyp Date: Mon, 21 Apr 2025 15:45:45 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=91=E5=AE=9A=E7=94=B5=E8=AF=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/head/Head.tsx | 84 ++++++++++++++++++++++++++-------------- src/request/api.ts | 5 +++ src/util/AjaxUtils.ts | 2 +- 3 files changed, 61 insertions(+), 30 deletions(-) diff --git a/src/layout/head/Head.tsx b/src/layout/head/Head.tsx index 3353bd7..aa164af 100644 --- a/src/layout/head/Head.tsx +++ b/src/layout/head/Head.tsx @@ -7,8 +7,10 @@ import { } from 'react-redux' import { operatorBaseUrl } from '../../util/AjaxUtils.ts' import { - getCode, checkPhone, + getCode, + // checkPhone, // updatePhone + updateBindPhone } from '../../request/api' import BalanceHead from '../../components/balance/BalanceHead.tsx'; import RechargeHead from '../../components/recharge/RechargeHead.tsx'; @@ -115,7 +117,10 @@ interface DataType { // ]; import { DownOutlined, UserOutlined, QuestionCircleOutlined, BellOutlined, KeyOutlined, LogoutOutlined, GiftOutlined, AccountBookOutlined, ContainerOutlined, MenuFoldOutlined, UsergroupAddOutlined, TableOutlined } from "@ant-design/icons"; -import { useContext, useEffect, useState, useRef } from "react"; +import { + useContext, useEffect, useState, + // useRef +} from "react"; import { put, get, // post, @@ -145,7 +150,7 @@ import type { // import HeadCouponModal from '../../components/CouponModal/HeadCouponModal.tsx' export default function Head() { // const currentUrl = window.location.href; - const formRef = useRef(null); + // const formRef = useRef(null); // const triggerFormSubmit = () => { // if (formRef.current) { // formRef.current.submit(); @@ -213,30 +218,51 @@ export default function Head() { // }; const onFinish = async (values: any) => { // console.log('Success:', values); + // try { + // setPhoneLoading(true) + // const res = await checkPhone(values.phone) + // // const formData = new URLSearchParams(); + // // formData.append('userId', userId); + // // formData.append('phone', values.phone); + // // formData.append('smsCode', values.smsCode); + // // console.log('结果',res); + // if (res.data == 'SUCCESS') { + // // if (formRef.current) { + + // // // // 触发表单提交 + // // formRef.current.submit(); + // // // console.log(formRef.current); + // // } + + // } else { + // setPhoneLoading(false) + // messageApi.open({ + // type: 'error', + // content: '手机号已被绑定,请更换手机号', + // }); + // } + // // await submit(values.phone, values.smsCode) + // } catch (error: any) { + // setPhoneLoading(false) + // if (error.response) { + // const data = error.response.data; + // messageApi.open({ + // type: 'error', + // content: data.msg ? data.msg : `${data.path}(${data.status})`, + // }); + // } else { + // console.error(error) + // } + // } try { setPhoneLoading(true) - const res = await checkPhone(values.phone) - // const formData = new URLSearchParams(); - // formData.append('userId', userId); - // formData.append('phone', values.phone); - // formData.append('smsCode', values.smsCode); - // console.log('结果',res); - if (res.data == 'SUCCESS') { - if (formRef.current) { + const res: any = await updateBindPhone({ + newPhone: values.phone, + verificationCode: values.smsCode, + }) + // console.log(res); + window.location.href = `${operatorBaseUrl}/operator/oauth/wx/update/login?userId=${userId}&code=${res.data}` - // // 触发表单提交 - formRef.current.submit(); - // console.log(formRef.current); - } - - } else { - setPhoneLoading(false) - messageApi.open({ - type: 'error', - content: '手机号已被绑定,请更换手机号', - }); - } - // await submit(values.phone, values.smsCode) } catch (error: any) { setPhoneLoading(false) if (error.response) { @@ -259,7 +285,7 @@ export default function Head() { await form.validateFields(['phone']); setCountdown(120); - console.log('发送验证码'); + // console.log('发送验证码'); const timer = setInterval(() => { setCountdown((prevCountdown) => { if (prevCountdown > 0) { @@ -2049,7 +2075,7 @@ export default function Head() { }} > - 倒计时 {countdown} 秒 + {countdown}秒后重试 )} @@ -2086,7 +2112,7 @@ export default function Head() { -
- {/* */} +
-
+ */} diff --git a/src/request/api.ts b/src/request/api.ts index 73a67b9..80913a5 100644 --- a/src/request/api.ts +++ b/src/request/api.ts @@ -107,6 +107,11 @@ export const fillInputInfo = (orderId: string, params:any) => aiShopRequest.post export const getCode = (phone: number) => phoneRequest.get(`/operator/api/verify/code/send/${phone}`) // 验证手机号是否可用 export const checkPhone = (phone: number) => phoneRequest.get(`/operator/api/user-wx-update-username/check-phone/${phone}`) + // 更新手机号 export const updatePhone = (params:any) => newRequest.post(`/operator/oauth/wx/update/phone`, params) + +// 更新绑定手机号 +export const updateBindPhone = (params:any) => phoneRequest.post(`/operator/api/user-wx-update-username/update-phone`, params) + //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/src/util/AjaxUtils.ts b/src/util/AjaxUtils.ts index ae1de3e..e930d97 100644 --- a/src/util/AjaxUtils.ts +++ b/src/util/AjaxUtils.ts @@ -23,7 +23,7 @@ export const WebSocketBaseUrl: string = `ws://${host}:7025/copyright`; axios.defaults.baseURL = `${copyBaseUrl}/copyright`; // export const DevUserId: string = '80d3365e-0597-4988-979e-18ef1c3ec671'; // 18634604067 -export const DevUserId: string = 'ccb00bbe-a6cd-468a-a8e2-a6f39f6acccb'; +export const DevUserId: string = '77690f3e-ec2e-4417-b3af-25acc13c8ecb'; // export const DevUserId: string = '6fb8e783-243c-4eec-8d98-c9b1c8aeaa00'; // 15042810561 密码123456 // export const DevUserId: string = 'c2438eb8-2685-49a9-bf02-5111a5192d96'; // 18647109157 // export const DevUserId: string = '';