Commit 18e24611 by FE

pull master and del build

parents 615ef9aa 61bc7232
var API = {
'www': 'http://www-test.julyedu.com',
'home': 'http://fast-test.julyedu.com',
'search-api': 'https://search.julyedu.com',
'passport-api': 'http://passport-test.julyedu.com',
......
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数据
......@@ -55,10 +55,11 @@ class App extends Component {
}
this.getUser()
this.utm()
const routeMatchRule = /binding-tel|forgot|set-password/
const {history} = this.props
history.listen((location) => {
this.utm()
this.setNavigationRecord(location)
if (cookie.get('uid') && this.props.user.hasError) {
this.getUser()
......@@ -88,6 +89,32 @@ class App extends Component {
}
}
utm = () => {
// utm统计 m站全站统计广告投放、以及统计详情页浏览
let utm_source = getParam('utm_source')
let utm_medium = getParam('utm_medium')
let utm_campaign = getParam('utm_campaign')
let utm_content = getParam('utm_content')
let utm_term = getParam('utm_term')
let courseId = location.pathname.startsWith('/getDetail') || location.pathname.startsWith('/detail') ? getParam('id') : 0
if (courseId || (utm_term && utm_source && utm_medium && utm_campaign && utm_content)) {
let data = {
'utm_source': utm_source,
'utm_medium': utm_medium,
'utm_campaign': utm_campaign,
'utm_content': utm_content,
'utm_term': utm_term,
}
http.post(`${API['www']}/base/first_utm_record/${courseId}`, data)
.then(res => {
})
}
}
getUser = () => {
this.props.startFetchUser()
......
......@@ -123,7 +123,6 @@ const formikConfig = {
plat: 5
}).then(res => {
const data = res.data
if (data.errno == 200) {
if (data.data['is_set_pwd']) {
......@@ -132,8 +131,10 @@ const formikConfig = {
data: {
uid: data.data.uid
},
msg: data.data.msg
msg: data.data.msg,
stage: 'binding'
})
alert('replace')
props.history.replace(`/passport/set-password`)
}else {
location.assign(data.data['jump_url'])
......
......@@ -67,15 +67,17 @@ class Passport extends Component {
let {history, location} = this.props
let {data} = this.props.user
if (data && Object.values(data).filter(item => !!item).length) {
if(history.action === 'POP' && history.length <= 3) {
if (history.action === 'POP' && history.length <= 3) {
history.push('/')
} else {
const { from } = location.state || {from: {pathname: '/', search: ''}};
if (!(this.props.user && this.props.user.stage)) {
const from = location.state && location.state.from || {pathname: '/', search: ''};
const redirectURI = getParam('redirect')
redirectURI ? (window.location.href = redirectURI) : history.replace(from);
}
}
}
}
render() {
......
......@@ -16,11 +16,6 @@ import { connect } from "react-redux";
class SetPassword extends Component {
componentDidMount() {
// console.log(this.props.location);
}
render() {
let {values, errors, location} = this.props
let {from} = location.state || {from: {pathname: '/'}}
......@@ -75,7 +70,7 @@ const formikConfig = {
},
handleSubmit: (values, {props}) => {
let {from} = props.location.state || {from: {pathname: '/'}}
let from = props.location.state && props.location.state.from || {pathname: '/'}
if (from.pathname.includes('forgot-password')) {
forgotPasswordReset(values, props);
} else {
......@@ -129,7 +124,7 @@ function bindMobileSetPassword(values, props) {
.then(res => {
if (res.data.errno == 200) {
Toast.info('密码设置成功')
let {from} = location.state || {from: {pathname: '/'}}
let from = props.location.state && props.location.state.from || {pathname: '/'}
setTimeout(function () {
props.history.replace(from.pathname)
}, 1000)
......
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