Commit 4e1e48c5 by zhanghaozhe

Merge branch 'no-trace-validation'

parents ed41fee7 05f04b42
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, endFetchUser} from '@/store/userAction' import { setCurrentUser, startFetchUser, endFetchUser } from '@/store/userAction'
import { import {
updateCaptchaState, updateCaptchaState,
closeCaptchaModal, closeCaptchaModal,
showCaptchaModal, showCaptchaModal,
validationPassed, validationPassed,
startFetchValidationState,
endFetchValidationState,
} from '@/store/no-trace-validation/reducer' } from '@/store/no-trace-validation/reducer'
import {initialState} from '@/store/userReducer' import { initialState } from '@/store/userReducer'
import {withRouter} from 'react-router-dom' import { withRouter } from 'react-router-dom'
import {compose} from 'redux' import { compose } from 'redux'
import {getParam, http, browser, loadScript, getTimestamp} from '@/utils' import { getParam, http, browser, loadScript, getTimestamp } from '@/utils'
import {Toast} from 'antd-mobile' import { Toast } from 'antd-mobile'
import {addDays} from 'date-fns' import { addDays } from 'date-fns'
import stringify from 'json-stringify-safe' import stringify from 'json-stringify-safe'
//拦截ajax请求,返回mock数据 //拦截ajax请求,返回mock数据
...@@ -118,18 +116,21 @@ class App extends Component { ...@@ -118,18 +116,21 @@ class App extends Component {
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
this.setPreviousLocation() this.setPreviousLocation()
const {user, noTraceValidation: {isShowCaptcha}} = this.props
if (!this.props.user.hasError && getParam('redirect')) { if (!user.hasError && getParam('redirect')) {
window.location.href = decodeURIComponent(getParam('redirect')) window.location.href = decodeURIComponent(getParam('redirect'))
} }
const {noTraceValidation: {isShowCaptcha}} = this.props
if (prevProps.noTraceValidation.isShowCaptcha !== isShowCaptcha && isShowCaptcha) { if (prevProps.noTraceValidation.isShowCaptcha !== isShowCaptcha && isShowCaptcha) {
typeof nvcReset === 'function' && nvcReset() typeof nvcReset === 'function' && nvcReset()
typeof getNC === 'function' && getNC().then(() => { typeof getNC === 'function' && getNC().then(() => {
_nvc_nc.reset() _nvc_nc.reset()
}) })
} }
if (prevProps.user.isFetching !== user.isFetching && !user.isFetching) {
document.body.style.pointerEvents = 'auto'
}
} }
// 获取宝箱阶段 // 获取宝箱阶段
...@@ -208,6 +209,7 @@ class App extends Component { ...@@ -208,6 +209,7 @@ class App extends Component {
} }
getUser = () => { getUser = () => {
document.body.style.pointerEvents = 'none'
//获取用户信息 //获取用户信息
this.props.startFetchUser() this.props.startFetchUser()
...@@ -215,7 +217,6 @@ class App extends Component { ...@@ -215,7 +217,6 @@ class App extends Component {
let code = getParam('code') let code = getParam('code')
let oid = getParam('oid') let oid = getParam('oid')
if (code && !oid) { if (code && !oid) {
this.props.startFetchValidationState()
http.get(`${API['passport-api']}/m/wx_loginInfo/code/${code}?redirect=${encodeURIComponent(window.location.href)}`) http.get(`${API['passport-api']}/m/wx_loginInfo/code/${code}?redirect=${encodeURIComponent(window.location.href)}`)
.then(res => { .then(res => {
let data = res.data let data = res.data
...@@ -224,7 +225,6 @@ class App extends Component { ...@@ -224,7 +225,6 @@ class App extends Component {
this.props.updateCaptchaState({ this.props.updateCaptchaState({
isNeedValidation: true, isNeedValidation: true,
}) })
this.props.startFetchValidationState()
this.setState({ this.setState({
mkey: data.data.mkey, mkey: data.data.mkey,
}); });
...@@ -232,7 +232,7 @@ class App extends Component { ...@@ -232,7 +232,7 @@ class App extends Component {
} else { } else {
this.props.updateCaptchaState({ this.props.updateCaptchaState({
isNeedValidation: false, isNeedValidation: false,
isFetching: false isFetching: false,
}) })
if (data.data['is_bind_mobile']) { if (data.data['is_bind_mobile']) {
window.location.assign(data.data.url) window.location.assign(data.data.url)
...@@ -243,7 +243,7 @@ class App extends Component { ...@@ -243,7 +243,7 @@ class App extends Component {
} else { } else {
this.props.updateCaptchaState({ this.props.updateCaptchaState({
isNeedValidation: false, isNeedValidation: false,
isFetching: false isFetching: false,
}) })
Toast.info(data.msg) Toast.info(data.msg)
this.props.setCurrentUser(initialState) this.props.setCurrentUser(initialState)
...@@ -319,7 +319,6 @@ class App extends Component { ...@@ -319,7 +319,6 @@ class App extends Component {
this.handleLoginResponse(data) this.handleLoginResponse(data)
} else if (errno === 5002) { } else if (errno === 5002) {
this.props.showCaptchaModal() this.props.showCaptchaModal()
this.props.endFetchValidationState()
typeof nvcReset === 'function' && nvcReset() typeof nvcReset === 'function' && nvcReset()
typeof getNC === 'function' && getNC().then(() => { typeof getNC === 'function' && getNC().then(() => {
_nvc_nc.reset() _nvc_nc.reset()
...@@ -328,7 +327,6 @@ class App extends Component { ...@@ -328,7 +327,6 @@ class App extends Component {
Toast.info(msg) Toast.info(msg)
} }
this.props.endFetchUser() this.props.endFetchUser()
this.props.endFetchValidationState()
}) })
} }
...@@ -470,8 +468,6 @@ export default compose( ...@@ -470,8 +468,6 @@ export default compose(
showCaptchaModal, showCaptchaModal,
validationPassed, validationPassed,
endFetchUser, endFetchUser,
startFetchValidationState,
endFetchValidationState,
}), }),
withRouter, withRouter,
)(App) )(App)
...@@ -96,9 +96,6 @@ class Invitation extends Component { ...@@ -96,9 +96,6 @@ class Invitation extends Component {
joinTeam = data => { joinTeam = data => {
const {user, history, noTraceValidation, showCaptchaModal} = this.props const {user, history, noTraceValidation, showCaptchaModal} = this.props
if (noTraceValidation.isFetching) {
return
}
if (noTraceValidation.isNeedValidation) { if (noTraceValidation.isNeedValidation) {
!noTraceValidation.isShowCaptcha && showCaptchaModal() !noTraceValidation.isShowCaptcha && showCaptchaModal()
return return
......
...@@ -27,20 +27,9 @@ export const validationPassed = () => { ...@@ -27,20 +27,9 @@ export const validationPassed = () => {
} }
} }
const START_FETCHING = 'START_FETCHING'
export const startFetchValidationState = () => ({
type: START_FETCHING,
})
const END_FETCHING = 'END_FETCHING'
export const endFetchValidationState = () => ({
type: END_FETCHING,
})
const initialState = { const initialState = {
isShowCaptcha: false, isShowCaptcha: false,
isNeedValidation: false, isNeedValidation: false,
isFetching: false,
} }
export default function noTraceValidation(state = initialState, action) { export default function noTraceValidation(state = initialState, action) {
...@@ -60,22 +49,12 @@ export default function noTraceValidation(state = initialState, action) { ...@@ -60,22 +49,12 @@ export default function noTraceValidation(state = initialState, action) {
...state, ...state,
...{isShowCaptcha: false}, ...{isShowCaptcha: false},
} }
case START_FETCHING:
return {
...state,
isFetching: true,
}
case VALIDATION_PASSED: case VALIDATION_PASSED:
return { return {
isNeedValidation: false, isNeedValidation: false,
isShowCaptcha: false, isShowCaptcha: false,
isFetching: false, isFetching: false,
} }
case END_FETCHING:
return {
...state,
isFetching: false,
}
default: default:
return state return state
} }
......
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