Commit 29ff89a7 by xuzhenghua

pull

parents 51b9a8eb d9389d99
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数据
...@@ -69,12 +69,18 @@ class App extends Component { ...@@ -69,12 +69,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,7 +171,7 @@ class App extends Component { ...@@ -165,7 +171,7 @@ class App extends Component {
let payload let payload
if (res.data.code === 200) { if (res.data.code === 200) {
//移除红包统计cookie //移除红包统计cookie
cookie.remove('share_code', {path: '/', domain: '.julyedu.com'}) this.removeShareCodeCookie()
const { const {
msg, data: { msg, data: {
avatar_file: avatar, avatar_file: avatar,
...@@ -201,6 +207,8 @@ class App extends Component { ...@@ -201,6 +207,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 {
......
...@@ -40,7 +40,7 @@ class RedPacket extends PureComponent { ...@@ -40,7 +40,7 @@ class RedPacket extends PureComponent {
endTime: 10, // 手机绑定时限 endTime: 10, // 手机绑定时限
countdownTimer: null, countdownTimer: null,
countdown: '00分00秒', // 绑定时间 countdown: '00分00秒', // 绑定时间
accountInfo: {}, accountInfo: {},
bindInfo: {}, bindInfo: {},
country: { country: {
num: '86' num: '86'
...@@ -55,12 +55,16 @@ class RedPacket extends PureComponent { ...@@ -55,12 +55,16 @@ class RedPacket extends PureComponent {
// 分享链接进入 // 分享链接进入
this.judgePopupType(); this.judgePopupType();
window.addEventListener('beforeunload', this.removeStatisticsCookie) 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');
...@@ -114,13 +118,11 @@ class RedPacket extends PureComponent { ...@@ -114,13 +118,11 @@ class RedPacket extends PureComponent {
componentWillUnmount() { componentWillUnmount() {
window.removeEventListener('beforeunload', this.removeStatisticsCookie) window.removeEventListener('beforeunload', this.removeStatisticsCookie)
this.removeStatisticsCookie()
} }
// 获取分享信息 // 获取分享信息
fetchShareInfo = () => { fetchShareInfo = () => {
const share_code = getParam('share_code'); const share_code = getParam('share_code');
http.get(`${API.home}/sys/redPacket/shareUrl/${getParam('id')}`).then(res => { http.get(`${API.home}/sys/redPacket/shareUrl/${getParam('id')}`).then(res => {
const { code, data } = res.data; const { code, data } = res.data;
...@@ -161,7 +163,7 @@ class RedPacket extends PureComponent { ...@@ -161,7 +163,7 @@ class RedPacket extends PureComponent {
}); });
}else { }else {
// is_receive 是否领取过 0-否 1-是 // is_receive 是否领取过 0-否 1-是
if(data.is_receive) { if(data.is_receive) {
this.judgeReceiveStatus(data); this.judgeReceiveStatus(data);
}else { }else {
...@@ -204,7 +206,7 @@ class RedPacket extends PureComponent { ...@@ -204,7 +206,7 @@ class RedPacket extends PureComponent {
const { code, data } = res.data; const { code, data } = res.data;
if(code === 200) { if(code === 200) {
// is_receive 是否领取过 0-否 1-是 // is_receive 是否领取过 0-否 1-是
if(data.is_receive) { if(data.is_receive) {
this.judgeReceiveStatus(data, 8); this.judgeReceiveStatus(data, 8);
}else { }else {
...@@ -305,8 +307,15 @@ class RedPacket extends PureComponent { ...@@ -305,8 +307,15 @@ class RedPacket extends PureComponent {
history.push(`/detail?id=${getParam('id')}&wechat=1`); history.push(`/detail?id=${getParam('id')}&wechat=1`);
}else { }else {
if(userInfo && userInfo.uid) { if(userInfo && userInfo.uid) {
this.setState({ // 领取好友的后,再领取自己的 share_code 未更新
type: 1 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 { }else {
history.push('/passport/login'); history.push('/passport/login');
...@@ -561,7 +570,7 @@ class RedPacket extends PureComponent { ...@@ -561,7 +570,7 @@ class RedPacket extends PureComponent {
const { accountInfo: { tel, code}, country: {num = '0086'} } = this.state; const { accountInfo: { tel, code}, country: {num = '0086'} } = this.state;
// is_valid 是否验证 1:验证(默认),0不验证 // is_valid 是否验证 1:验证(默认),0不验证
http.post( http.post(
`${API['passport-api']}/m/personal/bindPhone`, `${API['passport-api']}/m/personal/bindPhone`,
{ {
area_code: num.padStart(4, '0'), area_code: num.padStart(4, '0'),
phone_num: tel, phone_num: tel,
...@@ -594,24 +603,23 @@ class RedPacket extends PureComponent { ...@@ -594,24 +603,23 @@ class RedPacket extends PureComponent {
//设置统计信息 //设置统计信息
setRelativeCookie = () => { setRelativeCookie = () => {
const config = {path: '/', domain: '.julyedu.com'} const config = {path: '/', domain: '.julyedu.com'}
const {shareInfo} = this.state cookie.set('share_code', getParam('share_code') ? getParam('share_code') : 'share_code', config)
cookie.set('share_code', shareInfo && shareInfo.share_code ? shareInfo.share_code : '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;
const { const {
type, type,
isCopy, isCopy,
validate, validate,
isTimer, isTimer,
seconds, seconds,
shareInfo: { shareInfo: {
command = '', command = '',
share_code = '' share_code = ''
}, },
money, money,
doneInfo, doneInfo,
countdown, countdown,
endTime, endTime,
...@@ -636,7 +644,7 @@ class RedPacket extends PureComponent { ...@@ -636,7 +644,7 @@ class RedPacket extends PureComponent {
{/* wechat */} {/* wechat */}
{ {
type == 2 && type == 2 &&
<div className="pupup-wechat"> <div className="pupup-wechat">
<h4 className="popup-wechat__title">当前环境不支持领红包活动</h4> <h4 className="popup-wechat__title">当前环境不支持领红包活动</h4>
<p className="popup-wechat__desc">请点击右上角“ ··· ”,选择在浏览器中打开 然后参与活动!</p> <p className="popup-wechat__desc">请点击右上角“ ··· ”,选择在浏览器中打开 然后参与活动!</p>
...@@ -657,7 +665,7 @@ class RedPacket extends PureComponent { ...@@ -657,7 +665,7 @@ class RedPacket extends PureComponent {
{!isCopy {!isCopy
? userInfo && userInfo.uid ? userInfo && userInfo.uid
? ( ? (
<CopyToClipboard <CopyToClipboard
text={command} text={command}
onCopy={() => this.setState({ onCopy={() => this.setState({
isCopy: true isCopy: true
...@@ -667,8 +675,8 @@ class RedPacket extends PureComponent { ...@@ -667,8 +675,8 @@ class RedPacket extends PureComponent {
</CopyToClipboard> </CopyToClipboard>
) )
: ( : (
<button <button
className="popup-password__button--copy" className="popup-password__button--copy"
onClick={() => { onClick={() => {
window.localStorage.setItem('redpacket-click', 'copy'); window.localStorage.setItem('redpacket-click', 'copy');
history.push('/passport/login'); history.push('/passport/login');
...@@ -683,8 +691,8 @@ class RedPacket extends PureComponent { ...@@ -683,8 +691,8 @@ class RedPacket extends PureComponent {
自己也可以领取哦~ 自己也可以领取哦~
</p> </p>
</div> </div>
<i <i
className="popup-password__button--close iconfont iconiconfront-2" className="popup-password__button--close iconfont iconiconfront-2"
onClick={() => { onClick={() => {
if(getParam('wechat') === '1') { if(getParam('wechat') === '1') {
if(userInfo && userInfo.uid) { if(userInfo && userInfo.uid) {
...@@ -707,14 +715,14 @@ class RedPacket extends PureComponent { ...@@ -707,14 +715,14 @@ class RedPacket extends PureComponent {
</div> </div>
} }
{/* red-packet--close */} {/* red-packet--close */}
{ {
type === 3 && type === 3 &&
<Packet <Packet
type={3} type={3}
packetInfo={{ packetInfo={{
title: '七月在线给你发了个红包~' title: '七月在线给你发了个红包~'
}} }}
handleToClose={() => this.handleToClose(false)} handleToClose={() => this.handleToClose(false)}
handleToOpen={this.handleToOpen} handleToOpen={this.handleToOpen}
...@@ -724,7 +732,7 @@ class RedPacket extends PureComponent { ...@@ -724,7 +732,7 @@ class RedPacket extends PureComponent {
{/* red-packet--open */} {/* red-packet--open */}
{ {
type === 4 && type === 4 &&
<Packet <Packet
type={4} type={4}
packetInfo={{ packetInfo={{
money, money,
...@@ -745,7 +753,7 @@ class RedPacket extends PureComponent { ...@@ -745,7 +753,7 @@ class RedPacket extends PureComponent {
{/* red-packet--money success */} {/* red-packet--money success */}
{ {
type === 5 && type === 5 &&
<Packet <Packet
type={5} type={5}
packetInfo={{ packetInfo={{
money, money,
...@@ -768,7 +776,7 @@ class RedPacket extends PureComponent { ...@@ -768,7 +776,7 @@ class RedPacket extends PureComponent {
{/* red-packet--fragment success */} {/* red-packet--fragment success */}
{ {
type === 6 && type === 6 &&
<Packet <Packet
type={6} type={6}
packetInfo={{ packetInfo={{
money, money,
...@@ -791,7 +799,7 @@ class RedPacket extends PureComponent { ...@@ -791,7 +799,7 @@ class RedPacket extends PureComponent {
{/* red-packet--late 来完了 */} {/* red-packet--late 来完了 */}
{ {
type === 7 && type === 7 &&
<Packet <Packet
type={7} type={7}
packetInfo={{ packetInfo={{
btn: { btn: {
...@@ -819,7 +827,7 @@ class RedPacket extends PureComponent { ...@@ -819,7 +827,7 @@ class RedPacket extends PureComponent {
}} }}
validate={({tel, code}) => { validate={({tel, code}) => {
const errors = {}; const errors = {};
// if (!validateTel(tel)) { // if (!validateTel(tel)) {
if(!/^\d+$/.test(tel)) { if(!/^\d+$/.test(tel)) {
errors.tel = '请填写正确格式的手机号'; errors.tel = '请填写正确格式的手机号';
...@@ -827,7 +835,7 @@ class RedPacket extends PureComponent { ...@@ -827,7 +835,7 @@ class RedPacket extends PureComponent {
if (!/[0-9]{6}/.test(code)) { if (!/[0-9]{6}/.test(code)) {
errors.code = '请输入验证码'; errors.code = '请输入验证码';
} }
return errors; return errors;
}} }}
onSubmit={(values, { setStatus, setSubmitting }) => { onSubmit={(values, { setStatus, setSubmitting }) => {
...@@ -842,8 +850,8 @@ class RedPacket extends PureComponent { ...@@ -842,8 +850,8 @@ class RedPacket extends PureComponent {
<Form className="popup-form__content"> <Form className="popup-form__content">
<h4 className="popup-form__title">绑定手机号</h4> <h4 className="popup-form__title">绑定手机号</h4>
<div className="popup-form__item"> <div className="popup-form__item">
<a <a
className="popup-form__button--num" className="popup-form__button--num"
href={`/country?id=${getParam('id')}&share_code=${share_code}`}> href={`/country?id=${getParam('id')}&share_code=${share_code}`}>
+{country.num} +{country.num}
<i className="iconfont iconiconfront-69"></i> <i className="iconfont iconiconfront-69"></i>
...@@ -852,9 +860,9 @@ class RedPacket extends PureComponent { ...@@ -852,9 +860,9 @@ class RedPacket extends PureComponent {
name="tel" name="tel"
render={({field}) => { render={({field}) => {
return ( return (
<input <input
{...field} {...field}
className="popup-form__ipt" className="popup-form__ipt"
data-bdrs="0 6px 6px 0" data-bdrs="0 6px 6px 0"
data-type="tel" data-type="tel"
type="text" type="text"
...@@ -864,7 +872,7 @@ class RedPacket extends PureComponent { ...@@ -864,7 +872,7 @@ class RedPacket extends PureComponent {
}} }}
/> />
</div> </div>
<Captcha <Captcha
mrBtm={15} mrBtm={15}
getInstance={this.getCaptchaInstance} getInstance={this.getCaptchaInstance}
onVerify={this.onVerify} onVerify={this.onVerify}
...@@ -878,8 +886,8 @@ class RedPacket extends PureComponent { ...@@ -878,8 +886,8 @@ class RedPacket extends PureComponent {
绑定超时,红包已失效! 绑定超时,红包已失效!
</p> </p>
</div> </div>
<button <button
className="popup-packet__button--bundle" className="popup-packet__button--bundle"
data-status="do" data-status="do"
type="button" type="button"
onClick={() => { onClick={() => {
...@@ -894,7 +902,7 @@ class RedPacket extends PureComponent { ...@@ -894,7 +902,7 @@ class RedPacket extends PureComponent {
name="code" name="code"
render={({field}) => { render={({field}) => {
return ( return (
<input <input
{...field} {...field}
className="popup-form__ipt popup-form__ipt--left" className="popup-form__ipt popup-form__ipt--left"
type="text" type="text"
...@@ -903,7 +911,7 @@ class RedPacket extends PureComponent { ...@@ -903,7 +911,7 @@ class RedPacket extends PureComponent {
); );
}} }}
/> />
<button <button
className="popup-form__button--code" className="popup-form__button--code"
data-status={(validate && !isTimer)? 'do': ''} data-status={(validate && !isTimer)? 'do': ''}
type="button" type="button"
...@@ -914,8 +922,8 @@ class RedPacket extends PureComponent { ...@@ -914,8 +922,8 @@ class RedPacket extends PureComponent {
} }
</button> </button>
</div> </div>
<button <button
className="popup-packet__button--bundle" className="popup-packet__button--bundle"
data-status={(tel && code && isEmpty(errors))? 'do': 'done'} data-status={(tel && code && isEmpty(errors))? 'do': 'done'}
type="submit" type="submit"
> >
...@@ -927,8 +935,8 @@ class RedPacket extends PureComponent { ...@@ -927,8 +935,8 @@ class RedPacket extends PureComponent {
</Form> </Form>
)} )}
/> />
<i <i
className="popup-password__button--close iconfont iconiconfront-2" className="popup-password__button--close iconfont iconiconfront-2"
onClick={() => this.handleToClose(false)} onClick={() => this.handleToClose(false)}
/> />
</div> </div>
...@@ -947,8 +955,8 @@ class RedPacket extends PureComponent { ...@@ -947,8 +955,8 @@ class RedPacket extends PureComponent {
{doneInfo.txt} {doneInfo.txt}
</h4> </h4>
<p className="popup-done__desc">{doneInfo.desc}</p> <p className="popup-done__desc">{doneInfo.desc}</p>
<button <button
className="popup-packet__button--bundle" className="popup-packet__button--bundle"
data-status="do" data-status="do"
type="submit" type="submit"
onClick={() => { onClick={() => {
...@@ -956,8 +964,8 @@ class RedPacket extends PureComponent { ...@@ -956,8 +964,8 @@ class RedPacket extends PureComponent {
}} }}
>获取更多奖励</button> >获取更多奖励</button>
</div> </div>
<i <i
className="popup-password__button--close iconfont iconiconfront-2" className="popup-password__button--close iconfont iconiconfront-2"
onClick={() => { onClick={() => {
const isShare = getParam('share_code')? true : false; const isShare = getParam('share_code')? true : false;
this.handleToClose(false, isShare); this.handleToClose(false, isShare);
...@@ -968,7 +976,7 @@ class RedPacket extends PureComponent { ...@@ -968,7 +976,7 @@ class RedPacket extends PureComponent {
{/* 手机号绑定提示 */} {/* 手机号绑定提示 */}
{ {
type === 10 && type === 10 &&
<div className="popup-bind"> <div className="popup-bind">
<div className="popup-bind__content"> <div className="popup-bind__content">
<h4 className="popup-bind__title">绑定确认</h4> <h4 className="popup-bind__title">绑定确认</h4>
...@@ -977,7 +985,7 @@ class RedPacket extends PureComponent { ...@@ -977,7 +985,7 @@ class RedPacket extends PureComponent {
{ {
bindInfo['email'] && bindInfo['email'] &&
<li className="popup-bind__account"> <li className="popup-bind__account">
{/* 邮箱 */} {/* 邮箱 */}
<i className="iconfont iconduanxin"></i> <i className="iconfont iconduanxin"></i>
<p className="popup-bind__account--name">{bindInfo['email']}</p> <p className="popup-bind__account--name">{bindInfo['email']}</p>
...@@ -1012,16 +1020,16 @@ class RedPacket extends PureComponent { ...@@ -1012,16 +1020,16 @@ class RedPacket extends PureComponent {
} }
</ul> </ul>
<div className="popup-bind__button"> <div className="popup-bind__button">
<button <button
className="popup-bind__button--cancle" className="popup-bind__button--cancle"
onClick={() => this.handleToClose(false)}>取消</button> onClick={() => this.handleToClose(false)}>取消</button>
<button <button
className="popup-bind__button--confirm" className="popup-bind__button--confirm"
onClick={() => this.toContinueBind(0)}>继续绑定</button> onClick={() => this.toContinueBind(0)}>继续绑定</button>
</div> </div>
</div> </div>
<i <i
className="popup-password__button--close iconfont iconiconfront-2" className="popup-password__button--close iconfont iconiconfront-2"
onClick={() => this.handleToClose(false)} onClick={() => this.handleToClose(false)}
/> />
</div> </div>
...@@ -1083,7 +1091,7 @@ const Packet = ({type, packetInfo, handleToClose, handleToOpen }) => { ...@@ -1083,7 +1091,7 @@ const Packet = ({type, packetInfo, handleToClose, handleToOpen }) => {
}) })
} }
</p> </p>
<button <button
className="popup-packet__button--bundle" className="popup-packet__button--bundle"
onClick={btn.onClick} onClick={btn.onClick}
> >
...@@ -1099,7 +1107,7 @@ const Packet = ({type, packetInfo, handleToClose, handleToOpen }) => { ...@@ -1099,7 +1107,7 @@ const Packet = ({type, packetInfo, handleToClose, handleToOpen }) => {
红包仅能当日领取,下次<br /> 红包仅能当日领取,下次<br />
早点来哦~ 早点来哦~
</p> </p>
<button <button
className="popup-packet__button--bundle" className="popup-packet__button--bundle"
onClick={btn.onClick} onClick={btn.onClick}
> >
...@@ -1108,8 +1116,8 @@ const Packet = ({type, packetInfo, handleToClose, handleToOpen }) => { ...@@ -1108,8 +1116,8 @@ const Packet = ({type, packetInfo, handleToClose, handleToOpen }) => {
</> </>
} }
</div> </div>
<i <i
className="popup-password__button--close iconfont iconiconfront-2" className="popup-password__button--close iconfont iconiconfront-2"
onClick={handleToClose} onClick={handleToClose}
/> />
</div> </div>
......
...@@ -148,7 +148,7 @@ const FormikConfig = { ...@@ -148,7 +148,7 @@ const FormikConfig = {
validateOnChange: true, validateOnChange: true,
validate: (values) => { validate: (values) => {
let errors = {} let errors = {}
if (!validateTel(values.tel)) { if (!/\d/.test(values.tel)) {
errors.tel = '请填写正确格式的手机号' errors.tel = '请填写正确格式的手机号'
} }
if (!/[0-9]{6}/.test(values.veriCode)) { 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