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