This commit is contained in:
caishi 2021-10-28 18:23:22 +08:00
parent 1c48ffb130
commit a93b8a08c9
2 changed files with 456 additions and 257 deletions

View File

@ -97,9 +97,9 @@ class EducoderLogin extends Component {
<div style={{cursor:"pointer"}}>
{
mygetHelmetapi && mygetHelmetapi.login_logo_url ?
<img style={{cursor:"pointer"}} alt="" onClick={()=>this.gohome()} width="80px" src={getImageUrl(mygetHelmetapi.login_logo_url)}/>
<img style={{cursor:"pointer"}} alt="" onClick={()=>this.gohome()} src={getImageUrl(mygetHelmetapi.login_logo_url)}/>
:
<img style={{cursor:"pointer"}} alt="" onClick={()=>this.gohome()} src={educodernet} width="80px"/>
<img style={{cursor:"pointer"}} alt="" onClick={()=>this.gohome()} src={educodernet}/>
}
</div>
{

View File

@ -25,7 +25,13 @@ class LoginRegisterComponent extends Component {
constructor(props) {
super(props)
//
// console.log("LoginRegisterComponent");
// console.log("29");
// console.log(props.loginstatus);
if(props.loginstatus === true){
// console.log(props.loginstatus);
this.state = {
tab:["0"],
classpass: "text",
@ -142,14 +148,24 @@ class LoginRegisterComponent extends Component {
this.setState({
isphone:flag
})
// console.log("componentDidUpdate");
// console.log(this.props);
let pcipns=this.IsPC();
if (this.props.match.url === "/login") {
// this.state = {
// tab:["0"],
//
// }
this.setState({
tab:["0"]
})
} else if (this.props.match.url === "/register") {
// this.state = {
// tab:["1"],
//
// }
this.setState({
tab:["1"]
})
@ -183,6 +199,8 @@ class LoginRegisterComponent extends Component {
StudyMakeMoney = () => { // 调用父组件方法
// this.props.Setlogins(3);
this.setState({
login: "",
password: "",
@ -383,6 +401,11 @@ class LoginRegisterComponent extends Component {
}
// if(response.data.profile_completed !== null || response.data.profile_completed === false){
// this.setMyEduCoderModals();
// return;
// }
if (response.status === 200) {
if (response.data.status === 402) {
window.location.href = response.data.url;
@ -413,6 +436,23 @@ class LoginRegisterComponent extends Component {
}
//注册接口
postregistered = () => {
// if (this.state.logins === undefined || this.state.logins === "") {
// this.openNotification(`请输入登录手机号码或邮箱`,2);
//
// return
// } else if (this.state.dragOk === false) {
// this.openNotification(`请拖动滑块验证`,2);
// return
// } else if (this.state.codes === undefined || this.state.codes == "") {
// this.openNotification(`请输入验证码`,2);
// return
// } else if (this.state.passwords === undefined || this.state.passwords == "") {
// this.openNotification(`请输入密码`,2);
// return
// } else if (this.state.Agreetotheterms === false) {
// this.openNotification(`请同意服务协议条款`,2);
// return;
// }
if (this.state.logins === undefined || this.state.logins === ""||this.state.logins.length===0) {
this.setState({
Phonenumberisnotcos:"账号不能为空",
@ -422,8 +462,25 @@ class LoginRegisterComponent extends Component {
})
return
}
if(this.state.pciphone===true){
if (this.state.dragOk === false) {
// this.openNotification(`请拖动滑块完成验证`,2);
this.setState({
Phonenumberisnotcosytdhk:"请拖动滑块完成验证",
dragOk:false,
Whethertoverify:this.state.Whethertoverify===true?false:true,
})
return
}
}
if (this.state.passwords === undefined || this.state.passwords == "" || this.state.passwords.length === 0) {
if (this.state.codes === undefined || this.state.codes == ""||this.state.codes.length===0) {
// this.openNotification(`请输入验证码`,2);
this.setState({
Phonenumberisnotcosyzm:"验证码不能为空",
})
return
} else if (this.state.passwords === undefined || this.state.passwords == "" ||this.state.passwords.length===0) {
this.setState({
Phonenumberisnotcosymmm:"密码不能为空",
})
@ -438,6 +495,9 @@ class LoginRegisterComponent extends Component {
Phonenumberisnotcosymmm:"密码不能超过16位",
})
return
} else if (this.state.Agreetotheterms === false) {
this.openNotification(`请同意服务协议条款`,2);
return;
}
let url;
@ -452,9 +512,34 @@ class LoginRegisterComponent extends Component {
password: this.state.passwords,
code: this.state.codes,
}).then((result) => {
if (result && result.data) {
this.openNotification("注册成功!");
this.props.history.push('/');
if(result){
if(result.data.status===-2){
if(result.data.message==="验证码不正确"){
this.setState({
Phonenumberisnotcosyzm:"验证码不正确",
})
return;
}else if(result.data.message==="验证码已失效"){
this.setState({
Phonenumberisnotcosyzm:"验证码不正确",
})
return;
}else {
this.openNotification(result.data.message);
return;
}
}else {
// this.setState({
// logins: "",
// dragOk: false,
// codes: "",
// passwords: "",
// Agreetotheterms: "",
// })
this.setMyEduCoderModals();
}
}
}).catch((error) => {
@ -674,9 +759,12 @@ class LoginRegisterComponent extends Component {
})
return;
}
// var telephone = $("#telephoneAdd.tianjia_phone").val();
var regph = /^[1][3,4,5,6,7,8,9][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(e.target.value)) {
stringdata = "手机号格式不正确";
@ -722,6 +810,7 @@ class LoginRegisterComponent extends Component {
}
//获取登入密码
passwordonChange = (e) => {
// console.log(e.target.value);
var stirngt;
if(e.target.value.length>0){
var str= e.target.value.replace(/\s*/g,"")
@ -734,6 +823,9 @@ class LoginRegisterComponent extends Component {
Phonenumberisnotcodmm:undefined,
Phonenumberisnotcodmms:undefined,
})
// this.setState({
// password: e.target.value
// })
}
//获取注册登入
loginInputonChanges = (e) => {
@ -790,6 +882,7 @@ class LoginRegisterComponent extends Component {
this.setState({
tab:e.key
})
if(e.key === 0){
this.setState({
Phonenumberisnotcos:undefined
@ -798,8 +891,26 @@ class LoginRegisterComponent extends Component {
this.setState({
Phonenumberisnotco:undefined
})
}
// this.props.history.push(`/classrooms/${this.props.match.params.coursesId}/exercises/${this.props.match.params.Id}/student_exercise_list?tab=`+e.key)
}
loginonkeyup =(e)=>{
if(e.keyCode==32){
return false;
}
};
setNotcompleteds=()=>{
this.setState({
Notcompleteds:true,
MyEduCoderModals:false,
registered:undefined,
})
};
setMyEduCoderModals=()=>{
this.setState({
MyEduCoderModals:true,
@ -807,10 +918,70 @@ class LoginRegisterComponent extends Component {
})
};
openweixinlogin=()=>{
this.setState({
weixinlogin:true
})
}
hideweixinlogin=()=>{
this.setState({
weixinlogin:false,
qqlogin:false,
tab:["0"]
})
}
openqqlogin=()=>{
this.setState({
qqlogin:true
})
//window.location.href=`https://graph.qq.com/oauth2.0/show?which=Login&display=pc&client_id=101508858&redirect_uri=https%3a%2f%2f${window.location.host}%2otherloginqq&response_type=code`
window.location.href=`https://graph.qq.com/oauth2.0/show?which=Login&display=pc&client_id=101508858&redirect_uri=https%3a%2f%2fwww.educoder.net%2fotherloginqq&state=null,${window.location.host}&response_type=code`
// window.location.href=`https://graph.qq.com/oauth2.0/show?which=Login&display=pc&client_id=101508858&redirect_uri=https%3a%2f%2fwww.educoder.net%2fotherloginstart&tp=qq&response_type=code`
}
openphoneqqlogin=()=>{
window.open(
`https://xui.ptlogin2.qq.com/cgi-bin/xlogin?appid=716027609&pt_3rd_aid=101508858&daid=383&pt_skey_valid=0&style=35&s_url=http%3A%2F%2Fconnect.qq.com&refer_cgi=authorize&which=&client_id=101508858&response_type=code&scope=get_user_info&redirect_uri=https%3a%2f%2fwww.educoder.net%2fotherloginqq&state=null,${window.location.host}&response_type=code`
)
}
render() {
const {passopens,Agreetotheterms,Phonenumberisnotcos,tab,classpassbool,Phonenumberisnotcosymmm} = this.state
const {
// 登录
autoLogin,
classpass,
passopens,
seconds,
getverificationcodes,
Agreetotheterms,
Phonenumberisnotco,
Phonenumberisnotcos,
codes,
tab,
dragOk,
Whethertoverify,
classpassbool,
Phonenumberisnotcosytdhk,
Phonenumberisnotcosyzm,
Phonenumberisnotcosymmm,
Phonenumberisnotcodmm,
// 注册
readAgreement,
pciphone,
Phonenumberisnotcodmms,
weixinlogin
} = this.state
// height: 346px;
if (this.state.seconds === 0) {
// window.location.href='http://www.cnblogs.com/a-cat/';
}
return (
<div className={"login_register_content login_register_contents"}>
<div className={this.props.weixinlogin?"weixinregister":"login_register_content login_register_contents"}
// style={ parseInt(tab[0])==0?{height: "366px"} :{height: "510px"}}
>
<style>
{
`
@ -823,26 +994,52 @@ class LoginRegisterComponent extends Component {
</style>
<div>
<Menu mode="horizontal" selectedKeys={tab} onClick={this.changeTab} className="mt20">
<Menu.Item key="1" className={"active font-18"} style={{ marginLeft: "10px" }} >注册</Menu.Item>
</Menu>
{weixinlogin===false&&this.props.weixinlogin===undefined?<Menu mode="horizontal" selectedKeys={tab} onClick={this.changeTab} className="mt20">
<Menu.Item key="0" className={tab===0?"active font-18":"font-18"} > 登录</Menu.Item>
<Menu.Item key="1" className={tab===1?"active font-18 ":"font-18 "} style={{marginLeft:"10px"}} >注册</Menu.Item>
</Menu>:""}
<div style={{ width: '340px' }}>
<Input placeholder="请输入邮箱账号进行注册"
className={Phonenumberisnotcos && Phonenumberisnotcos !== "" ? " color-grey-9 loginInputzhucheyslass bor-reds" : " color-grey-9 loginInputzhuche"}
value={this.state.logins}
type="text" autoComplete="off"
onChange={this.loginInputonChanges}
style={{ marginTop: '30px', height: '38px', color: '#999999', fontSize: "14px" }}></Input>
{
Phonenumberisnotcos && Phonenumberisnotcos !== "" ?
<p className="color-red mt5 mb5 " style={{ width: " 100%", height: "20px" }}>
<span className="fl" style={{ textAlign: "left", width: " 100%" }}>{Phonenumberisnotcos}</span>
</p>
: <div style={{ height: "25px" }}></div>
weixinlogin===false&&parseInt(tab[0])==0 &&
<div style={{width: '340px'}}>
<style>
{
`
.ant-input {
font-family: "Monospaced Number", "Chinese Quote", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
-webkit-box-sizing: border-box;
box-sizing: border-box;
margin: 0;
padding: 0;
list-style: none;
position: relative;
display: inline-block;
padding: 4px 11px;
width: 100%;
height: 38px;
font-size: 14px;
line-height: 1.5;
color: rgba(0, 0, 0, 0.65);
background-color: #fff;
background-image: none;
border: 1px solid #d9d9d9;
border-radius: 4px;
-webkit-transition: all .3s;
-o-transition: all .3s;
transition: all .3s;
}
.loginInputzhuche{
width: 100%;
background-color: #fff!important;
height: 45px !important;
padding: 5px;
}
`
}
</style>
<Input placeholder="请输入邮箱账号" value={this.state.login}
onChange={this.loginInputonChange}
name="username"
@ -898,6 +1095,7 @@ class LoginRegisterComponent extends Component {
</div>
</p>
</div>
}
@ -1080,3 +1278,4 @@ class LoginRegisterComponent extends Component {
}
export default (LoginRegisterComponent);