Commit 5b65df1e by zhanghaozhe

Merge branch 'red-envelope-statistics'

# Conflicts:
#	src/components/detail/redPacket/index.js
parents 0a43367b 4092b755
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数据
...@@ -70,12 +70,18 @@ class App extends Component { ...@@ -70,12 +70,18 @@ class App extends Component {
return return
} }
location.state = {from: this.previousLocation}; location.state = {from: this.previousLocation};
} else {
this.removeShareCodeCookie()
} }
}) })
} }
removeShareCodeCookie = () => {
cookie.remove('share_code', {path: '/', domain: '.julyedu.com'})
}
setNavigationRecord = (location) => { setNavigationRecord = (location) => {
let {location: _location} = this.props let {location: _location} = this.props
let {state: _state = {}} = _location let {state: _state = {}} = _location
...@@ -165,6 +171,8 @@ class App extends Component { ...@@ -165,6 +171,8 @@ class App extends Component {
transformUser = res => { transformUser = res => {
let payload let payload
if (res.data.code === 200) { if (res.data.code === 200) {
//移除红包统计cookie
this.removeShareCodeCookie()
const { const {
msg, data: { msg, data: {
avatar_file: avatar, avatar_file: avatar,
...@@ -200,6 +208,8 @@ class App extends Component { ...@@ -200,6 +208,8 @@ class App extends Component {
transformWxUser = res => { transformWxUser = res => {
let data = res.data let data = res.data
if (data.errno == 200) { if (data.errno == 200) {
//移除红包统计cookie
this.removeShareCodeCookie()
let {uid, token, avatar_file: avatar, uname: username,} = data.data let {uid, token, avatar_file: avatar, uname: username,} = data.data
return { return {
......
...@@ -9,6 +9,7 @@ import { Toast } from 'antd-mobile'; ...@@ -9,6 +9,7 @@ import { Toast } from 'antd-mobile';
import Captcha from '@/common/Captcha'; import Captcha from '@/common/Captcha';
import FollowQRcode from './../followQRcode'; import FollowQRcode from './../followQRcode';
import './index.scss'; import './index.scss';
import cookie from 'js-cookie'
class RedPacket extends PureComponent { class RedPacket extends PureComponent {
...@@ -54,9 +55,16 @@ class RedPacket extends PureComponent { ...@@ -54,9 +55,16 @@ class RedPacket extends PureComponent {
// 分享链接进入 // 分享链接进入
this.judgePopupType(); this.judgePopupType();
window.addEventListener('beforeunload', this.removeStatisticsCookie)
// 微信进入 // 微信进入
const isWechat = getParam('wechat'); const isWechat = getParam('wechat');
const { userInfo } = this.props; const { userInfo } = this.props;
if(!userInfo || !userInfo.uid) {
this.setRelativeCookie()
}
if(isWechat === '1' && !browser.isWeixin) { if(isWechat === '1' && !browser.isWeixin) {
if(userInfo && userInfo.uid) { if(userInfo && userInfo.uid) {
const type = window.localStorage.getItem('redpacket-click'); const type = window.localStorage.getItem('redpacket-click');
...@@ -95,6 +103,7 @@ class RedPacket extends PureComponent { ...@@ -95,6 +103,7 @@ class RedPacket extends PureComponent {
window.localStorage.removeItem('redpacket-click'); window.localStorage.removeItem('redpacket-click');
} }
}else { }else {
this.setRelativeCookie()
this.setState({ this.setState({
type: 1 type: 1
}); });
...@@ -103,6 +112,15 @@ class RedPacket extends PureComponent { ...@@ -103,6 +112,15 @@ class RedPacket extends PureComponent {
this.fetchShareInfo(); this.fetchShareInfo();
} }
removeStatisticsCookie = () => {
cookie.remove('share_code', {path: '/', domain: '.julyedu.com'})
}
componentWillUnmount() {
window.removeEventListener('beforeunload', this.removeStatisticsCookie)
}
// 获取分享信息 // 获取分享信息
fetchShareInfo = () => { fetchShareInfo = () => {
...@@ -582,6 +600,13 @@ class RedPacket extends PureComponent { ...@@ -582,6 +600,13 @@ class RedPacket extends PureComponent {
}); });
} }
//设置统计信息
setRelativeCookie = () => {
const config = {path: '/', domain: '.julyedu.com'}
cookie.set('share_code', getParam('share_code') ? getParam('share_code') : 'share_code', config)
}
render() { render() {
// console.log(this.props); // console.log(this.props);
const { history, userInfo } = this.props; const { history, userInfo } = this.props;
......
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