diff --git a/src/assets/api.js b/src/assets/api.js index c67f8b70..d81763a7 100644 --- a/src/assets/api.js +++ b/src/assets/api.js @@ -633,9 +633,10 @@ export const getVerify = (params) => { export const getUserinfo= (params) => { return req('get', baseurl + "/auth/admin/userinfo",params) } - - - +//设置登录密码 +export const putmodifySelf = (data) => { + return req('put', baseurl + "/auth/admin/setPassword",data) +} diff --git a/src/pages/distributor/adddistributorinfo/adddistributorinfo.less b/src/pages/distributor/adddistributorinfo/adddistributorinfo.less index c409f38d..5885280c 100644 --- a/src/pages/distributor/adddistributorinfo/adddistributorinfo.less +++ b/src/pages/distributor/adddistributorinfo/adddistributorinfo.less @@ -1,5 +1,5 @@ .zent-form-horizontal[data-zv="9.11.0"] .zent-form-label { - flex-basis: 110px!important; + flex-basis: 118px!important; justify-content: flex-start!important; } .zent-form-horizontal[data-zv="9.11.0"] .zent-form-control-content{ diff --git a/src/pages/home/ModifySelfpwd.js b/src/pages/home/ModifySelfpwd.js new file mode 100644 index 00000000..33cf019d --- /dev/null +++ b/src/pages/home/ModifySelfpwd.js @@ -0,0 +1,115 @@ +import ReactDOM from 'react-dom'; +import React, { Component } from 'react'; +import { + Form, + FormStrategy, + Notify, + Validators, + FormInputField, + Button, + Icon +} from 'zent'; +import {putmodifySelf,handelResponse} from "../../assets/api.js" +import "../../assets/comm.css" +import './modifySelf.less' +import _ from "lodash" +function equalsPassword(value, ctx) { + if (value !== ctx.getSectionValue('password').password) { + return { + name: 'passwordEqual', + message: '两次填写的密码不一致', + }; + } + return null; +} + +const Modifypwd=(props)=>{ + const form = Form.useForm(FormStrategy.View); + const [pwdType, setPwdType] = React.useState('password') + const [repwdType, setRePwdType] = React.useState('password') + + const onSubmit = React.useCallback(form => { + const value = form.getValue(); + if(value){ + let data=_.cloneDeep(value); + let parmas={ + password:data.password + } + putmodifySelf(parmas).then(res=>{ + handelResponse(res,(response,msg)=>{ + Notify.clear(); + Notify.success(msg); + setTimeout(()=>{ + window.location.href='/login'; + sessionStorage.clear(); + },2000); + },err=>{ + Notify.clear(); + Notify.error(res.data.message); + }); + }).catch(err=>{ + + }); + } + }, []); + const cancelFn=()=>{ + props.visibleShow(false); + } + const changepwdType=()=>{ + if(pwdType=='password'){ + setPwdType('text'); + }else{ + setPwdType('password'); + } + } + const rechangepwdType=()=>{ + if(repwdType=='password'){ + setRePwdType('text'); + }else{ + setRePwdType('password'); + } + } + + return ( +
+ } + helpDesc='' + validators={[ + Validators.required('请输入新密码'), + Validators.pattern(/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/, '6-16位字符,数字+字母组成,(字母区分大小写)'), + ]} + notice="6-16位字符,数字+字母组成,字母(区分大小写)" + props={{ + type: pwdType=='password'?'password':'text',maxLength:16,autoComplete:'new-password' + }} + /> + } + validators={[ Validators.required('请确认密码'),equalsPassword]} + props={{ + type:repwdType=='password'?'password':'text',maxLength:16,autoComplete:'new-password' + }} + /> +

+ , + +

+ + ); +} +export default Modifypwd; \ No newline at end of file diff --git a/src/pages/home/home.js b/src/pages/home/home.js index 48bab504..516d9b0f 100644 --- a/src/pages/home/home.js +++ b/src/pages/home/home.js @@ -7,7 +7,7 @@ import { HashRouter as Router, Route, Link, - + Redirect } from "react-router-dom"; import "./home.less" @@ -18,9 +18,12 @@ import { Avatar, Pop, Sweetalert, + Dialog, Icon, - Notify + Notify, + Button } from 'zent'; +import ModifySelfpwd from './ModifySelfpwd' import extension from '../extension/main/main'; import overview from '../overview/main/main'; import newplan from '../newplan/main'; @@ -82,6 +85,7 @@ export default class App extends Component { } state = { + visible:false, isShowSub:true, noShowSubMenu:["/home/extension","/home/overview","/home/plan-create","/home/mytempMould","/home/edittemplate"], pathname:'', @@ -163,6 +167,15 @@ export default class App extends Component { }) }).catch(err=>{ }); + } + //修改密码 + modifyFn(){ + this.setState({visible:true}); + + } + //修改密码 + modifyPwdFn(){ + } //退出登录 exitFn(){ @@ -193,7 +206,9 @@ export default class App extends Component { }); } - + setVisible = visible => { + this.setState({ visible }); + }; componentWillMount(e){ let activeMenuList=JSON.parse(sessionStorage.getItem('activeMenu')); this.setState({'navlist':activeMenuList}); @@ -298,13 +313,28 @@ export default class App extends Component {

-

{this.exitFn()}} className="exit-btn">退出

+

+ {this.exitFn()}} className="exit-btn">退出 + {this.modifyFn()}} className="modify-btn">修改密码 +

+ }> {/* */}
{this.state.userInfo.real_name} 
+ this.setVisible(false)} + title="修改密码" + > + this.setVisible(visible) }/> +
+ +
+