Commit 98da329f by FE

3

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