Commit 2d314bb2 by xuzhenghua

pull

parent 84bcf595
...@@ -570,6 +570,7 @@ class Detail extends Component { ...@@ -570,6 +570,7 @@ class Detail extends Component {
history={this.props.history} history={this.props.history}
country={this.props.country} country={this.props.country}
delCountryNum={this.props.delCountryNum} delCountryNum={this.props.delCountryNum}
userInfo={this.props.user.data}
/> />
} }
......
import React, { PureComponent } from 'react'; import React, { PureComponent } from 'react';
import CopyToClipboard from 'react-copy-to-clipboard'; import {CopyToClipboard} from 'react-copy-to-clipboard';
import classnames from 'classnames'; import classnames from 'classnames';
import { isEmpty } from 'lodash'; import { isEmpty } from 'lodash';
import { browser } from '@/utils'; import { browser } from '@/utils';
...@@ -28,13 +28,11 @@ class RedPacket extends PureComponent { ...@@ -28,13 +28,11 @@ class RedPacket extends PureComponent {
shareInfo: { shareInfo: {
url: '', url: '',
share_code: '', share_code: '',
command: '' command: '【七月在线送你一个红包】https://www.julyedu.com/'
}, },
doneInfo: { //领取后的状态,1:领取成功,2:领取超时 doneInfo: { //领取后的状态,1:领取成功,2:领取超时
status: 2, status: 2,
txt: '手机号绑定超时,红包已失效!', txt: '手机号绑定超时,红包已失效!',
// txt: '今日已领取5.6元代金券碎片!',
// txt: '今日已领取5.6元现金!',
desc: '' desc: ''
}, },
money: '', // 红包金额, money: '', // 红包金额,
...@@ -51,29 +49,33 @@ class RedPacket extends PureComponent { ...@@ -51,29 +49,33 @@ class RedPacket extends PureComponent {
componentDidMount() { componentDidMount() {
// console.log(this.props); // console.log(this.props);
const share_code = getParam('share_code'); this.judgePopupTypeFromCountry();
const { country } = this.props;
const { shareInfo } = this.state; // 分享链接进入
if(country.code) { this.judgePopupType();
this.setState({
country, // 微信进入
shareInfo: { const isWechat = getParam('wechat');
...shareInfo, const { userInfo } = this.props;
share_code: country.code if(isWechat === '1' && !browser.isWeixin) {
} if(userInfo && userInfo.uid) {
}); const type = window.localStorage.getItem('redpacket-click');
if(type === 'split') {
http.get(`${API.home}/sys/redPacket/shareUrl/${getParam('id')}`).then(res => {
const { code, data } = res.data;
if(code === 200) {
// 检查收否领取过 // 检查收否领取过
http.post( http.post(
`${API.home}/sys/redPacket/split`, `${API.home}/sys/redPacket/split`,
{ {
action: 'check', action: 'check',
share_code: country.code share_code: data.share_code
} }
).then(res => { ).then(res => {
console.log(res);
const { code, data } = res.data; const { code, data } = res.data;
if(code === 200) { if(code === 200) {
window.localStorage.removeItem('redpacket-click');
// is_receive 是否领取过 0-否 1-是 // is_receive 是否领取过 0-否 1-是
if(data.is_receive) { if(data.is_receive) {
this.judgeReceiveStatus(data, 8); this.judgeReceiveStatus(data, 8);
...@@ -82,18 +84,47 @@ class RedPacket extends PureComponent { ...@@ -82,18 +84,47 @@ class RedPacket extends PureComponent {
type: 3 type: 3
}); });
} }
// 清除
this.props.delCountryNum();
} }
}) })
} }
// 分享链接进入 });
if(share_code) { }else {
this.setState({ this.setState({
shareInfo: { type: 1
...shareInfo, });
share_code window.localStorage.removeItem('redpacket-click');
} }
}else {
this.setState({
type: 1
});
}
}
this.fetchShareInfo();
}
// 获取分享信息
fetchShareInfo = () => {
http.get(`${API.home}/sys/redPacket/shareUrl/${getParam('id')}`).then(res => {
const { code, data } = res.data;
if(code === 200) {
this.setState({
shareInfo: data
});
}
});
}
// 分享后进入,链接中带 share_code 字段
judgePopupType = () => {
const share_code = getParam('share_code');
const { shareInfo } = this.state;
if(share_code && share_code !== 'null') {
this.setState({
shareInfo: Object.assign({}, shareInfo, {
share_code
})
}); });
// 检查收否领取过 // 检查收否领取过
...@@ -133,6 +164,47 @@ class RedPacket extends PureComponent { ...@@ -133,6 +164,47 @@ class RedPacket extends PureComponent {
} }
} }
// 选择区号后进入
judgePopupTypeFromCountry = () => {
const { country } = this.props;
const { shareInfo } = this.state;
if(country.code) {
this.setState({
country,
shareInfo: Object.assign({}, shareInfo, {
share_code: country.code
})
});
// 检查收否领取过
http.post(
`${API.home}/sys/redPacket/split`,
{
action: 'check',
share_code: country.code
}
).then(res => {
console.log(res);
const { code, data } = res.data;
if(code === 200) {
// is_receive 是否领取过 0-否 1-是
if(data.is_receive) {
this.judgeReceiveStatus(data, 8);
}else {
this.setState({
type: 3
});
}
// 清除
this.props.delCountryNum();
}
})
}
}
// 判断领取状态--领取后 // 判断领取状态--领取后
judgeReceiveStatus = (data, bindType=4) => { judgeReceiveStatus = (data, bindType=4) => {
let txt = ''; let txt = '';
...@@ -209,25 +281,21 @@ class RedPacket extends PureComponent { ...@@ -209,25 +281,21 @@ class RedPacket extends PureComponent {
// 获取分享信息 // 获取分享信息
handleToShare = () => { handleToShare = () => {
const { history } = this.props; const { history, userInfo } = this.props;
http.get(`${API.home}/sys/redPacket/shareUrl/${getParam('id')}`).then(res => {
const { code, data } = res.data;
if(code === 4030 || code === 4040) {
if(browser.isWeixin) { if(browser.isWeixin) {
this.setState({ this.setState({
type: 2 type: 2
}); });
history.push(`/detail?id=${getParam('id')}&wechat=1`);
}else { }else {
history.push('/passport/login'); if(userInfo && userInfo.uid) {
}
}
if(code === 200) {
this.setState({ this.setState({
shareInfo: data, type: 1
type: browser.isWeixin? 2 : 1
}); });
}else {
history.push('/passport/login');
}
} }
});
} }
// 提示关注公众号 // 提示关注公众号
...@@ -354,13 +422,6 @@ class RedPacket extends PureComponent { ...@@ -354,13 +422,6 @@ class RedPacket extends PureComponent {
} }
} }
// 复制口令
handleToCopy = () => {
this.setState({
isCopy: true
});
}
getCaptchaInstance = instance => { getCaptchaInstance = instance => {
this.setState({ this.setState({
captchaInstance: instance captchaInstance: instance
...@@ -515,7 +576,7 @@ class RedPacket extends PureComponent { ...@@ -515,7 +576,7 @@ class RedPacket extends PureComponent {
render() { render() {
// console.log(this.props); // console.log(this.props);
const { history } = this.props; const { history, userInfo } = this.props;
const { const {
type, type,
isCopy, isCopy,
...@@ -570,11 +631,26 @@ class RedPacket extends PureComponent { ...@@ -570,11 +631,26 @@ class RedPacket extends PureComponent {
{command.length > 16? `${command.substr(0, 16)}...` : command} {command.length > 16? `${command.substr(0, 16)}...` : command}
</p> </p>
{!isCopy {!isCopy
? userInfo && userInfo.uid
? ( ? (
<CopyToClipboard text={command} onCopy={this.handleToCopy}> <CopyToClipboard
text={command}
onCopy={() => this.setState({
isCopy: true
})}
>
<button className="popup-password__button--copy">复制口令</button> <button className="popup-password__button--copy">复制口令</button>
</CopyToClipboard> </CopyToClipboard>
) )
: (
<button
className="popup-password__button--copy"
onClick={() => {
window.localStorage.setItem('redpacket-click', 'copy');
history.push('/passport/login');
}}
>复制口令</button>
)
: <p className="popup-password__success">复制成功,快发送给好友吧~</p> : <p className="popup-password__success">复制成功,快发送给好友吧~</p>
} }
</div> </div>
...@@ -585,7 +661,24 @@ class RedPacket extends PureComponent { ...@@ -585,7 +661,24 @@ class RedPacket extends PureComponent {
</div> </div>
<i <i
className="popup-password__button--close iconfont iconiconfront-2" className="popup-password__button--close iconfont iconiconfront-2"
onClick={() => this.handleToClose(true)} onClick={() => {
if(getParam('wechat') === '1') {
if(userInfo && userInfo.uid) {
this.handleToClose(true);
history.push(`/detail?id=${getParam('id')}`);
}else {
this.setState({
type: 3
});
window.localStorage.setItem('redpacket-click', 'split');
}
}else {
this.handleToClose(true);
}
this.setState({
isCopy: false
});
}}
/> />
</div> </div>
} }
......
...@@ -123,7 +123,6 @@ const formikConfig = { ...@@ -123,7 +123,6 @@ const formikConfig = {
plat: 5 plat: 5
}).then(res => { }).then(res => {
const data = res.data const data = res.data
if (data.errno == 200) { if (data.errno == 200) {
if (data.data['is_set_pwd']) { if (data.data['is_set_pwd']) {
...@@ -132,7 +131,8 @@ const formikConfig = { ...@@ -132,7 +131,8 @@ const formikConfig = {
data: { data: {
uid: data.data.uid uid: data.data.uid
}, },
msg: data.data.msg msg: data.data.msg,
stage: 'binding'
}) })
props.history.replace(`/passport/set-password`) props.history.replace(`/passport/set-password`)
}else { }else {
......
...@@ -67,15 +67,17 @@ class Passport extends Component { ...@@ -67,15 +67,17 @@ class Passport extends Component {
let {history, location} = this.props let {history, location} = this.props
let {data} = this.props.user let {data} = this.props.user
if (data && Object.values(data).filter(item => !!item).length) { 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('/') history.push('/')
} else { } 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') const redirectURI = getParam('redirect')
redirectURI ? (window.location.href = redirectURI) : history.replace(from); redirectURI ? (window.location.href = redirectURI) : history.replace(from);
} }
} }
} }
}
render() { render() {
......
...@@ -16,11 +16,6 @@ import { connect } from "react-redux"; ...@@ -16,11 +16,6 @@ import { connect } from "react-redux";
class SetPassword extends Component { class SetPassword extends Component {
componentDidMount() {
// console.log(this.props.location);
}
render() { render() {
let {values, errors, location} = this.props let {values, errors, location} = this.props
let {from} = location.state || {from: {pathname: '/'}} let {from} = location.state || {from: {pathname: '/'}}
...@@ -75,7 +70,7 @@ const formikConfig = { ...@@ -75,7 +70,7 @@ const formikConfig = {
}, },
handleSubmit: (values, {props}) => { 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')) { if (from.pathname.includes('forgot-password')) {
forgotPasswordReset(values, props); forgotPasswordReset(values, props);
} else { } else {
...@@ -129,7 +124,7 @@ function bindMobileSetPassword(values, props) { ...@@ -129,7 +124,7 @@ function bindMobileSetPassword(values, props) {
.then(res => { .then(res => {
if (res.data.errno == 200) { if (res.data.errno == 200) {
Toast.info('密码设置成功') Toast.info('密码设置成功')
let {from} = location.state || {from: {pathname: '/'}} let from = props.location.state && props.location.state.from || {pathname: '/'}
setTimeout(function () { setTimeout(function () {
props.history.replace(from.pathname) props.history.replace(from.pathname)
}, 1000) }, 1000)
......
...@@ -2772,6 +2772,11 @@ cli-width@^2.0.0: ...@@ -2772,6 +2772,11 @@ cli-width@^2.0.0:
resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639" resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639"
integrity sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk= integrity sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=
clipboard-copy@^3.1.0:
version "3.1.0"
resolved "https://registry.npm.taobao.org/clipboard-copy/download/clipboard-copy-3.1.0.tgz#4c59030a43d4988990564a664baeafba99f78ca4"
integrity sha1-TFkDCkPUmImQVkpmS66vupn3jKQ=
cliui@^3.2.0: cliui@^3.2.0:
version "3.2.0" version "3.2.0"
resolved "https://registry.yarnpkg.com/cliui/-/cliui-3.2.0.tgz#120601537a916d29940f934da3b48d585a39213d" resolved "https://registry.yarnpkg.com/cliui/-/cliui-3.2.0.tgz#120601537a916d29940f934da3b48d585a39213d"
......
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