Commit 2dd8b0c3 by xuzhenghua

优化

parent 3d29968c
...@@ -71,6 +71,21 @@ class Login extends Component { ...@@ -71,6 +71,21 @@ class Login extends Component {
history.push('/passport/student-login') history.push('/passport/student-login')
} }
componentDidMount() {
const {location} = this.props
const {action} = this.props.history
let pathname = location.state && location.state.from && location.state.from.pathname
let search = location.state && location.state.from && location.state.from.search
console.log(action,pathname,search);
if(action !== 'POP'){
let historyUrl = `${pathname}${search}`
window.localStorage.setItem('HistoryUrl',historyUrl)
}
}
render() { render() {
const { const {
loginWays, loginWays,
...@@ -122,7 +137,7 @@ class Login extends Component { ...@@ -122,7 +137,7 @@ class Login extends Component {
onVerify={this.onVerify} onVerify={this.onVerify}
/> />
<LoginButton active={values.tel && values.veriCode && isEmpty(errors)}/> <LoginButton active={values.tel && values.veriCode && isEmpty(errors)}/>
{/* 助学计划 */} {/* 助学计划 */}
<div className="student-root"> <div className="student-root">
<a className="student-root__button" onClick={this.toStudentRegister}>助学计划</a> <a className="student-root__button" onClick={this.toStudentRegister}>助学计划</a>
......
...@@ -15,6 +15,35 @@ import { connect } from "react-redux" ...@@ -15,6 +15,35 @@ import { connect } from "react-redux"
import { setCurrentUser } from '@/store/userAction' import { setCurrentUser } from '@/store/userAction'
class SetPassword extends Component { class SetPassword extends Component {
toFrom = () => {
let historyUrl = window.localStorage.getItem('HistoryUrl')
const {history} = this.props
history.push(historyUrl)
// window.localStorage.removeItem('HistoryUrl')
return
}
//
// componentDidMount() {
// const {location} = this.props
// const {action} = this.props.history
// let pathname = location.state && location.state.from && location.state.from.pathname
// let search = location.state && location.state.from && location.state.from.search
//
// console.log(location);
// console.log(location.state);
// console.log(action,pathname,search);
//
// // if(action !== 'PUSH'){
// // let historyUrl = `${pathname}${search}`
// // window.localStorage.setItem('HistoryUrl',historyUrl)
// // }
//
// }
render() { render() {
let {values, errors, location} = this.props let {values, errors, location} = this.props
let {from} = location.state || {from: {pathname: '/'}} let {from} = location.state || {from: {pathname: '/'}}
...@@ -52,7 +81,7 @@ class SetPassword extends Component { ...@@ -52,7 +81,7 @@ class SetPassword extends Component {
</Form> </Form>
<div className="skip" <div className="skip"
style={{display: from && from.pathname.includes('forgot-password') ? 'none' : 'block'}}> style={{display: from && from.pathname.includes('forgot-password') ? 'none' : 'block'}}>
<Link replace to='/passport/account-login'>跳过</Link> <span onClick={this.toFrom}>跳过</span>
</div> </div>
</div> </div>
</> </>
...@@ -68,7 +97,6 @@ const formikConfig = { ...@@ -68,7 +97,6 @@ const formikConfig = {
} }
}, },
handleSubmit: (values, {props}) => { handleSubmit: (values, {props}) => {
const {location} = props const {location} = props
let from = location.state && location.state.records && location.state.records[location.state.records.length - 2] || {pathname: '/'} let from = location.state && location.state.records && location.state.records[location.state.records.length - 2] || {pathname: '/'}
...@@ -108,7 +136,7 @@ function forgotPasswordReset(values, props) { ...@@ -108,7 +136,7 @@ function forgotPasswordReset(values, props) {
if (res.data.errno == 200) { if (res.data.errno == 200) {
Toast.info('密码设置成功') Toast.info('密码设置成功')
setTimeout(function () { setTimeout(function () {
props.history.replace('/passport/account-login') props.history.replace('/passport/account-login')
}, 1000) }, 1000)
} else { } else {
Toast.info(res.data.msg, 2, null, false) Toast.info(res.data.msg, 2, null, false)
...@@ -117,7 +145,6 @@ function forgotPasswordReset(values, props) { ...@@ -117,7 +145,6 @@ function forgotPasswordReset(values, props) {
} }
function bindMobileSetPassword(values, props) { function bindMobileSetPassword(values, props) {
http.post(`${API['passport-api']}/bind_mobile/set_pwd_new`, { http.post(`${API['passport-api']}/bind_mobile/set_pwd_new`, {
uid: props.user.data.uid, uid: props.user.data.uid,
password: encrypt(values.password) password: encrypt(values.password)
...@@ -128,10 +155,21 @@ function bindMobileSetPassword(values, props) { ...@@ -128,10 +155,21 @@ function bindMobileSetPassword(values, props) {
Toast.info('密码设置成功') Toast.info('密码设置成功')
let from = location.state && location.state.from || {pathname: '/'} let from = location.state && location.state.from || {pathname: '/'}
let local_redirect_url = JSON.parse(window.localStorage.getItem('binding_redirect')) let local_redirect_url = JSON.parse(window.localStorage.getItem('binding_redirect'))
setTimeout(function () {
if (local_redirect_url) { // setTimeout(function () {
const {pathname, search, hash} = local_redirect_url // if (local_redirect_url) {
history.replace(pathname + search + hash) // const {pathname, search, hash} = local_redirect_url
// history.replace(pathname + search + hash)
// } else {
// history.replace(from.pathname)
// }
// }, 1000)
let HistoryUrl = window.localStorage.getItem('HistoryUrl')
setTimeout(()=> {
if (HistoryUrl) {
let historyUrl = window.localStorage.getItem('HistoryUrl')
props.history.push(historyUrl)
} else { } else {
history.replace(from.pathname) history.replace(from.pathname)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment