Commit 844f037b by FE

Merge branch '00' of gitlab.julyedu.com:baiguangyao/mr-julyedu into 00

parents 8c56fbd9 50ab0cd1
...@@ -85,6 +85,10 @@ class MyTreasure extends Component { ...@@ -85,6 +85,10 @@ class MyTreasure extends Component {
isEmpty: false, isEmpty: false,
teams, teams,
}); });
}else{
this.setState({
isEmpty: true,
});
} }
} }
}); });
......
...@@ -39,22 +39,25 @@ class LiveRoom extends Component { ...@@ -39,22 +39,25 @@ class LiveRoom extends Component {
// 预约直播 // 预约直播
subscribe = (id) => { subscribe = (id) => {
// 检查是否已登录 // 检查是否已登录
this.checkLogin(); const {hasError, data = {}} = this.props.user;
http.get(`${API['base-api']}/sys/createLiveQrcode/${id}`).then(res => { if(hasError) {
let { errno, data, msg } = res.data; this.props.history.push('/passport/login');
console.log(res); }else{
if (errno === 200) { http.get(`${API['base-api']}/sys/createLiveQrcode/${id}`).then(res => {
// TODO 显示二维码地址 并且传递给二维码的图片/地址 let { errno, data, msg } = res.data;
QRCode.toDataURL(data.url, (err, url) => { if (errno === 200) {
this.setState({ QRCode.toDataURL(data.url, (err, url) => {
showMark: true, this.setState({
subUrl: url, showMark: true,
subUrl: url,
})
}) })
}) } else {
} else { Toast.info(msg);
Toast.info(msg); }
} });
}); }
} }
// 已预约 给提示 // 已预约 给提示
tip = () => { tip = () => {
...@@ -62,15 +65,22 @@ class LiveRoom extends Component { ...@@ -62,15 +65,22 @@ class LiveRoom extends Component {
} }
// 去直播间 // 去直播间
toLivingRoom = (id) => { toLivingRoom = (id) => {
this.checkLogin(); const {hasError, data = {}} = this.props.user;
window.location.href = `${window.location.protocol}//www.julyedu.com/live/m_room/${id}` if(hasError) {
this.props.history.push('/passport/login');
}else{
window.location.href = `${window.location.protocol}//www.julyedu.com/live/m_room/${id}`
}
} }
// 查看回放 // 查看回放
checkVideo = (url) => { checkVideo = (url) => {
this.checkLogin(); const {hasError, data = {}} = this.props.user;
// TODO 这里需要课程ID 如何获取? if(hasError) {
const vCourseId = url.split('/')[0]; this.props.history.push('/passport/login');
history.push(`/play/video?id=${vCourseId}`) }else{
const vCourseId = url.split('/')[0];
history.push(`/play/video?id=${vCourseId}`)
}
} }
// 关闭弹框 // 关闭弹框
closePopup = () => { closePopup = () => {
...@@ -80,15 +90,8 @@ class LiveRoom extends Component { ...@@ -80,15 +90,8 @@ class LiveRoom extends Component {
// 关闭弹框的时候再次查询接口 查询预约状态 // 关闭弹框的时候再次查询接口 查询预约状态
this.getLiveInfo(); this.getLiveInfo();
} }
// 检查是否登录
checkLogin = () => {
const {hasError, data = {}} = this.props.user;
if(hasError) { // 未登录
return;
}
}
// TODO APP内需要保存图片 是否还是这样做 需要确认 // APP内需要保存图片 是否还是这样做 需要确认
saveImage = () => { saveImage = () => {
let version = getParam('version') let version = getParam('version')
version = typeof version === 'string' ? version.replace('.', '').replace('.', '').slice(0, 3) : '' version = typeof version === 'string' ? version.replace('.', '').replace('.', '').slice(0, 3) : ''
......
...@@ -251,4 +251,18 @@ ...@@ -251,4 +251,18 @@
.sub__code_container { .sub__code_container {
padding: 20px; padding: 20px;
} }
.save-image {
display: block;
width: 133px;
height: 30px;
margin: 20px auto 0 auto;
background: rgba(83, 39, 250, 1);
border-radius: 15px;
font-size: 14px;
color: #fff;
-webkit-appearance: none;
outline: 0;
border: none;
}
} }
\ No newline at end of file
...@@ -5,13 +5,78 @@ import YearCourse from './YearCourse/index' ...@@ -5,13 +5,78 @@ import YearCourse from './YearCourse/index'
import TreasureBox from './../treasure-box/index' import TreasureBox from './../treasure-box/index'
import TreasureNav from './nav' import TreasureNav from './nav'
import CommonPopup from './../common/commonPopup/index' import CommonPopup from './../common/commonPopup/index'
import cookie from "js-cookie"
import {setCurrentUser, startFetchUser} from "@/store/userAction"
import {addDays} from "date-fns"
export default class index extends Component { export default class index extends Component {
state = { state = {
userInfoList: [],
userInfo: {},
isAppUpdate: false,
showMark: false, showMark: false,
banner: 'https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/newyear20/H5/m_banner_bj%402x.png' banner: 'https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/newyear20/H5/m_banner_bj%402x.png'
} }
componentDidMount() {
const _this = this
// 获取App登录信息
window['loginInfo'] = result => {
_this.loginInfo(result)
}
}
// 获取app登录数据
loginInfo = (result) => {
this.setState({
userInfoList: result
}, () => {
if (this.state.userInfoList.length) {
this.props.startFetchUser()
this.appLogin()
}
})
}
// 保存cookie
appLogin = () => {
let expires = addDays(new Date(), 90)
this.state.userInfoList.map((item, index) => {
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.setState({
isAppUpdate: true
})
}
this.props.setCurrentUser(this.transformUser(this.state.userInfoList))
}
transformUser = res => {
let payload
res.map((item, index) => {
payload = {
hasError: false,
data: {
username: item.uname,
avatar: item.avatar_file,
token: item.token,
uid: item.uid
},
isFetching: false
}
})
return payload
}
// 关闭弹框 // 关闭弹框
closePopup = () => { closePopup = () => {
this.setState({ this.setState({
...@@ -20,22 +85,23 @@ export default class index extends Component { ...@@ -20,22 +85,23 @@ export default class index extends Component {
} }
render() { render() {
const { banner } = this.state; const {banner} = this.state
return ( return (
<div className={'year-index'}> <div className={'year-index'}>
<div className="banner-treasure"> <div className="banner-treasure">
<div id="banner" className="banner-treasure__header" style={{backgroundImage: `url(${banner})`}}></div> <div id="banner" className="banner-treasure__header"
style={{backgroundImage: `url(${banner})`}}></div>
<div className="banner-treasure__nav"> <div className="banner-treasure__nav">
<TreasureNav id="banner" /> <TreasureNav id="banner"/>
</div> </div>
<div className="banner-treasure__decorate"></div> <div className="banner-treasure__decorate"></div>
</div> </div>
{/* 大咖直播 */} {/* 大咖直播 */}
<LiveRoom /> <LiveRoom/>
{/* 组队开宝箱 */} {/* 组队开宝箱 */}
<TreasureBox /> <TreasureBox/>
<YearCourse /> <YearCourse isAppUpdate={this.state.isAppUpdate}/>
{/*好友加入队伍提醒;获得宝箱提醒;开售提醒弹窗,需要自取,注意修改文案*/} {/*好友加入队伍提醒;获得宝箱提醒;开售提醒弹窗,需要自取,注意修改文案*/}
{ {
...@@ -44,7 +110,8 @@ export default class index extends Component { ...@@ -44,7 +110,8 @@ export default class index extends Component {
<div className='sub__code_container'> <div className='sub__code_container'>
<p className='sub__title'>提醒服务</p> <p className='sub__title'>提醒服务</p>
<p className='sub__tip'>有好友加入队伍后第一时间通知我~</p> <p className='sub__tip'>有好友加入队伍后第一时间通知我~</p>
<img className='sub__qr_code' id={'live-qr-code'} src='//julyedu-cdn.oss-cn-beijing.aliyuncs.com/2018christyear/h5/qrcode.jpg' alt=""/> <img className='sub__qr_code' id={'live-qr-code'}
src='//julyedu-cdn.oss-cn-beijing.aliyuncs.com/2018christyear/h5/qrcode.jpg' alt=""/>
<p className='sub__tip'>长按识别/扫码 关注【七月在线】服务号即可预约</p> <p className='sub__tip'>长按识别/扫码 关注【七月在线】服务号即可预约</p>
</div> </div>
</CommonPopup> </CommonPopup>
......
...@@ -3,22 +3,22 @@ import './team.scss' ...@@ -3,22 +3,22 @@ import './team.scss'
import { getParam, http, SendMessageToApp, browser } from "@/utils" import { getParam, http, SendMessageToApp, browser } from "@/utils"
import { Toast } from 'antd-mobile'; import { Toast } from 'antd-mobile';
import {withRouter} from 'react-router-dom'; import {withRouter} from 'react-router-dom';
import {compose} from "redux"
import { connect } from "react-redux";
class TeamInfo extends Component { class TeamInfo extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
is_my_team: true, // 是否有自己的队伍 is_my_team: false, // 是否有自己的队伍
prize_info: { prize_info: [],
name: '',
stage_no: 0,
},
info: { info: {
removable: 0, removable: 0,
total: 0 total: 0
}, },
member: [], member: [],
removable_data: [], removable_data: [],
my_team: {},
} }
} }
...@@ -26,17 +26,19 @@ class TeamInfo extends Component { ...@@ -26,17 +26,19 @@ class TeamInfo extends Component {
this.getTeamInfo(); this.getTeamInfo();
} }
// 获取队伍信息
getTeamInfo = () => { getTeamInfo = () => {
http.get(`${API.home}/sys/treasure/teamInfo`).then(res => { http.get(`${API.home}/sys/treasure/teamInfo`).then(res => {
const { code, data, msg } = res.data; const { code, data, msg } = res.data;
if (code === 200) { if (code === 200) {
const { prize_info, is_my_team, info, member, removable_data } = data; const { prize_info, is_my_team, info, member, removable_data, my_team } = data;
this.setState({ this.setState({
prize_info, prize_info,
is_my_team, is_my_team,
info, info,
member: this.format(member), member: this.fillTeam(member),
removable_data removable_data,
my_team
}) })
} else { } else {
Toast.info(msg); Toast.info(msg);
...@@ -46,16 +48,48 @@ class TeamInfo extends Component { ...@@ -46,16 +48,48 @@ class TeamInfo extends Component {
// 跳转到我的宝箱页 // 跳转到我的宝箱页
toYearTreasure = (close) => { toYearTreasure = (close) => {
let search = ''; if(this.props.user.hasError) {
if(close) { this.props.history.push('/passport/login');
const {removable_data} = this.state; } else {
let current = removable_data[0]; let search = '';
search = `?team_num=${current.team_num}&owner_uid=${current.captain_uid}`; if(close) {
const {removable_data, info: {removable}} = this.state;
if(removable > 0) {
let current = removable_data[0];
search = `?team_num=${current.team_num}&owner_uid=${current.captain_uid}`;
}
}
this.props.history.push(`/year/yearTreasure${search}`);
} }
this.props.history.push(`/year/yearTreasure${search}`);
} }
format = (list) => { // 邀请好友组队
createTeam = () => {
if(this.props.user.hasError) {
this.props.history.push('/passport/login');
} else {
const {is_my_team, my_team: {treasure_code}} = this.state;
if(is_my_team) { // 有自己的队伍
// 直接跳转
this.props.history.push('/activity/newyear-2019/landing?origin=1&treasure_code=' + treasure_code);
}else{ // 没自己的队伍
// 请求创建队伍的接口
http.get(`${API.home}/sys/treasure/createMyTeam`).then(res => {
const { code, data, msg } = res.data;
if (code === 200) {
const { treasure_code } = data;
this.props.history.push('/activity/newyear-2019/landing?origin=1&treasure_code=' + treasure_code);
} else {
Toast.info(msg);
}
});
}
}
}
// 队伍成员信息必须满五个 不满的需要填充
fillTeam = (list) => {
let len = list.length; let len = list.length;
for(let i=0;i<5-len;i++) { for(let i=0;i<5-len;i++) {
list.push({ list.push({
...@@ -68,7 +102,12 @@ class TeamInfo extends Component { ...@@ -68,7 +102,12 @@ class TeamInfo extends Component {
} }
render() { render() {
const { prize_info: { name, stage_no }, is_my_team, info: {removable, total}, member } = this.state; const { prize_info, is_my_team, info: {removable, total}, member } = this.state;
let name = '', stage_no = 0;
if(prize_info.length > 0) {
name = prize_info[0].name;
stage_no = prize_info[0].stage_no;
}
// 显示文案控制 // 显示文案控制
let Text = ''; let Text = '';
if(total === 0) { if(total === 0) {
...@@ -122,16 +161,22 @@ class TeamInfo extends Component { ...@@ -122,16 +161,22 @@ class TeamInfo extends Component {
} }
</div> </div>
</div> </div>
<div className='invite__btn'> <div onClick={this.createTeam} className='invite__btn'>
{ {
is_my_team ? ('继续组队') : ('组队开宝箱') is_my_team ? ('继续组队') : ('组队开宝箱')
} }
</div> </div>
{ {
stage_no && name && <p className='stage_prize'>{`第${stage_no}次必中${name}`}</p> stage_no > 0 && name && <p className='stage_prize'>{`第${stage_no}次必中${name}`}</p>
} }
</div> </div>
) )
} }
} }
export default withRouter(TeamInfo) export default compose(
connect(
state => ({user: state.user}),
null
),
withRouter
)(TeamInfo)
...@@ -3,17 +3,29 @@ import './index.scss' ...@@ -3,17 +3,29 @@ import './index.scss'
import {http, SendMessageToApp, getParam} from '@/utils' import {http, SendMessageToApp, getParam} from '@/utils'
import CommonContainer from './../common/commonContainer/index' import CommonContainer from './../common/commonContainer/index'
import CourseItem from '../../../blessingPreheat/courseItem/index' import CourseItem from '../../../blessingPreheat/courseItem/index'
import {Link, withRouter} from "react-router-dom" import {withRouter} from "react-router-dom"
class YarnWish extends Component { class YarnWish extends Component {
state = { state = {
list: [] list: [],
activityStage: 1,
} }
componentDidMount() { componentDidMount() {
this.fetchCourse() this.fetchCourse()
this.getStage()
} }
componentWillUpdate() {
const {activityStage} = this.state;
if(activityStage == 1) {
document.title = `七月在线年终大回馈,人气好课免费学,精品课程1分抢!`
}else{
document.title = `七月在线年终大回馈,人气好课免费学,精品课程1分抢!`
}
}
fetchCourse = () => { fetchCourse = () => {
http.get(`${API.home}/activity/wish_course`).then(res => { http.get(`${API.home}/activity/wish_course`).then(res => {
const {code, data} = res.data const {code, data} = res.data
...@@ -24,6 +36,16 @@ class YarnWish extends Component { ...@@ -24,6 +36,16 @@ class YarnWish extends Component {
} }
}) })
} }
getStage = () => {
http.get(`${API.home}/activity/stage`).then(res => {
const {code, data} = res.data
if (code === 200) {
this.setState({
activityStage: data.activity_stage // 0-不在活动时间 1-预热 2-正式 3-返场
})
}
})
}
// 去课程详情页 // 去课程详情页
toCourse = (courseId) => { toCourse = (courseId) => {
...@@ -36,7 +58,7 @@ class YarnWish extends Component { ...@@ -36,7 +58,7 @@ class YarnWish extends Component {
} }
render() { render() {
const {list} = this.state const {list, activityStage} = this.state
return ( return (
<div className='yarn-wish'> <div className='yarn-wish'>
...@@ -132,10 +154,10 @@ class YarnWish extends Component { ...@@ -132,10 +154,10 @@ class YarnWish extends Component {
</CommonContainer> </CommonContainer>
: <div className="notData"> : <div className="notData">
<img src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/newyear20/PC/icon-empty.png" alt=""/> <img src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/newyear20/PC/icon-empty.png" alt=""/>
{
<p>你的心愿单目前空空如也,<br/>快去挑选更多优惠课程吧~</p> activityStage == 1 ? <p>你的心愿单目前空空如也,<br/>快去挑选更多优惠课程吧~</p>
{/*活动期间文案*/} : <p>你的心愿单没有课程哦,<br/>感兴趣的课程可在双旦主会场直接购买!</p>
{/*<p>你的心愿单没有课程哦,感兴趣的课程可在双旦主会场直接购买!</p>*/} }
</div> </div>
} }
</div> </div>
......
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