Commit 29ff89a7 by xuzhenghua

pull

parents 51b9a8eb d9389d99
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数据
......@@ -69,12 +69,18 @@ class App extends Component {
return
}
location.state = {from: this.previousLocation};
} else {
this.removeShareCodeCookie()
}
})
}
removeShareCodeCookie = () => {
cookie.remove('share_code', {path: '/', domain: '.julyedu.com'})
}
setNavigationRecord = (location) => {
let {location: _location} = this.props
let {state: _state = {}} = _location
......@@ -165,7 +171,7 @@ class App extends Component {
let payload
if (res.data.code === 200) {
//移除红包统计cookie
cookie.remove('share_code', {path: '/', domain: '.julyedu.com'})
this.removeShareCodeCookie()
const {
msg, data: {
avatar_file: avatar,
......@@ -201,6 +207,8 @@ class App extends Component {
transformWxUser = res => {
let data = res.data
if (data.errno == 200) {
//移除红包统计cookie
this.removeShareCodeCookie()
let {uid, token, avatar_file: avatar, uname: username,} = data.data
return {
......
......@@ -55,12 +55,16 @@ class RedPacket extends PureComponent {
// 分享链接进入
this.judgePopupType();
window.addEventListener('beforeunload', this.removeStatisticsCookie)
// 微信进入
const isWechat = getParam('wechat');
const { userInfo } = this.props;
if(!userInfo || !userInfo.uid) {
this.setRelativeCookie()
}
if(isWechat === '1' && !browser.isWeixin) {
if(userInfo && userInfo.uid) {
const type = window.localStorage.getItem('redpacket-click');
......@@ -114,13 +118,11 @@ class RedPacket extends PureComponent {
componentWillUnmount() {
window.removeEventListener('beforeunload', this.removeStatisticsCookie)
this.removeStatisticsCookie()
}
// 获取分享信息
fetchShareInfo = () => {
const share_code = getParam('share_code');
http.get(`${API.home}/sys/redPacket/shareUrl/${getParam('id')}`).then(res => {
const { code, data } = res.data;
......@@ -305,9 +307,16 @@ class RedPacket extends PureComponent {
history.push(`/detail?id=${getParam('id')}&wechat=1`);
}else {
if(userInfo && userInfo.uid) {
// 领取好友的后,再领取自己的 share_code 未更新
http.get(`${API.home}/sys/redPacket/shareUrl/${getParam('id')}`).then(res => {
const { code, data } = res.data;
if(code === 200) {
this.setState({
shareInfo: data,
type: 1
});
}
});
}else {
history.push('/passport/login');
}
......@@ -594,8 +603,7 @@ class RedPacket extends PureComponent {
//设置统计信息
setRelativeCookie = () => {
const config = {path: '/', domain: '.julyedu.com'}
const {shareInfo} = this.state
cookie.set('share_code', shareInfo && shareInfo.share_code ? shareInfo.share_code : 'share_code:share_code', config)
cookie.set('share_code', getParam('share_code') ? getParam('share_code') : 'share_code', config)
}
render() {
......
......@@ -148,7 +148,7 @@ const FormikConfig = {
validateOnChange: true,
validate: (values) => {
let errors = {}
if (!validateTel(values.tel)) {
if (!/\d/.test(values.tel)) {
errors.tel = '请填写正确格式的手机号'
}
if (!/[0-9]{6}/.test(values.veriCode)) {
......
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