diff --git a/src/modules/login/Otherloginxc.js b/src/modules/login/Otherloginxc.js index 3f28eeee..877310bb 100644 --- a/src/modules/login/Otherloginxc.js +++ b/src/modules/login/Otherloginxc.js @@ -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 ( -
- - + } + + +
+ + : +
+
+
初始化仓库账号密码
+ + +
+ 确认修改 +
+
+
+ } ); }