绑定电话
This commit is contained in:
parent
9b1d9206d2
commit
d542525986
@ -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<HTMLFormElement>(null);
|
||||
// const formRef = useRef<HTMLFormElement>(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}秒后重试
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@ -2086,7 +2112,7 @@ export default function Head() {
|
||||
|
||||
|
||||
|
||||
<div style={{
|
||||
{/* <div style={{
|
||||
display: 'none'
|
||||
}}>
|
||||
<form ref={formRef}
|
||||
@ -2095,9 +2121,9 @@ export default function Head() {
|
||||
<input name="userId" defaultValue={userId} />
|
||||
<input name="phone" defaultValue={form.getFieldValue('phone') || ''} />
|
||||
<input name="smsCode" defaultValue={form.getFieldValue('smsCode') || ''} />
|
||||
{/* <input name="errorRedirectUrl" defaultValue={encodeURI(currentUrl)} /> */}
|
||||
<input name="errorRedirectUrl" defaultValue={encodeURI(currentUrl)} />
|
||||
</form>
|
||||
</div>
|
||||
</div> */}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -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)
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -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 = '';
|
||||
|
Loading…
Reference in New Issue
Block a user