Commit b6786289 by xuzhenghua

app

parent 2bdf9ba2
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Link } from 'react-router-dom';
import { http, getParam, SendMessageToApp } from '@/utils';
import { Toast } from "antd-mobile";
import React, {Component} from 'react';
import {connect} from 'react-redux';
import {Link} from 'react-router-dom';
import {http, getParam, SendMessageToApp} from '@/utils';
import {Toast} from "antd-mobile";
import ListFrame from './../listFrame/index';
import ListHeader from './../listHeader';
import './index.scss';
@connect(({user})=> ({
uid: user.data.uid || ''
@connect(({user}) => ({
uid: user && user.data && user.data.uid ? user.data.uid :''
}))
class CollectBlessing extends Component {
......@@ -56,11 +56,11 @@ class CollectBlessing extends Component {
}
qqToShare = () => {
const { uid, history } = this.props;
if(getParam('version')) {
if(!uid) {
const {uid, history} = this.props;
if (getParam('version')) {
if (!uid) {
SendMessageToApp("toLogin");
}else {
} else {
SendMessageToApp("QQshare", {
title: 'AI充电节,积福气享1折秒课,超10万元奖品来就送!!',
desc: '把这门超5万人报名的【Python基础入门 升级版】课程送给你,附200元红包,请笑纳!--七月在线',
......@@ -68,10 +68,10 @@ class CollectBlessing extends Component {
imgUrl: 'https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_1111/m/index-share-img.png',
});
}
}else {
if(!uid) {
} else {
if (!uid) {
history.push('/passport');
}else {
} else {
history.push('/blessingPreheat?utm_source=qq&utm_medium=11&utm_campaign=QQ11&utm_content=11&utm_term=11')
this.fetchUserBlessing(3, () => {
this.handleToAddBlessing(3);
......@@ -81,11 +81,11 @@ class CollectBlessing extends Component {
}
wechatToShare = () => {
const { uid, history } = this.props;
if(getParam('version')) {
if(!uid) {
const {uid, history} = this.props;
if (getParam('version')) {
if (!uid) {
SendMessageToApp("toLogin");
}else {
} else {
SendMessageToApp("WXshare", {
title: 'AI充电节,积福气享1折秒课,超10万元奖品来就送!!',
desc: '把这门超5万人报名的【Python基础入门 升级版】课程送给你,附200元红包,请笑纳!--七月在线',
......@@ -93,10 +93,10 @@ class CollectBlessing extends Component {
imgUrl: 'https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_1111/m/index-share-img.png',
});
}
}else {
if(!uid) {
} else {
if (!uid) {
history.push('/passport');
}else {
} else {
history.push('/blessingPreheat?utm_source=1&utm_medium=1&utm_campaign=11&utm_content=1&utm_term=1');
this.fetchUserBlessing(1, () => {
this.handleToAddBlessing(1);
......@@ -106,11 +106,11 @@ class CollectBlessing extends Component {
}
weiboToShare = () => {
const { uid, history } = this.props;
if(getParam('version')) {
if(!uid) {
const {uid, history} = this.props;
if (getParam('version')) {
if (!uid) {
SendMessageToApp("toLogin");
}else {
} else {
SendMessageToApp("WBshare", {
title: 'AI充电节,积福气享1折秒课,超10万元奖品来就送!!',
desc: '把这门超5万人报名的【Python基础入门 升级版】课程送给你,附200元红包,请笑纳!--七月在线',
......@@ -118,10 +118,10 @@ class CollectBlessing extends Component {
imgUrl: 'https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_1111/m/index-share-img.png',
});
}
}else {
if(!uid) {
} else {
if (!uid) {
history.push('/passport');
}else {
} else {
history.push('/blessingPreheat?utm_source=sina&utm_medium=11&utm_campaign=sina11&utm_content=1&utm_term=11');
this.fetchUserBlessing(2, () => {
this.handleToAddBlessing(2);
......@@ -131,14 +131,14 @@ class CollectBlessing extends Component {
}
fetchUserBlessing(key, cb) {
const { handleToShowShare, handleToHideShare } = this.props;
let { seconds } = this.state;
const {handleToShowShare, handleToHideShare} = this.props;
let {seconds} = this.state;
http.get(`${API.home}/sys/user/blessing`).then(res => {
const { code, data } = res.data;
if(code === 200) {
if(data.today_shared_platforms.some(item => item === key)) {
const {code, data} = res.data;
if (code === 200) {
if (data.today_shared_platforms.some(item => item === key)) {
Toast.info('今日已分享,记得明天来~', 2, null, false);
}else {
} else {
handleToShowShare();
this.shareTimer = setInterval(() => {
this.setState(
......@@ -164,7 +164,7 @@ class CollectBlessing extends Component {
share_platform: key, // 1 朋友圈 2 微博 3 qq
type: 3 // 1:签到;3:分享;4:浏览课程;
}).then(res => {
const {code } = res.data;
const {code} = res.data;
if (code === 200) {
Toast.info('+2点福气值~', 2, null, false);
}
......@@ -174,7 +174,7 @@ class CollectBlessing extends Component {
render() {
const {
isSign,
userInfo: {blessingVal = 0, buyBlessing = 0, inviteBlessing = 0 },
userInfo: {blessingVal = 0, buyBlessing = 0, inviteBlessing = 0},
isLogin,
handleToShowNotice,
handleToShowList,
......@@ -183,16 +183,16 @@ class CollectBlessing extends Component {
toLogin,
toSection
} = this.props;
const { rules, welfareRuleList, seconds } = this.state;
const {rules, welfareRuleList, seconds} = this.state;
return (
<div className="collect-blessing">
{
isLogin
? (
<ListHeader text={`我的福气值: ${blessingVal}分`} size="middle" styles={{margin: '20px 0 0 0'}} />
<ListHeader text={`我的福气值: ${blessingVal}分`} size="middle" styles={{margin: '20px 0 0 0'}}/>
)
: (
<ListHeader size="middle" styles={{margin: '20px 0 0 0'}} >
<ListHeader size="middle" styles={{margin: '20px 0 0 0'}}>
<span className="text_nologin">我的福气值:</span>
<span onClick={toLogin} className="login__btn">登录</span>
</ListHeader>
......@@ -224,11 +224,11 @@ class CollectBlessing extends Component {
</div>
))
}
<ListHeader text="福气值积攒规则" size="middle" styles={{margin: '30px 0 0'}} />
<ListHeader text="福气值积攒规则" size="middle" styles={{margin: '30px 0 0'}}/>
{
rules.map((item, index) => (
<div className="collect-blessing__item" key={index}>
<i className="collect-blessing__num">{index+1}</i>
<i className="collect-blessing__num">{index + 1}</i>
<p className="collect-blessing__title">{item}</p>
{
index === 0 &&
......
......@@ -62,6 +62,27 @@ class CourseList extends Component {
this.fetchAICourse('four');
}
shouldComponentUpdate(nextProps, nextState, nextContext) {
if(this.props.isApp !== nextProps.isApp) {
// 精品课程-集训营、就业班/AI特训营
this.fetchCourseData();
// AI之路-基础
this.fetchAICourse('one');
// AI之路-进阶
this.fetchAICourse('two');
// AI之路-高阶
this.fetchAICourse('three');
// AI之路-拓展
this.fetchAICourse('four');
return false;
}
return true;
}
fetchAICourse = (key) => {
const { basic, advanced, higher, expand } = this.state;
http.get(`${API.home}/sys/ai_grow_up_courses/${key}`).then(res => {
......@@ -221,8 +242,7 @@ class CourseList extends Component {
}
toReceiveCoupon(id, key = '') {
const {isLogin, toLogin,uid} = this.props;
alert(uid)
const {isLogin, toLogin} = this.props;
if(isLogin) {
http.post(`${API.home}/sys/activity/coupon/receive`, {
course_id: id
......
......@@ -81,7 +81,8 @@ class BlessingPreheat extends Component {
},
],
index: 0,
userHasError: props.user.hasError
userHasError: props.user.hasError,
isApp: false
}
}
......@@ -110,7 +111,7 @@ class BlessingPreheat extends Component {
this.handleToAddBlessing(result);
}
this.appLogin()
}
......@@ -138,6 +139,9 @@ class BlessingPreheat extends Component {
if (cookie.get("token") && cookie.get("uid")) {
this.fetchUserBlessing();
this.setState({
isApp: true
})
}
this.props.setCurrentUser(this.transformUser(this.state.userInfoList))
......@@ -419,11 +423,11 @@ class BlessingPreheat extends Component {
isSign,
showRecordList,
shareMark,
index
index,
isApp
} = this.state;
const {history} = this.props;
const isLogin = !this.props.user.hasError
const uid = this.props.user.data.uid
return (
<div id={'blessing-preheat'}>
<Banner
......@@ -473,9 +477,9 @@ class BlessingPreheat extends Component {
{/* 精品课程特惠专区 */}
<ListHeader id={'best-courses'} text="精品课程特惠专区" styles={{margin: '30px 0 15px'}}/>
<CourseList
isApp={isApp}
isFormal={isFormal}
isLogin={isLogin}
uid={uid}
history={this.props.history}
toLogin={this.toLogin}
/>
......
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