Commit 87099ecc by zhanghaozhe

红包统计

parent 65b20269
......@@ -165,6 +165,8 @@ class App extends Component {
transformUser = res => {
let payload
if (res.data.code === 200) {
//移除红包统计cookie
cookie.remove('share_code', {path: '/', domain: '.julyedu.com'})
const {
msg, data: {
avatar_file: avatar,
......
......@@ -9,6 +9,7 @@ import { Toast } from 'antd-mobile';
import Captcha from '@/common/Captcha';
import FollowQRcode from './../followQRcode';
import './index.scss';
import cookie from 'js-cookie'
class RedPacket extends PureComponent {
......@@ -53,6 +54,8 @@ class RedPacket extends PureComponent {
// 分享链接进入
this.judgePopupType();
window.addEventListener('beforeunload', this.removeStatisticsCookie)
// 微信进入
const isWechat = getParam('wechat');
......@@ -64,7 +67,7 @@ class RedPacket extends PureComponent {
http.get(`${API.home}/sys/redPacket/shareUrl/${getParam('id')}`).then(res => {
const { code, data } = res.data;
if(code === 200) {
// 检查收否领取过
http.post(
`${API.home}/sys/redPacket/split`,
......@@ -76,7 +79,7 @@ class RedPacket extends PureComponent {
const { code, data } = res.data;
if(code === 200) {
window.localStorage.removeItem('redpacket-click');
// is_receive 是否领取过 0-否 1-是
// is_receive 是否领取过 0-否 1-是
if(data.is_receive) {
this.judgeReceiveStatus(data, 8);
}else {
......@@ -95,6 +98,7 @@ class RedPacket extends PureComponent {
window.localStorage.removeItem('redpacket-click');
}
}else {
this.setRelativeCookie()
this.setState({
type: 1
});
......@@ -103,6 +107,16 @@ class RedPacket extends PureComponent {
this.fetchShareInfo();
}
removeStatisticsCookie = () => {
cookie.remove('share_code', {path: '/', domain: '.julyedu.com'})
}
componentWillUnmount() {
window.removeEventListener('beforeunload', this.removeStatisticsCookie)
this.removeStatisticsCookie()
}
// 获取分享信息
fetchShareInfo = () => {
const share_code = getParam('share_code');
......@@ -574,6 +588,14 @@ 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)
}
render() {
// console.log(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