From 806e81e3a59c1d5bf578db3ce9358a87412ab1f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Thu, 25 Jul 2019 16:17:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modules/user/FindPasswordComponent.js | 94 ++++++++++++++----- .../modules/user/LoginRegisterComponent.js | 74 +++++++++++++-- 2 files changed, 139 insertions(+), 29 deletions(-) diff --git a/public/react/src/modules/user/FindPasswordComponent.js b/public/react/src/modules/user/FindPasswordComponent.js index 0c3678776..6317c5134 100644 --- a/public/react/src/modules/user/FindPasswordComponent.js +++ b/public/react/src/modules/user/FindPasswordComponent.js @@ -94,14 +94,14 @@ class LoginRegisterComponent extends Component { } //倒计时 getverificationcode = () => { - + debugger if(this.state.login === undefined || this.state.login.length===0){ this.openNotification("请输入手机号或邮箱"); return; } //这是判断是否手机正确 - if(this.state.Phonenumberisnotcobool === true){ + if(this.state.Phonenumberisnotcobool === false){ this.openNotification(this.state.Phonenumberisnotco); this.setState({ Whethertoverify:this.state.Whethertoverify===true?false:true, @@ -109,7 +109,7 @@ class LoginRegisterComponent extends Component { return; } //拖动滑动验证 - if(this.state.dragOk===undefined||this.state.dragOk === false){ + if(this.state.dragOk === false){ this.openNotification("拖动滑块验证"); return; } @@ -180,12 +180,11 @@ class LoginRegisterComponent extends Component { //找回密码 Retrievepassword = () => { if (this.state.Phonenumberisnotcobool === false) { - if (this.state.login.length === 0) { - this.setState({ - Phonenumberisnotco:"请输入正确的邮箱或手机号", - }) - return - } + this.openNotification(this.state.Phonenumberisnotco); + this.setState({ + Whethertoverify:this.state.Whethertoverify===true?false:true, + }) + return; } if (this.state.login === undefined|| this.state.login.length ===0 || this.state.login === "") { this.setState({ @@ -365,7 +364,7 @@ class LoginRegisterComponent extends Component { if (value.length === 0) { this.setState({ Phonenumberisnotco: undefined, - Phonenumberisnotcobool: false, + Phonenumberisnotcobool: true, }) return; } @@ -418,20 +417,20 @@ class LoginRegisterComponent extends Component { if(this.state.login===""||this.state.login.length===0){ this.setState({ Phonenumberisnotco: "账号不能为空", - Phonenumberisnotcobool: true, + Phonenumberisnotcobool: false, dragOk:false, Whethertoverify:this.state.Whethertoverify===true?false:true, }) return } - console.log(e.target.value.length); - if (e.target.value.length === 0) { - this.setState({ - Phonenumberisnotco: undefined, - Phonenumberisnotcobool: false, - }) - return; - } + // console.log(e.target.value.length); + // if (e.target.value.length === 0) { + // this.setState({ + // Phonenumberisnotco: undefined, + // Phonenumberisnotcobool: false, + // }) + // return; + // } // var telephone = $("#telephoneAdd.tianjia_phone").val(); var regph = /^[1][3,4,5,6,7,8][0-9]{9}$/; // var email = $("#add_email.tianjia_email").val(); @@ -485,12 +484,63 @@ class LoginRegisterComponent extends Component { if (this.state.login === "" || this.state.login.length === 0) { this.setState({ Phonenumberisnotco: "账号不能为空", - Phonenumberisnotcobool: true, + Phonenumberisnotcobool: false, dragOk: false, Whethertoverify: this.state.Whethertoverify === true ? false : true, }) return } + // var telephone = $("#telephoneAdd.tianjia_phone").val(); + var regph = /^[1][3,4,5,6,7,8][0-9]{9}$/; + // var email = $("#add_email.tianjia_email").val(); + var regemail = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/; + + // [1]手机号开头必须是1 [3,4,5,6,7,8] 第二位是3-8中的一个 [0-9]{9} 后边9位可以是0-9的任意数字。 + var stringdata = undefined; + if (!regph.test(this.state.login)) { + stringdata = "手机号格式不正确"; + this.setState({ + Phonenumberisnotco: stringdata, + Phonenumberisnotcobool: false, + dragOk:false, + Whethertoverify: this.state.Whethertoverify === true ? false : true, + }) + } else { + this.setState({ + Phonenumberisnotco: undefined, + Phonenumberisnotcobool: true, + dragOk: true, + + }); + this.Emailphonenumberverification(this.state.login) + + return + } + + if (!regemail.test(this.state.login)) { + if ((this.state.login.indexOf("@") != -1) === true) { + stringdata = "邮箱格式不正确"; + } else { + stringdata = "手机号格式不正确"; + + } + this.setState({ + Phonenumberisnotco: stringdata, + Phonenumberisnotcobool: false, + dragOk:false, + Whethertoverify: this.state.Whethertoverify === true ? false : true, + }) + return + } else { + this.setState({ + Phonenumberisnotco: undefined, + Phonenumberisnotcobool: true, + dragOk: true, + }) + this.Emailphonenumberverification(this.state.login) + return + } + this.setState({ Phonenumberisnotcosytdhk: undefined, }) @@ -513,7 +563,7 @@ class LoginRegisterComponent extends Component { console.log(value.length); this.setState({ Phonenumberisnotco: result.data.message, - Phonenumberisnotcobool: true, + Phonenumberisnotcobool: false, dragOk:false, Whethertoverify:this.state.Whethertoverify===true?false:true, }) @@ -521,7 +571,7 @@ class LoginRegisterComponent extends Component { }else { this.setState({ Phonenumberisnotco: undefined, - Phonenumberisnotcobool: false, + Phonenumberisnotcobool: true, dragOk:true, }) return; diff --git a/public/react/src/modules/user/LoginRegisterComponent.js b/public/react/src/modules/user/LoginRegisterComponent.js index f6c32909d..241fc2c6f 100644 --- a/public/react/src/modules/user/LoginRegisterComponent.js +++ b/public/react/src/modules/user/LoginRegisterComponent.js @@ -206,7 +206,65 @@ class LoginRegisterComponent extends Component { } //是否验证通过 dragOkCallback = () => { - console.log(this.state.logins); + debugger + if (this.state.logins.length === 0) { + this.setState({ + Phonenumberisnotcos: undefined, + Phonenumberisnotcobool: false, + dragOk:true, + + }) + return; + } + // var telephone = $("#telephoneAdd.tianjia_phone").val(); + var regph = /^[1][3,4,5,6,7,8][0-9]{9}$/; + // var email = $("#add_email.tianjia_email").val(); + var regemail = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/; + + // [1]手机号开头必须是1 [3,4,5,6,7,8] 第二位是3-8中的一个 [0-9]{9} 后边9位可以是0-9的任意数字。 + var stringdata = undefined; + if (!regph.test(this.state.logins)) { + stringdata = "手机号格式不正确"; + this.setState({ + Phonenumberisnotcos: stringdata, + Phonenumberisnotcobool: true, + dragOk:false, + Whethertoverify:this.state.Whethertoverify===true?false:true, + }) + } else { + this.setState({ + Phonenumberisnotcos: undefined, + Phonenumberisnotcobool: false, + dragOk:true, + }); + this.Emailphonenumberverification(this.state.logins, 2); + return + } + + if (!regemail.test(this.state.logins)) { + if ((this.state.logins.indexOf("@") != -1) === true) { + stringdata = "邮箱格式不正确"; + } else { + stringdata = "手机号格式不正确"; + + } + this.setState({ + Phonenumberisnotcos: stringdata, + Phonenumberisnotcobool: true, + dragOk:false, + Whethertoverify:this.state.Whethertoverify===true?false:true, + }) + return + } else { + this.setState({ + Phonenumberisnotcos: undefined, + Phonenumberisnotcobool: false, + dragOk:true, + }) + this.Emailphonenumberverification(this.state.logins, 2); + return + } + this.setState({ Phonenumberisnotcosytdhk:undefined, }) @@ -416,7 +474,6 @@ class LoginRegisterComponent extends Component { Phonenumberisnotco: undefined, Phonenumberisnotcobool: false, dragOk:true, - }) }else { this.setState({ @@ -426,7 +483,7 @@ class LoginRegisterComponent extends Component { Whethertoverify:this.state.Whethertoverify===true?false:true, }) } - return; + return; } else if (id === 2) { this.setState({ Phonenumberisnotcos: result.data.message, @@ -499,8 +556,9 @@ class LoginRegisterComponent extends Component { //倒计时 getverificationcode = () => { - console.log(this.state.Phonenumberisnotcobool); - console.log(this.state.dragOk); + debugger + // console.log(this.state.Phonenumberisnotcobool); + // console.log(this.state.dragOk); if(this.state.logins === undefined || this.state.logins.length===0){ this.openNotification("请输入手机号或邮箱"); return; @@ -513,7 +571,7 @@ class LoginRegisterComponent extends Component { }) return; } - if(this.state.dragOk===undefined||this.state.dragOk === false){ + if(this.state.dragOk === false){ this.openNotification("拖动滑块验证"); return; } @@ -669,6 +727,7 @@ class LoginRegisterComponent extends Component { this.setState({ Phonenumberisnotcos: undefined, Phonenumberisnotcobool: false, + }) return } @@ -691,6 +750,7 @@ class LoginRegisterComponent extends Component { this.setState({ Phonenumberisnotcos: undefined, Phonenumberisnotcobool: false, + }) this.Emailphonenumberverification(e.target.value, id); return @@ -943,7 +1003,7 @@ class LoginRegisterComponent extends Component { { Whethertoverify===false&&pciphone===true? :