增加初始化密码操作页面

This commit is contained in:
guotao 2021-06-22 10:17:17 +08:00
parent 5e1495e71f
commit b886a73f39
1 changed files with 126 additions and 9 deletions

View File

@ -2,9 +2,32 @@ import React, { Component } from 'react';
import { BrowserRouter as Router, Route, Link } from "react-router-dom";
import { Spin } from 'antd';
import {notification, Spin} from 'antd';
import axios from 'axios';
import Dialog from "material-ui/Dialog";
class Otherloginxc extends Component {
constructor() {
super();
this.state = {
needChangePassword: false,
pass: "",
repass: "",
message: ""
};
this.changeBtnClick = this.changeBtnClick.bind(this);
this.handlePassChange = this.handlePassChange.bind(this);
this.handleRePassChange = this.handleRePassChange.bind(this);
}
handlePassChange(event) {
this.setState({pass: event.target.value});
}
handleRePassChange(event) {
this.setState({repass: event.target.value});
}
componentDidMount() {
debugger
@ -22,8 +45,9 @@ class Otherloginxc extends Component {
}}).then((result)=> {
if(result){
if(result.data.status===0){
window.location.href=`/`;
} else if(result.data.status===10001) {
this.setState({needChangePassword:true})
}
}
}).catch((error)=>{
@ -32,20 +56,113 @@ class Otherloginxc extends Component {
}
}
openNotification = (messge) => {
notification.open({
message: "提示",
description:
messge,
onClick: () => {
console.log('Notification Clicked!');
},
});
}
changeBtnClick() {
if (this.state.pass === undefined || this.state.pass.length ===0 || this.state.pass === "") {
this.openNotification("密码不能为空");
}
if (this.state.repass === undefined || this.state.repass.length ===0 || this.state.repass === "") {
this.openNotification("二次密码不能为空");
return
}
if (this.state.pass !== this.state.repass==="") {
this.openNotification(`两次输入的密码不一致`);
return
}
else if (this.state.pass !==undefined&&this.state.pass.length>0&&this.state.pass.length<8){
this.openNotification("密码不能少于8位");
return
} else if (this.state.pass !==undefined&&this.state.pass.length>0&&this.state.pass.length>16){
this.openNotification("密码不能超过16位");
return
}
else if (this.state.repass !==undefined&&this.state.repass.length>0&&this.state.repass.length<8){
this.openNotification("二次密码不能少于8位");
return
} else if (this.state.repass !==undefined&&this.state.repass.length>0&&this.state.repass.length>16){
this.openNotification("二次密码不能超过16位");
return
}
var url = "/auth/ccyun/init.json";
axios.post(url, {
pass: this.state.pass,
repass: this.state.repass,
}).then((result) => {
if(result.data.status===0){
this.openNotification("密码初始化成功")
setInterval(function() {
window.location.href=`/`;
}, 500);
} else {
this.openNotification(result.data.message);
}
}).catch((error) => {
})
}
render() {
// Loading
let needChangePassword = this.state.needChangePassword;
return (
<div className="App" style={{minHeight: '800px',width:"100%"}}>
<style>
{
`
<div>
{
needChangePassword === false ?
<div className="App" style={{minHeight: '800px',width:"100%"}}>
<div>
<style>
{
`
.margintop{
margin-top:20%;
}
`
}
</style>
<Spin size="large" className={"margintop"}/>
}
</style>
<Spin size="large" className={"margintop"}/>
</div>
</div>
:
<div style={{minHeight: '800px',width:"100%",textAlign: "center"}}>
<div style={{width:"480px",display: "inline-block"}}>
<div style={{height: "3rem",lineHeight: "3rem",background: "#f1f8ff",
textAlign: "center",borderRadius: "4px 4px 0 0",fontSize: "1.6em",
borderBottom:" 1px solid #f0f0f0"}}>初始化仓库账号密码</div>
<input type="password" id="password_loggin_input"
name="pass"
className="input-100-45 mt5"
value={this.state.pass}
onChange={this.handlePassChange}
placeholder="请输入密码" />
<input type="password" id="password_loggin_input"
name="repass"
value={this.state.repass}
onChange={this.handleRePassChange}
className="input-100-45 mt5"
placeholder="请重复输入密码" />
<div className={"bluebutton edu-back-blue"}
style={{width:"100px",display:"inline-block"}}
onClick={this.changeBtnClick}>
确认修改
</div>
</div>
</div>
}
</div>
);
}