Commit c2abe11e by wangshuo

特训营加入购物车

parent 4ed8fb07
......@@ -59,27 +59,12 @@ class BtnStatus extends Component {
// 未登录 去登陆
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}})
let cidArr = JSON.stringify([Number(getParam('id'))]);
console.log(cidArr);
http.get(`${api['base-api']}/m/cart/addtopreorder/${cidArr}?type=1`).then((res) => {
console.log(res);
if (res.data.errno === 0) {
this.props.history.push({pathname: '/order?id=' + res.data.data[0], state: {type: 1}});
} else {
Toast.info(res.data.msg, 2);
}
......@@ -273,19 +258,11 @@ class BtnStatus extends Component {
<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 &&
info.is_aist && !this.props.user.hasError && info.is_baoming === 1 &&
<div className='btns-box'>
<a className='consult consult-m' href="https://q.url.cn/AB8aue?_type=wpa&qidian=true">
<i className='iconfont iconerji'></i>
......
......@@ -11,6 +11,7 @@ import "./order.scss"
const Item = List.Item;
function OrderList(props) {
console.log(props);
const listData = props.list;
return (
<div>
......@@ -29,7 +30,7 @@ function OrderList(props) {
<span className='order-price'>¥{price0}</span>
</p>
</div>
)
);
return (
<OrderItem {...item} src={image_name} id={course_id} key={index} info={Info}>
......@@ -80,7 +81,8 @@ class Order extends Component {
orderList: [],
info: false,
offset: 0,
}
};
console.log(this.props.location.state);
}
// 提交订单
submitOrder = () => {
......@@ -170,9 +172,35 @@ class Order extends Component {
};
componentDidMount() {
let _this = this;
if(getParam('id') !== undefined) {
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 => {
console.log(this.props.location.state);
if(this.props.location.state && this.props.location.state.type === 1) {
http.get(`${api['home']}/m/order/preorder/`).then((res) => {
if(res.data.errno === 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,
});
}else{
Toast.info(res.data.msg, 2);
return;
}
})
}else {
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 => {
console.log(res);
let preorder = res[1],
detail = res[2],
orderList = [];
......@@ -206,7 +234,8 @@ class Order extends Component {
}else{
http.get(`${api['base-api']}/m/order/preorder`).then((res) => {
if (res.data.code !== 200) {
console.log(res.data);
if (res.data.errno !== 200) {
return;
}
const { course, total, user_account, user_info, discount } = res.data.data;
......@@ -216,7 +245,7 @@ class Order extends Component {
user_account,
total,
discount,
}
};
this.setState({
perfect: user_info,
orderList: course,
......@@ -237,6 +266,7 @@ class Order extends Component {
}
})
}
}
};
render() {
const {
......
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