Commit cc180c86 by zhangleyuan

feat:联调登录接口和发送验证码接口

parent 58a1fe9e
......@@ -5,6 +5,8 @@ import {
import './Login.less';
import {Input,Popover,message} from 'antd';
import CheckBeforeSendCode from '../../components/CheckBeforeSendCode';
import Service from "../../common/js/service"
import axios from 'axios';
function Login(props) {
const [phone, setPhone] = useState(''); // 登录手机号
const [phoneverify, setPhoneverify] = useState(''); // 密码登录验证码
......@@ -37,9 +39,25 @@ function Login(props) {
function handleSendSMSCode(checkData, userType) {
if (waitStatus) return;
let timer;
timeSub(60);
setChecking1(true)
// timeSub(60);
// setChecking1(true)
const params = {
phone: phone,
sig: checkData.sig,
sessionId: checkData.csessionid,
token: checkData.token,
scene: 'nc_login',
}
axios.post('https://dev-heimdall.xiaomai5.com/hades/anon/store/sendLoginAuthCode', params).then((res) => {
console.log('111',res.data.success);
if (!res.data.success) {
setErrorMessage(res.data.message);
} else {
console.log('111');
timeSub(60);
setChecking1(true)
}
})
function timeSub(waitTime, unit) {
clearTimeout(timer);
timer = setTimeout(function () {
......@@ -56,6 +74,27 @@ function Login(props) {
}, unit || 0);
}
}
function handleSubmit() {
if(!phoneverify){
setErrorMessage("请输入验证码");
return;
}
const params = {
phone,
authCode:phoneverify
}
axios.post('https://dev-heimdall.xiaomai5.com/hades/anon/store/login', params).then((res) => {
const data = res.data;
if (!data.success) {
setErrorMessage(data.message);
} else {
localStorage.setItem('userId',data.userId);
localStorage.setItem('xmToken',data.xmToken);
}
})
}
return (
<div className="login-page" >
<div className="login-main">
......@@ -70,7 +109,7 @@ function Login(props) {
<div className="title">
手机号登录
</div>
<form action="" className="login-form">
<div className="login-form">
<div className="form">
<div className="username" style={{ marginBottom: 16 }}>
<Input
......@@ -135,14 +174,14 @@ function Login(props) {
</div>
<div className="submit">
<div className="btn">
<button id='loginIn' type="submit">登录</button>
<button id='loginIn' onClick={ () => { handleSubmit() } }>登录</button>
</div>
</div>
<div className="network-message">
{/* <div className="network-message">
<span className="icon iconfont">&#xe834;</span>网络不给力,请<span className="refresh">点击刷新</span>
</div>
</div> */}
</div>
</form>
</div>
</div>
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment