Commit 0018a825 by zhanghaozhe

微信登录无痕验证

parent 05f04b42
...@@ -8,6 +8,8 @@ import { ...@@ -8,6 +8,8 @@ import {
closeCaptchaModal, closeCaptchaModal,
showCaptchaModal, showCaptchaModal,
validationPassed, validationPassed,
startFetchNoTrace,
endFetchNoTrace,
} 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'
...@@ -116,7 +118,7 @@ class App extends Component { ...@@ -116,7 +118,7 @@ class App extends Component {
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
this.setPreviousLocation() this.setPreviousLocation()
const {user, noTraceValidation: {isShowCaptcha}} = this.props const {user, noTraceValidation: {isShowCaptcha, isFetching: isNoTraceFetching}} = this.props
if (!user.hasError && getParam('redirect')) { if (!user.hasError && getParam('redirect')) {
window.location.href = decodeURIComponent(getParam('redirect')) window.location.href = decodeURIComponent(getParam('redirect'))
} }
...@@ -128,7 +130,10 @@ class App extends Component { ...@@ -128,7 +130,10 @@ class App extends Component {
}) })
} }
if (prevProps.user.isFetching !== user.isFetching && !user.isFetching) { if (
!user.isFetching &&
!isNoTraceFetching
) {
document.body.style.pointerEvents = 'auto' document.body.style.pointerEvents = 'auto'
} }
} }
...@@ -210,6 +215,7 @@ class App extends Component { ...@@ -210,6 +215,7 @@ class App extends Component {
getUser = () => { getUser = () => {
document.body.style.pointerEvents = 'none' document.body.style.pointerEvents = 'none'
this.props.startFetchNoTrace()
//获取用户信息 //获取用户信息
this.props.startFetchUser() this.props.startFetchUser()
...@@ -230,6 +236,7 @@ class App extends Component { ...@@ -230,6 +236,7 @@ class App extends Component {
}); });
this.setupNoTraceValidate() this.setupNoTraceValidate()
} else { } else {
this.props.endFetchNoTrace()
this.props.updateCaptchaState({ this.props.updateCaptchaState({
isNeedValidation: false, isNeedValidation: false,
isFetching: false, isFetching: false,
...@@ -241,6 +248,7 @@ class App extends Component { ...@@ -241,6 +248,7 @@ class App extends Component {
} }
} }
} else { } else {
this.props.endFetchNoTrace()
this.props.updateCaptchaState({ this.props.updateCaptchaState({
isNeedValidation: false, isNeedValidation: false,
isFetching: false, isFetching: false,
...@@ -252,6 +260,7 @@ class App extends Component { ...@@ -252,6 +260,7 @@ class App extends Component {
} else { } else {
if (this.props.location.pathname !== '/my') { if (this.props.location.pathname !== '/my') {
http.get(`${API.home}/m/user_info_sample/0`).then(res => { http.get(`${API.home}/m/user_info_sample/0`).then(res => {
this.props.endFetchNoTrace()
this.props.setCurrentUser(this.transformUser(res)) this.props.setCurrentUser(this.transformUser(res))
}) })
} }
...@@ -327,6 +336,7 @@ class App extends Component { ...@@ -327,6 +336,7 @@ class App extends Component {
Toast.info(msg) Toast.info(msg)
} }
this.props.endFetchUser() this.props.endFetchUser()
this.props.endFetchNoTrace()
}) })
} }
...@@ -468,6 +478,8 @@ export default compose( ...@@ -468,6 +478,8 @@ export default compose(
showCaptchaModal, showCaptchaModal,
validationPassed, validationPassed,
endFetchUser, endFetchUser,
startFetchNoTrace,
endFetchNoTrace,
}), }),
withRouter, withRouter,
)(App) )(App)
import React, {Component} from 'react'; import React, { Component } from 'react';
import './index.scss' import './index.scss'
import {connect} from "react-redux"; import { connect } from "react-redux";
import {compose} from "redux"; import { compose } from "redux";
import {HeaderBar} from "@common/index" import { HeaderBar } from "@common/index"
import {getParam, http, browser, wxShare} from "@/utils" import { getParam, http, browser, wxShare } from "@/utils"
import {Toast} from "antd-mobile"; import { Toast } from "antd-mobile";
import {CopyToClipboard} from "react-copy-to-clipboard"; import { CopyToClipboard } from "react-copy-to-clipboard";
import {Link} from 'react-router-dom' import { Link } from 'react-router-dom'
import storage from 'store2' import storage from 'store2'
import {CaptchaAli} from "@common/index" import { CaptchaAli } from "@common/index"
import {showCaptchaModal} from "@/store/no-trace-validation/reducer"; import { showCaptchaModal } from "@/store/no-trace-validation/reducer";
class Invitation extends Component { class Invitation extends Component {
...@@ -125,7 +125,6 @@ class Invitation extends Component { ...@@ -125,7 +125,6 @@ class Invitation extends Component {
if (data.token && data.sig) { if (data.token && data.sig) {
_data = {..._data, ...data} _data = {..._data, ...data}
} }
http.post(`${API.home}/activity/anniversary/joinTeam`, _data) http.post(`${API.home}/activity/anniversary/joinTeam`, _data)
.then(res => { .then(res => {
const {code, msg} = res.data const {code, msg} = res.data
......
...@@ -27,9 +27,20 @@ export const validationPassed = () => { ...@@ -27,9 +27,20 @@ export const validationPassed = () => {
} }
} }
const START_FETCH = 'START_FETCH'
export const startFetchNoTrace = () => ({
type: START_FETCH,
})
const END_FETCH = 'END_FETCH'
export const endFetchNoTrace = () => ({
type: END_FETCH,
})
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) {
...@@ -55,6 +66,16 @@ export default function noTraceValidation(state = initialState, action) { ...@@ -55,6 +66,16 @@ export default function noTraceValidation(state = initialState, action) {
isShowCaptcha: false, isShowCaptcha: false,
isFetching: false, isFetching: false,
} }
case START_FETCH:
return {
...state,
isFetching: true,
}
case END_FETCH:
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