|
|
|
@ -1,14 +1,86 @@
|
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
import { Spin, Icon , Modal,Input,Button} from 'antd';
|
|
|
|
|
class PhoneModel extends Component {
|
|
|
|
|
//getverificationcodes 是否是重新发送或者是获取验证码
|
|
|
|
|
//多少秒
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
this.state = {
|
|
|
|
|
funmodalsType:false,
|
|
|
|
|
istype:false
|
|
|
|
|
istype:false,
|
|
|
|
|
getverificationcodes:true,
|
|
|
|
|
seconds:35,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//获取验证码
|
|
|
|
|
getverificationcode =()=>{
|
|
|
|
|
// if (this.state.logins&&this.state.logins.length === 0) {
|
|
|
|
|
// 判断没有输入手机号
|
|
|
|
|
// return
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
if (this.state.getverificationcodes === true) {
|
|
|
|
|
this.setState({
|
|
|
|
|
getverificationcodes: undefined,
|
|
|
|
|
})
|
|
|
|
|
let timer = setInterval(() => {
|
|
|
|
|
this.setState((preState) => ({
|
|
|
|
|
seconds: preState.seconds - 1,
|
|
|
|
|
}), () => {
|
|
|
|
|
if (this.state.seconds == 0) {
|
|
|
|
|
clearInterval(timer);
|
|
|
|
|
this.setState({
|
|
|
|
|
getverificationcodes: false,
|
|
|
|
|
seconds: 35,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}, 1000)
|
|
|
|
|
//其他的网络请求也可以
|
|
|
|
|
this.SMSverification();
|
|
|
|
|
} else {
|
|
|
|
|
this.setState({
|
|
|
|
|
getverificationcodes: undefined,
|
|
|
|
|
})
|
|
|
|
|
let timer = setInterval(() => {
|
|
|
|
|
this.setState((preState) => ({
|
|
|
|
|
seconds: preState.seconds - 1,
|
|
|
|
|
}), () => {
|
|
|
|
|
if (this.state.seconds == 0) {
|
|
|
|
|
clearInterval(timer);
|
|
|
|
|
this.setState({
|
|
|
|
|
getverificationcodes: false,
|
|
|
|
|
seconds: 35,
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}, 1000)
|
|
|
|
|
//其他的网络请求也可以
|
|
|
|
|
this.SMSverification();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//短信验证
|
|
|
|
|
SMSverification = () => {
|
|
|
|
|
// var url = `/accounts/get_verification_code.json`;
|
|
|
|
|
// axios.get((url), {
|
|
|
|
|
// params: {
|
|
|
|
|
// login: this.state.logins,
|
|
|
|
|
// type: 1,
|
|
|
|
|
// }
|
|
|
|
|
// }).then((result) => {
|
|
|
|
|
// //验证有问题{"status":1,"message":"success"}
|
|
|
|
|
// // console.log(result);
|
|
|
|
|
// this.openNotification("验证码已发送,请注意查收!",2);
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// }).catch((error) => {
|
|
|
|
|
// console.log(error);
|
|
|
|
|
//
|
|
|
|
|
// })
|
|
|
|
|
}
|
|
|
|
|
render() {
|
|
|
|
|
let{getverificationcodes,seconds} =this.state;
|
|
|
|
|
const antIcons = <Icon type="loading" style={{ fontSize: 24 }} spin />
|
|
|
|
|
return(
|
|
|
|
|
<Modal
|
|
|
|
@ -39,7 +111,15 @@ class PhoneModel extends Component {
|
|
|
|
|
placeholder="请输入验证码" />
|
|
|
|
|
</span>
|
|
|
|
|
<span>
|
|
|
|
|
<Button type="primary" className="defalutSubmitbtn ml10 defalutSubmitbtnmodels">获取验证码</Button>
|
|
|
|
|
{
|
|
|
|
|
getverificationcodes === undefined ?
|
|
|
|
|
<Button type="primary" className="defalutSubmitbtn ml10 defalutSubmitbtnmodels" >重新发送 ({seconds}s)</Button>
|
|
|
|
|
: getverificationcodes === true ?
|
|
|
|
|
<Button type="primary" className="defalutSubmitbtn ml10 defalutSubmitbtnmodels" onClick={() => this.getverificationcode()} >获取验证码</Button>
|
|
|
|
|
:
|
|
|
|
|
<Button type="primary" className="defalutSubmitbtn ml10 defalutSubmitbtnmodels" onClick={() => this.getverificationcode()} >重新发送</Button>
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
{/*<Button type="primary" className="defalutSubmitbtn ml10 defalutSubmitbtnmodels">重新发送()</Button>*/}
|
|
|
|
|
</span>
|
|
|
|
|
</span>
|
|
|
|
|