Commit 533c5f55 by wangshuo

普通课程立即报名

parent 6f366566
...@@ -89,6 +89,16 @@ class BtnStatus extends Component { ...@@ -89,6 +89,16 @@ class BtnStatus extends Component {
}) })
} }
}; };
// 普通课程的立即报名 要模拟结算过程
simpleCourse = () => {
http.get(`${API['base-api']}/m/cart/addtopreorder/[${getParam('id')}]`).then((res) => {
if (res.data.errno === 0) {
this.props.history.push(`/order?id=[${getParam('id')}]`, {simple: 1})
} else {
Toast.info(res.data.msg, 2);
}
})
};
// 格式化开课时间 // 格式化开课时间
formatDate = (date) => { formatDate = (date) => {
let ary = date.split('-'); let ary = date.split('-');
...@@ -208,7 +218,8 @@ class BtnStatus extends Component { ...@@ -208,7 +218,8 @@ class BtnStatus extends Component {
<button className='btn btn-s bg-FCCD05' onClick={e => this.toCart(1)}>加入购物车</button> <button className='btn btn-s bg-FCCD05' onClick={e => this.toCart(1)}>加入购物车</button>
} }
<Link to='/order' className='btn btn-s bg-FD7700'>立即报名</Link> {/*<Link to='/order' className='btn btn-s bg-FD7700'>立即报名</Link>*/}
<span className='btn btn-s bg-FD7700' onClick={e => this.simpleCourse()}>立即报名</span>
</div> </div>
} }
...@@ -217,7 +228,7 @@ class BtnStatus extends Component { ...@@ -217,7 +228,7 @@ class BtnStatus extends Component {
info.is_baoming === 1 && info.is_baoming === 1 &&
<div className='btns-box'> <div className='btns-box'>
<a className='consult consult-m' href="https://q.url.cn/AB8aue?_type=wpa&qidian=true"> <a className='consult consult-m' href="https://q.url.cn/AB8aue?_type=wpa&qidian=true">
<i className='iconfont iconerji'></i> <i className='iconfont iconerji' />
<span>课程咨询</span> <span>课程咨询</span>
</a> </a>
<Link to={`/play?id=${getParam('id')}`} className='btn btn-m bg-09f'>开始学习</Link> <Link to={`/play?id=${getParam('id')}`} className='btn btn-m bg-09f'>开始学习</Link>
......
...@@ -81,11 +81,10 @@ class Order extends Component { ...@@ -81,11 +81,10 @@ class Order extends Component {
info: false, info: false,
offset: 0, offset: 0,
}; };
console.log(this.props.location.state);
} }
// 提交订单 // 提交订单
submitOrder = () => { submitOrder = () => {
if (this.state.orderList.lengtjh === 0) { if (this.state.orderList.length === 0) {
Toast.info('没有要提交的订单!'); Toast.info('没有要提交的订单!');
return; return;
} }
...@@ -93,7 +92,7 @@ class Order extends Component { ...@@ -93,7 +92,7 @@ class Order extends Component {
Toast.info('请完善报名信息!'); Toast.info('请完善报名信息!');
} }
let url = `${API['base-api']}/m/v34/cart/order?ischeck=${this.state.useBalance}`; let url = `${API['base-api']}/m/v34/cart/order?ischeck=${this.state.useBalance}`;
if(this.props.location.state.type === 1) { if(this.props.location.state && this.props.location.state.type === 1) {
url += '&type=1' url += '&type=1'
} }
http.get(url).then(res => { http.get(url).then(res => {
...@@ -210,37 +209,64 @@ class Order extends Component { ...@@ -210,37 +209,64 @@ class Order extends Component {
Toast.info(res.data.msg, 2); Toast.info(res.data.msg, 2);
} }
}) })
}else { } else if (this.props.location.state && this.props.location.state.simple === 1) {
http.get(`${API.home}/m/order/preorder`).then(res => {
console.log(res);
if(res.data.code === 200) {
const { course, total, user_account, user_info, discount } = res.data.data;
this.cacheObj = {
perfect: user_info,
orderList: course,
user_account,
total,
discount,
};
this.setState({
perfect: user_info,
orderList: course,
user_account,
total,
discount,
});
if(this.props.history.action === 'PUSH') {
sessionStorage.removeItem('orderUseCacheObj');
} else{
const cacheObj = sessionStorage.getItem('orderUseCacheObj');
if(cacheObj !== null) {
this.setState({
useBalance: true
});
this.computedMoneyByCache();
}
}
}else{
Toast.info(res.data.msg, 2);
}
});
} else {
if(getParam('id')) { if(getParam('id')) {
Promise.all([http.get(`${API.home}/m/del_cart_order/${getParam('id')}`), http.get(`${API.home}/m/order/preorder`), http.get(`${API.home}/m/course/detail/${getParam('id')}`)]).then(res => { Promise.all([http.get(`${API.home}/m/del_cart_order/${getParam('id')}`), http.get(`${API.home}/m/order/preorder`)]).then(res => {
console.log(res); console.log(res);
let preorder = res[1], let preorder = res[1],
detail = res[2], orderList = preorder.data.data.course;
orderList = [];
console.log(detail);
if(preorder.data.code !== 200) { if(preorder.data.code !== 200) {
Toast.info(preorder.data.msg, 2); Toast.info(preorder.data.msg, 2);
return; return;
} }
if(detail.data.code !== 200) {
Toast.info(preorder.data.msg, 2);
return;
}
const { user_info, user_account, discount } = preorder.data.data; const { user_info, user_account, discount } = preorder.data.data;
const { course_info } = detail.data.data;
orderList.push(course_info);
this.cacheObj = { this.cacheObj = {
perfect: user_info, perfect: user_info,
orderList: orderList, orderList: orderList,
user_account, user_account,
total: course_info.pdd_group_info.price, total: preorder.data.data.total,
discount, discount,
} };
_this.setState({ _this.setState({
perfect: user_info, perfect: user_info,
orderList: orderList, orderList: orderList,
user_account, user_account,
total: course_info.pdd_group_info.price, total: preorder.data.data.total,
discount, discount,
}); });
}) })
...@@ -301,7 +327,7 @@ class Order extends Component { ...@@ -301,7 +327,7 @@ class Order extends Component {
!this.state.perfect && !this.state.perfect &&
<Link to={{ <Link to={{
pathname: '/orderinfo', pathname: '/orderinfo',
state: {type: this.props.location.state.type, id: getParam('id')} state: {type: this.props.location.state ? this.props.location.state.type : null, id: getParam('id')}
}} }}
className="order-information"> className="order-information">
<i className="iconfont iconiconfront-6 order-addsize"></i> <i className="iconfont iconiconfront-6 order-addsize"></i>
...@@ -317,7 +343,7 @@ class Order extends Component { ...@@ -317,7 +343,7 @@ class Order extends Component {
pathname: '/orderinfo', pathname: '/orderinfo',
state: { state: {
...this.state.perfect, ...this.state.perfect,
type: this.props.location.state.type, type: this.props.location.state ? this.props.location.state.type : null,
id: getParam('id') id: getParam('id')
} }
} }
...@@ -340,7 +366,7 @@ class Order extends Component { ...@@ -340,7 +366,7 @@ class Order extends Component {
</div> </div>
} }
<div className="order-list"> <div className="order-list">
<OrderList list={orderList} compute={this.computedMoney} courseId={getParam('id')} isaist={this.props.location.state.type}/> <OrderList list={orderList} compute={this.computedMoney} courseId={getParam('id')} isaist={this.props.location.state ? this.props.location.state.type : null}/>
</div> </div>
<div className="order-balance"> <div className="order-balance">
<List> <List>
......
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