Commit 98da329f by FE

3

parents 1b556ef3 6dd7b3c9
...@@ -8,7 +8,7 @@ import ListHeader from './../listHeader'; ...@@ -8,7 +8,7 @@ import ListHeader from './../listHeader';
import './index.scss'; import './index.scss';
@connect(({user})=> ({ @connect(({user})=> ({
uid: user.data.uid || '' uid: user && user.data && user.data.uid ? user.data.uid :''
})) }))
class CollectBlessing extends Component { class CollectBlessing extends Component {
......
...@@ -6,6 +6,7 @@ import ListFrame from './../listFrame/index'; ...@@ -6,6 +6,7 @@ import ListFrame from './../listFrame/index';
import CourseItem from './../courseItem/index'; import CourseItem from './../courseItem/index';
import ListHeader from './../listHeader'; import ListHeader from './../listHeader';
import './index.scss'; import './index.scss';
import cookie from "js-cookie";
class CourseList extends Component { class CourseList extends Component {
constructor(props) { constructor(props) {
...@@ -62,6 +63,27 @@ class CourseList extends Component { ...@@ -62,6 +63,27 @@ class CourseList extends Component {
this.fetchAICourse('four'); 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) => { fetchAICourse = (key) => {
const { basic, advanced, higher, expand } = this.state; const { basic, advanced, higher, expand } = this.state;
http.get(`${API.home}/sys/ai_grow_up_courses/${key}`).then(res => { http.get(`${API.home}/sys/ai_grow_up_courses/${key}`).then(res => {
...@@ -222,6 +244,9 @@ class CourseList extends Component { ...@@ -222,6 +244,9 @@ class CourseList extends Component {
toReceiveCoupon(id, key = '') { toReceiveCoupon(id, key = '') {
const {isLogin, toLogin} = this.props; const {isLogin, toLogin} = this.props;
alert(cookie.get("uid"))
if(isLogin) { if(isLogin) {
http.post(`${API.home}/sys/activity/coupon/receive`, { http.post(`${API.home}/sys/activity/coupon/receive`, {
course_id: id course_id: id
...@@ -405,12 +430,22 @@ class CourseList extends Component { ...@@ -405,12 +430,22 @@ class CourseList extends Component {
<em>¥{item.coupon}</em> <em>¥{item.coupon}</em>
<i>代金券</i> <i>代金券</i>
</span> </span>
<<<<<<< HEAD
<span className="coupon-course__button-label">立即领券</span> <span className="coupon-course__button-label">立即领券</span>
</a> </a>
} }
{ {
(isFormal === 0 && item.course_status === 2) && (isFormal === 0 && item.course_status === 2) &&
<a className="coupon-course__button"> <a className="coupon-course__button">
=======
<span className="coupon-course__button-label">立即领券</span>
</a>
}
{
(isFormal === 0 && item.course_status === 2) &&
<a className="coupon-course__button">
>>>>>>> 6dd7b3c93601d587e25fa3320135ff2407451de6
<span className="coupon-course__button-price"> <span className="coupon-course__button-price">
<em>¥{item.coupon}</em> <em>¥{item.coupon}</em>
<i>代金券</i> <i>代金券</i>
......
import React, {Component} from 'react' import React, { Component } from 'react'
import QRCode from 'qrcode' import QRCode from 'qrcode'
import {http, SendMessageToApp, wxShare, is_weixin, getParam} from '@/utils'; import { http, SendMessageToApp, wxShare, is_weixin, getParam } from '@/utils'
import {Link} from 'react-router-dom' import { Link } from 'react-router-dom'
import {throttle, findIndex, debounce} from 'lodash' import { throttle, findIndex, debounce } from 'lodash'
import RulePopup from './rulePopup/index' import RulePopup from './rulePopup/index'
import CoursePopup from './coursePopup/index' import CoursePopup from './coursePopup/index'
import RecordPopup from './recordPopup/index' import RecordPopup from './recordPopup/index'
...@@ -15,16 +15,16 @@ import ListHeader from './listHeader/index' ...@@ -15,16 +15,16 @@ import ListHeader from './listHeader/index'
import LevelTest from './levelTest/index' import LevelTest from './levelTest/index'
import RankList from './rankList/index' import RankList from './rankList/index'
import './index.scss' import './index.scss'
import {Popup} from '@/common' import { Popup } from '@/common'
import {CopyToClipboard} from 'react-copy-to-clipboard' import { CopyToClipboard } from 'react-copy-to-clipboard'
import {Toast} from "antd-mobile" import { Toast } from "antd-mobile"
import Live from './live' import Live from './live'
import Banner from './banner' import Banner from './banner'
import cookie from "js-cookie"; import cookie from "js-cookie"
import {setCurrentUser, startFetchUser} from "@/store/userAction" import { setCurrentUser, startFetchUser } from "@/store/userAction"
import {addDays} from "date-fns"; import { addDays } from "date-fns"
import {compose} from "redux"; import { compose } from "redux"
import {connect} from "react-redux"; import { connect } from "react-redux"
class BlessingPreheat extends Component { class BlessingPreheat extends Component {
...@@ -35,6 +35,12 @@ class BlessingPreheat extends Component { ...@@ -35,6 +35,12 @@ class BlessingPreheat extends Component {
this.prevY = 0 this.prevY = 0
this.state = { this.state = {
userInfoList: [], userInfoList: [],
// userInfoList: [{
// token:'fcfef221e60ab7a2-92a80d5d30196999',
// uid:'545292',
// uname:'xzhtest2',
// avatar_file:''
// }],
isRule: false, isRule: false,
isCourse: false, isCourse: false,
inviteUrl: '', inviteUrl: '',
...@@ -75,14 +81,15 @@ class BlessingPreheat extends Component { ...@@ -75,14 +81,15 @@ class BlessingPreheat extends Component {
}, },
], ],
index: 0, index: 0,
userHasError: props.user.hasError userHasError: props.user.hasError,
isApp: false
} }
} }
componentDidMount() { componentDidMount() {
this.fetchUserBlessing(); this.fetchUserBlessing()
this.setInitialNavActiveStatus() this.setInitialNavActiveStatus()
window.addEventListener('scroll', throttle(this.calcNavActive, 100)); window.addEventListener('scroll', throttle(this.calcNavActive, 100))
if (is_weixin()) { if (is_weixin()) {
wxShare({ wxShare({
title: 'AI充电节,积福气享1折秒课,超10万元奖品来就送!!', title: 'AI充电节,积福气享1折秒课,超10万元奖品来就送!!',
...@@ -98,33 +105,46 @@ class BlessingPreheat extends Component { ...@@ -98,33 +105,46 @@ class BlessingPreheat extends Component {
} }
window['getNewData'] = result => { window['getNewData'] = result => {
this.fetchUserBlessing(); this.fetchUserBlessing()
}
window['QQWXWBshare'] = result => {
this.handleToAddBlessing(result)
} }
} }
// 获取app登录数据 // 获取app登录数据
loginInfo = (result) => { loginInfo = (result) => {
this.setState({ this.setState({
userInfoList: result userInfoList: result
}) }, () => {
if (this.state.userInfoList.length !== 0) { if (this.state.userInfoList.length) {
this.props.startFetchUser() this.props.startFetchUser()
this.appLogin() this.appLogin()
} }
})
} }
// 保存cookie // 保存cookie
appLogin = () => { appLogin = () => {
let expires = addDays(new Date(), 90) let expires = addDays(new Date(), 90)
this.state.userInfoList.map((item, index) => { this.state.userInfoList.map((item, index) => {
Toast.info(item.version, 3) Toast.info(item.uid)
cookie.set("token", item.token, {expires, path: '/', domain: 'julyedu.com'}); cookie.set("token", item.token, {expires, path: '/', domain: '.julyedu.com'})
cookie.set("plat", item.plat, {expires, path: '/', domain: 'julyedu.com'}); cookie.set("plat", item.plat, {expires, path: '/', domain: '.julyedu.com'})
cookie.set("uid", item.uid, {expires, path: '/', domain: 'julyedu.com'}); cookie.set("uid", item.uid, {expires, path: '/', domain: '.julyedu.com'})
cookie.set("uname", item.uname, {expires, path: '/', domain: 'julyedu.com'}); cookie.set("uname", item.uname, {expires, path: '/', domain: '.julyedu.com'})
cookie.set("avatar_file", item.avatar_file, {expires, path: '/', domain: 'julyedu.com'}); cookie.set("avatar_file", item.avatar_file, {expires, path: '/', domain: '.julyedu.com'})
}); })
if (cookie.get("token") && cookie.get("uid")) {
this.fetchUserBlessing()
this.setState({
isApp: true
})
}
this.props.setCurrentUser(this.transformUser(this.state.userInfoList)) this.props.setCurrentUser(this.transformUser(this.state.userInfoList))
} }
transformUser = res => { transformUser = res => {
...@@ -161,6 +181,36 @@ class BlessingPreheat extends Component { ...@@ -161,6 +181,36 @@ class BlessingPreheat extends Component {
} }
} }
} }
<<<<<<< HEAD
fetchMoudleId = (str) => {
const {navs} = this.state
return findIndex(navs, item => item.id === str)
}
fetchUserBlessing() {
Toast.info('fetchUserBlessing', 2)
const {userInfo} = this.state;
http.get(`${API.home}/sys/user/blessing`).then(res => {
const {code, data} = res.data
if (code === 200) {
this.setState({
isSign: !!data.today_signed,
isFormal: data.is_activity,
userInfo: Object.assign({}, userInfo, {
isFollow: data.subscribed,
blessingVal: data.user_blessing_value,
buyBlessing: (data.types_total_blessing_value && data.types_total_blessing_value.buy_course) ? data.types_total_blessing_value.buy_course : 0,
inviteBlessing: (data.types_total_blessing_value && data.types_total_blessing_value.invite) ? data.types_total_blessing_value.invite : 0,
})
})
if (data.is_login === 1) {
this.handleToSign()
}
this.initNav(data.is_activity)
}
=======
return arr.length - 1 return arr.length - 1
} }
...@@ -173,6 +223,7 @@ class BlessingPreheat extends Component { ...@@ -173,6 +223,7 @@ class BlessingPreheat extends Component {
this.setState({index, navsTop}, () => { this.setState({index, navsTop}, () => {
this.calcNavActive() this.calcNavActive()
observer.disconnect() observer.disconnect()
>>>>>>> 6dd7b3c93601d587e25fa3320135ff2407451de6
}) })
} }
}, 30)) }, 30))
...@@ -193,23 +244,22 @@ class BlessingPreheat extends Component { ...@@ -193,23 +244,22 @@ class BlessingPreheat extends Component {
return findIndex(navs, item => item.id === str) return findIndex(navs, item => item.id === str)
} }
fetchUserBlessing() { fetchUserBlessing = () => {
Toast.info('fetchUserBlessing', 2) const {userInfo} = this.state
const {userInfo} = this.state;
http.get(`${API.home}/sys/user/blessing`).then(res => { http.get(`${API.home}/sys/user/blessing`).then(res => {
const {code, data} = res.data const {code, data} = res.data
alert(code)
if (code === 200) { if (code === 200) {
this.setState({ this.setState({
isSign: !!data.today_signed, isSign: !!data.today_signed,
isFormal: data.is_activity, isFormal: data.is_activity,
userInfo: Object.assign({}, userInfo, { userInfo: Object.assign({}, userInfo, {
isFollow: data.subscribed,
blessingVal: data.user_blessing_value, blessingVal: data.user_blessing_value,
buyBlessing: (data.types_total_blessing_value && data.types_total_blessing_value.buy_course) ? data.types_total_blessing_value.buy_course : 0, buyBlessing: (data.types_total_blessing_value && data.types_total_blessing_value.buy_course) ? data.types_total_blessing_value.buy_course : 0,
inviteBlessing: (data.types_total_blessing_value && data.types_total_blessing_value.invite) ? data.types_total_blessing_value.invite : 0, inviteBlessing: (data.types_total_blessing_value && data.types_total_blessing_value.invite) ? data.types_total_blessing_value.invite : 0,
}) })
}) })
alert(cookie.get('uid'))
if (data.is_login === 1) { if (data.is_login === 1) {
this.handleToSign() this.handleToSign()
} }
...@@ -218,6 +268,20 @@ class BlessingPreheat extends Component { ...@@ -218,6 +268,20 @@ class BlessingPreheat extends Component {
}) })
} }
handleToAddBlessing = (key) => {
http.post(`${API.home}/sys/add/blessing`, {
share_platform: key, // 1 朋友圈 2 微博 3 qq
type: 3 // 1:签到;3:分享;4:浏览课程;
}).then(res => {
const {code} = res.data
if (code === 200) {
Toast.info('+2点福气值~', 2, null, false)
}
})
}
handleToSign = () => { handleToSign = () => {
http.post(`${API.home}/sys/add/blessing`, { http.post(`${API.home}/sys/add/blessing`, {
type: 1 // 1:签到;3:分享;4:浏览课程; type: 1 // 1:签到;3:分享;4:浏览课程;
...@@ -244,7 +308,7 @@ class BlessingPreheat extends Component { ...@@ -244,7 +308,7 @@ class BlessingPreheat extends Component {
// 需要用户登录 并且用户未登录 // 需要用户登录 并且用户未登录
const isLoginnew = !this.props.user.hasError const isLoginnew = !this.props.user.hasError
if (isLogin && isLoginnew) { if (isLogin && !isLoginnew) {
this.toLogin() this.toLogin()
} else { } else {
let obj = {} let obj = {}
...@@ -255,7 +319,7 @@ class BlessingPreheat extends Component { ...@@ -255,7 +319,7 @@ class BlessingPreheat extends Component {
} }
} }
// 邀请好友注册 // 邀请好友注册
handleToShowInvite = () => { handleToShowInvite = () => {
const isLogin = !this.props.user.hasError const isLogin = !this.props.user.hasError
if (isLogin) { if (isLogin) {
...@@ -266,9 +330,18 @@ class BlessingPreheat extends Component { ...@@ -266,9 +330,18 @@ class BlessingPreheat extends Component {
margin: 1 margin: 1
}) })
.then(url => { .then(url => {
this.setState({ const content = (
inviteUrl: url, <>
inviteVisible: true <img src={url} alt="barcode" className="qr-code"/>
<CopyToClipboard text={`${API.m}/invite"`} onCopy={this.onCopy}>
<button>一键复制网址</button>
</CopyToClipboard>
</>
)
Popup({
title: '扫码邀请好友注册+10点福气值',
content,
className: 'invite-popup'
}) })
}) })
.catch(err => { .catch(err => {
...@@ -284,7 +357,7 @@ class BlessingPreheat extends Component { ...@@ -284,7 +357,7 @@ class BlessingPreheat extends Component {
SendMessageToApp("toShare", data) SendMessageToApp("toShare", data)
} }
} else { } else {
this.toLogin(); this.toLogin()
} }
} }
...@@ -297,9 +370,10 @@ class BlessingPreheat extends Component { ...@@ -297,9 +370,10 @@ class BlessingPreheat extends Component {
height: 120, height: 120,
margin: 1 margin: 1
}).then(url => { }).then(url => {
this.setState({ Popup({
isServer: true, title: '',
serverUrl: url, content: <img src={url} alt="barcode" className="qr-code"/>,
className: 'invite-popup'
}) })
}) })
.catch(err => { .catch(err => {
...@@ -383,17 +457,14 @@ class BlessingPreheat extends Component { ...@@ -383,17 +457,14 @@ class BlessingPreheat extends Component {
userInfo, userInfo,
isRule, isRule,
isCourse, isCourse,
inviteUrl,
inviteVisible,
isFormal, isFormal,
isServer,
serverUrl,
isSign, isSign,
showRecordList, showRecordList,
shareMark, shareMark,
index index,
} = this.state; isApp
const {history} = this.props; } = this.state
const {history} = this.props
const isLogin = !this.props.user.hasError const isLogin = !this.props.user.hasError
return ( return (
<div id={'blessing-preheat'}> <div id={'blessing-preheat'}>
...@@ -403,10 +474,11 @@ class BlessingPreheat extends Component { ...@@ -403,10 +474,11 @@ class BlessingPreheat extends Component {
toSection={this.toSection} toSection={this.toSection}
index={index} index={index}
/> />
{/* 积福气 */} {/* 积福气 */}
<ListHeader id={'lucky-value'} text="积福气,享受更多福利" styles={{margin: '60px 0 15px'}}/> <ListHeader id={'lucky-value'} text="积福气,享受更多福利" styles={{margin: '60px 0 15px'}}/>
<Link className="luck-draw__button" to="/blessingRank">福气排行榜></Link> <Link className="luck-draw__button" to="/blessingRank">福气排行榜></Link>
<CollectBlessing <CollectBlessing
isSign={isSign} isSign={isSign}
userInfo={userInfo} userInfo={userInfo}
...@@ -433,13 +505,14 @@ class BlessingPreheat extends Component { ...@@ -433,13 +505,14 @@ class BlessingPreheat extends Component {
isFormal === 0 && isFormal === 0 &&
<> <>
<ListHeader id={'deposit'} text="预付1元定金,最高可省100元" styles={{margin: '30px 0 15px'}}/> <ListHeader id={'deposit'} text="预付1元定金,最高可省100元" styles={{margin: '30px 0 15px'}}/>
<ReserveCourse/> <ReserveCourse isApp={isApp}/>
</> </>
} }
{/* 精品课程特惠专区 */} {/* 精品课程特惠专区 */}
<ListHeader id={'best-courses'} text="精品课程特惠专区" styles={{margin: '30px 0 15px'}}/> <ListHeader id={'best-courses'} text="精品课程特惠专区" styles={{margin: '30px 0 15px'}}/>
<CourseList <CourseList
isApp={isApp}
isFormal={isFormal} isFormal={isFormal}
isLogin={isLogin} isLogin={isLogin}
history={this.props.history} history={this.props.history}
...@@ -463,23 +536,8 @@ class BlessingPreheat extends Component { ...@@ -463,23 +536,8 @@ class BlessingPreheat extends Component {
shareMark && shareMark &&
<SharePopup/> <SharePopup/>
} }
<Popup {/*
visible={inviteVisible}
title={'扫码邀请好友注册+10点福气值'}
className={'invite-popup'}
>
<img src={inviteUrl} alt="barcode" className="qr-code"/>
<CopyToClipboard text={`${API.m}/invite"`} onCopy={this.onCopy}>
<button>一键复制网址</button>
</CopyToClipboard>
</Popup>
<Popup
visible={isServer}
title="扫码关注“七月在线”服务号"
className={'invite-popup'}
>
<img src={serverUrl} alt="barcode" className="qr-code"/>
</Popup>
<Popup visible={this.state.joinLotteryVisible} <Popup visible={this.state.joinLotteryVisible}
title={'你已成功参与本时段抽奖'} title={'你已成功参与本时段抽奖'}
...@@ -504,7 +562,7 @@ class BlessingPreheat extends Component { ...@@ -504,7 +562,7 @@ class BlessingPreheat extends Component {
> >
<img src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/tinypng-common/right_weixin.png" alt="" <img src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/tinypng-common/right_weixin.png" alt=""
className="qr-code"/> className="qr-code"/>
</Popup> </Popup>*/}
<ListHeader id={'ai-test'} text="全国AI工程师水平测试" styles={{margin: '30px 0 15px'}}/> <ListHeader id={'ai-test'} text="全国AI工程师水平测试" styles={{margin: '30px 0 15px'}}/>
......
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