Commit 67ce51d8 by zhanghaozhe

Merge branch 'international-phone-number' into pre

# Conflicts:
#	src/components/passport/index.js
parents 7be9a9c7 18fc7851
import React, { Component } from 'react'
import React, {Component} from 'react'
import Routes from './router'
import cookie from 'js-cookie'
import { connect } from "react-redux";
import { setCurrentUser, startFetchUser } from "@/store/userAction";
import { withRouter } from 'react-router-dom'
import { compose } from 'redux'
import { getParam, http, browser } from "@/utils";
import { Toast } from "antd-mobile";
import { addDays } from 'date-fns'
import {connect} from "react-redux";
import {setCurrentUser, startFetchUser} from "@/store/userAction";
import {withRouter} from 'react-router-dom'
import {compose} from 'redux'
import {getParam, http, browser} from "@/utils";
import {Toast} from "antd-mobile";
import {addDays} from 'date-fns'
//拦截ajax请求,返回mock数据
......@@ -65,6 +65,7 @@ class App extends Component {
this.utm()
this.firstLoad = false
this.setNavigationRecord(location, action)
this.setPreviousLocation()
if (cookie.get('uid') && this.props.user.hasError) {
this.getUser()
}
......@@ -89,13 +90,13 @@ class App extends Component {
setNavigationRecord = (location, action) => {
const {pathname, search, hash} = location
let isLastRecord = location.pathname === this.records.length && this.records[this.records.length - 1].pathname
let isLastRecord = location.pathname === (this.records.length && this.records[this.records.length - 1].pathname)
switch (action) {
case 'POP':
this.firstLoad ? this.records.push({pathname, search, hash}) : this.records.pop()
break
case 'REPLACE':
this.records[this.records.length - 1] = {pathname, search, hash}
this.records.length > 1 && (this.records[this.records.length - 1] = {pathname, search, hash})
break
default:
!isLastRecord && this.records.push({pathname, search, hash})
......@@ -170,8 +171,6 @@ class App extends Component {
componentDidUpdate() {
this.setPreviousLocation()
if (!this.props.user.hasError && getParam('redirect')) {
window.location.href = getParam('redirect')
}
......@@ -179,22 +178,23 @@ class App extends Component {
setPreviousLocation = () => {
const {location, history: {action}} = this.props
if (location.pathname.startsWith('/passport')) {
let index = this.records.findIndex(item => item.pathname.startsWith('/passport'))
/*let index = this.records.findIndex(item => item.pathname.startsWith('/passport'))
this.previousLocation = index > 0
? this.records[index - 1]
: this.records.length
? this.records[this.records.length - 1]
: null
: null*/
} else {
if (action === 'POP' || action === 'REPLACE') {
let index = this.records.findIndex(item => item.pathname.startsWith('/passport'))
this.previousLocation = index > 0 ? this.records[index - 1] : this.records[this.records.length - 1]
} else {
this.previousLocation = location
}
if (action === 'POP' || action === 'REPLACE') {
let index = this.records.findIndex(item => item.pathname.startsWith('/passport'))
this.previousLocation = index > 0 ? this.records[index - 1] : this.records[this.records.length - 1]
} else {
this.previousLocation = location
}
}
}
transformUser = res => {
......
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