Commit 312b4a6d by wangshuo

特训营课程报名购买学习流程

parent 9af87de7
......@@ -18,6 +18,7 @@ class BtnStatus extends Component {
in_cart: false,
countdown: 0,
}
console.log(props);
}
componentWillReceiveProps(nextProps) {
......@@ -51,7 +52,45 @@ class BtnStatus extends Component {
Toast.info(res.data.msg, 2);
}
})
}
};
// 返现课程的立即购买
signUpNow = () => {
if(this.props.user.hasError) {
// 未登录 去登陆
this.props.history.push('/passport');
}else{
// 登陆 走登陆的逻辑
/**
let cidArr = JSON.stringify([getParam('id')]);
this.axios({
method : 'get',
url : "cart/addtopreorder/" + cidArr + "?type=1"
})
.then(function(res){
if(res.data.errno == 0 ){
_this.$router.push({ path: 'order', query: { type: 1 }});
}
})
.catch(function(err){
console.log(err);
})
}
* **/
let cidArr = JSON.stringify([getParam('id')]);
http.get(`${api['base-api']}/cart/addtopreorder/${cidArr}?type=1`).then((res) => {
if (res.data.code === 200) {
this.props.history.push({pathname: '/order', state: {type: 1}})
} else {
Toast.info(res.data.msg, 2);
}
})
}
};
// 格式化开课时间
formatDate = (date) => {
let ary = date.split('-');
return `${ary[1]}${ary[2]}日开课`;
};
// 直接购买
tobuy = () => {
if (this.props.barInfo.bargain_status === 2) {
......@@ -63,7 +102,7 @@ class BtnStatus extends Component {
bargainStatus: 1,
})
}
}
};
// 取消砍价
......@@ -222,6 +261,53 @@ class BtnStatus extends Component {
</div>
}
{/*特训营课程 未登录 未报名*/}
{
(info.is_aist && (this.props.user.hasError || info.is_baoming === 0)) &&
<div className='btns-box'>
<a className='consult consult-m' href="https://q.url.cn/AB8aue?_type=wpa&qidian=true">
<i className='iconfont iconerji'></i>
<span>课程咨询</span>
</a>
<button className='btn sign-up-now' onClick={e => this.signUpNow()}>
<span>立即报名</span>
</button>
{/*<Link to={`/play?id=${getParam('id')}`} className='btn btn-m learn-now'>*/}
{/* <span>开始学习</span>*/}
{/*</Link>*/}
{/*<button className='btn btn-m wait-open' >*/}
{/* <span>{this.formatDate('2019-02-10')}</span>*/}
{/*</button>*/}
</div>
}
{/*特训营课程 登陆且已报名*/}
{
info.is_aist && !this.props.user.hasError && info.is_baoming === 0 &&
<div className='btns-box'>
<a className='consult consult-m' href="https://q.url.cn/AB8aue?_type=wpa&qidian=true">
<i className='iconfont iconerji'></i>
<span>课程咨询</span>
</a>
{
info.aist_start_time === "" ?
(
<Link to={`/play?id=${getParam('id')}`} className='btn btn-m learn-now'>
<span>开始学习</span>
</Link>
) : (
<button className='btn btn-m wait-open' >
<span>{this.formatDate(info.aist_start_time)}</span>
</button>
)
}
</div>
}
{
this.state.isShowOverlay &&
......
......@@ -84,6 +84,17 @@
font-size: 12px;
}
}
.sign-up-now {
width: 50%;
color: #fff;
font-size: 16px;
background: linear-gradient(270deg,rgba(255,64,0,1) 0%,rgba(253,119,0,1) 100%);
}
.learn-now {
background-color: #0099FF;
font-size: 16px;
color: #FFF;
}
.btn-m {
width: 50%;
......
......@@ -267,6 +267,7 @@ class Detail extends Component {
{/*课程按钮*/}
<BtnStatus countdown={countdown}
data={this.props.courseInfo}
user={this.props.user}
barInfo={this.state.barInfo}
getBargainInfo={this.getBargainInfo}
invitedFriends={this.invitedFriends}
......@@ -295,7 +296,10 @@ class Detail extends Component {
const mapStateToProps = (state) => {
return {
courseInfo: state.courseInfo
courseInfo: state.courseInfo,
user: {
...state.user
}
}
}
......
......@@ -205,7 +205,7 @@ class Order extends Component {
})
}else{
http.get(`${api.home}/m/order/preorder`).then((res) => {
http.get(`${api['base-api']}/m/order/preorder`).then((res) => {
if (res.data.code !== 200) {
return;
}
......
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