Commit c2abe11e by wangshuo

特训营加入购物车

parent 4ed8fb07
...@@ -59,27 +59,12 @@ class BtnStatus extends Component { ...@@ -59,27 +59,12 @@ class BtnStatus extends Component {
// 未登录 去登陆 // 未登录 去登陆
this.props.history.push('/passport'); this.props.history.push('/passport');
}else{ }else{
// 登陆 走登陆的逻辑 let cidArr = JSON.stringify([Number(getParam('id'))]);
/** console.log(cidArr);
let cidArr = JSON.stringify([getParam('id')]); http.get(`${api['base-api']}/m/cart/addtopreorder/${cidArr}?type=1`).then((res) => {
this.axios({ console.log(res);
method : 'get', if (res.data.errno === 0) {
url : "cart/addtopreorder/" + cidArr + "?type=1" this.props.history.push({pathname: '/order?id=' + res.data.data[0], state: {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 { } else {
Toast.info(res.data.msg, 2); Toast.info(res.data.msg, 2);
} }
...@@ -273,19 +258,11 @@ class BtnStatus extends Component { ...@@ -273,19 +258,11 @@ class BtnStatus extends Component {
<button className='btn sign-up-now' onClick={e => this.signUpNow()}> <button className='btn sign-up-now' onClick={e => this.signUpNow()}>
<span>立即报名</span> <span>立即报名</span>
</button> </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> </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'> <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'></i>
......
...@@ -11,6 +11,7 @@ import "./order.scss" ...@@ -11,6 +11,7 @@ import "./order.scss"
const Item = List.Item; const Item = List.Item;
function OrderList(props) { function OrderList(props) {
console.log(props);
const listData = props.list; const listData = props.list;
return ( return (
<div> <div>
...@@ -29,7 +30,7 @@ function OrderList(props) { ...@@ -29,7 +30,7 @@ function OrderList(props) {
<span className='order-price'>¥{price0}</span> <span className='order-price'>¥{price0}</span>
</p> </p>
</div> </div>
) );
return ( return (
<OrderItem {...item} src={image_name} id={course_id} key={index} info={Info}> <OrderItem {...item} src={image_name} id={course_id} key={index} info={Info}>
...@@ -80,7 +81,8 @@ class Order extends Component { ...@@ -80,7 +81,8 @@ class Order extends Component {
orderList: [], orderList: [],
info: false, info: false,
offset: 0, offset: 0,
} };
console.log(this.props.location.state);
} }
// 提交订单 // 提交订单
submitOrder = () => { submitOrder = () => {
...@@ -170,9 +172,35 @@ class Order extends Component { ...@@ -170,9 +172,35 @@ class Order extends Component {
}; };
componentDidMount() { componentDidMount() {
let _this = this; let _this = this;
if(getParam('id') !== undefined) { console.log(this.props.location.state);
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 => { 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], let preorder = res[1],
detail = res[2], detail = res[2],
orderList = []; orderList = [];
...@@ -206,7 +234,8 @@ class Order extends Component { ...@@ -206,7 +234,8 @@ class Order extends Component {
}else{ }else{
http.get(`${api['base-api']}/m/order/preorder`).then((res) => { 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; return;
} }
const { course, total, user_account, user_info, discount } = res.data.data; const { course, total, user_account, user_info, discount } = res.data.data;
...@@ -216,7 +245,7 @@ class Order extends Component { ...@@ -216,7 +245,7 @@ class Order extends Component {
user_account, user_account,
total, total,
discount, discount,
} };
this.setState({ this.setState({
perfect: user_info, perfect: user_info,
orderList: course, orderList: course,
...@@ -237,6 +266,7 @@ class Order extends Component { ...@@ -237,6 +266,7 @@ class Order extends Component {
} }
}) })
} }
}
}; };
render() { render() {
const { 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