project_pack
杨树林 5 years ago
parent 3663314fc8
commit 34c3396f14

@ -14,7 +14,9 @@ class PackageIndexNEIBannerConcent extends Component {
super(props)
this.contentMdRef = React.createRef();
this.state = {
modalCancel:false
modalCancel:false,
getverificationcodes:true,
seconds:35,
}
}
@ -22,7 +24,76 @@ class PackageIndexNEIBannerConcent extends Component {
}
//获取验证码;
getverificationcode =()=>{
// if (this.state.logins&&this.state.logins.length === 0) {
// // 判断没有输入手机号
// return
// }
if(this.state.getverificationcodes === undefined){
console.log("undefined");
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);
//
// })
}
setclick=()=>{
const mdContnet = this.contentMdRef.current.getValue().trim();
console.log(mdContnet)
@ -52,7 +123,7 @@ class PackageIndexNEIBannerConcent extends Component {
render() {
let {modalCancel}=this.state;
let {modalCancel,seconds,getverificationcodes}=this.state;
return (
<div className="mb20">
<PhoneModel
@ -221,7 +292,9 @@ class PackageIndexNEIBannerConcent extends Component {
style={{ width: 300 }}
className="fafas"
placeholder="请输入验证码"
enterButton={<span>获取验证码</span>}
enterButton={
getverificationcodes === undefined ? <span>重新发送 ({seconds}s)</span>: getverificationcodes === true ?<span ></span> :<span ></span>}
onSearch={()=>this.getverificationcode()}
/>
</span>
<span>

@ -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>

Loading…
Cancel
Save