Commit 39937e45 by FE

solve question that info of course in order page when click btn of pintuan to order

parent 2c845752
......@@ -100,6 +100,7 @@ class Order extends Component {
constructor(props) {
super(props);
this.state = {
groupPrice: '',
perfect: this.props.location.state,
user_account: 0.00, // 账户余额
total: 0.00, // 需要支付总金额
......@@ -217,9 +218,10 @@ class Order extends Component {
};
// 公共方法 存储数据
publicGetData = (res) => {
let { course, total, user_account, user_info, discount } = res.data.data;
let { course, total, user_account, user_info, discount } = res;
if(this.props.location.state && this.props.location.state.group === 1) {
total = this.groupPrice;
console.log(this.state);
total = this.state.groupPrice;
}
this.cacheObj = {
perfect: user_info,
......@@ -253,52 +255,57 @@ class Order extends Component {
componentDidMount() {
let _this = this;
console.log(this.props.location.state);
console.log(0);
// type: 1,返现课程,simple: 1,正常购买
if(this.props.location.state && this.props.location.state.type === 1) {
http.get(`${API['base-api']}/m/order/preorder?type=1`).then((res) => {
if(res.data.errno === 200) {
this.publicGetData(res);
this.publicGetData(res.data.data);
this.publicLocalStorage();
}else{
Toast.info(res.data.msg, 2);
}
})
} else if (this.props.location.state && (this.props.location.state.simple === 1 || this.props.location.state.bargain === 1)) {
console.log(1);
// 普通课程立即报名 不带 type = 1
http.get(`${API['base-api']}/m/order/preorder`).then(res => {
if(res.data.errno === 200) {
this.publicGetData(res);
this.publicGetData(res.data.data);
this.publicLocalStorage();
}else{
Toast.info(res.data.msg, 2);
}
});
} else if (this.props.location.state && this.props.location.state.group === 1){
console.log(2);
// 获取一键开团的课程
Promise.all([http.get(`${API['base-api']}/m/order/preorder`), http.get(`${API.home}/m/course/detail/${getParam('id')}`)]).then(resList => {
console.log(resList);
Promise.all([http.get(`${API.home}/m/course/detail/${getParam('id')}`),http.get(`${API['base-api']}/m/order/preorder`)]).then(resList => {
let courseInfo = resList[0],
orderInfo = resList[1];
console.log(courseInfo.data);
console.log(orderInfo.data);
if(courseInfo.data.errno === 200) {
let newData = {};
if(orderInfo.data.errno === 200) {
newData = Object.assign({}, orderInfo.data.data, {course: []});
}else{
Toast.info(courseInfo.data.msg, 2);
return;
}
if(orderInfo.data.code === 200) {
if(courseInfo.data.code === 200) {
newData.course.push(courseInfo.data.data.course_info);
this.setState({
groupPrice: courseInfo.data.data.course_info.pdd_group_info.price
})
}else{
Toast.info(courseInfo.data.msg, 2);
return;
}
this.groupPrice = orderInfo.data.data.course_info.pdd_group_info.price;
if(courseInfo.data.data.course.length === 0) {
courseInfo.data.data.course.push(orderInfo.data.data.course_info)
}
this.publicGetData(courseInfo);
// this.groupPrice = orderInfo.data.data.course_info.pdd_group_info.price;
// if(courseInfo.data.data.course.length === 0) {
// courseInfo.data.data.course.push(orderInfo.data.data.course_info)
// }
this.publicGetData(newData);
this.publicLocalStorage();
});
} else {
......@@ -323,7 +330,7 @@ class Order extends Component {
return;
}
this.publicGetData(res);
this.publicGetData(res.data.data);
this.publicLocalStorage();
})
// }
......@@ -347,6 +354,7 @@ class Order extends Component {
useBalance,
info,
offset,
groupPrice
} = this.state;
return (
......@@ -402,7 +410,7 @@ class Order extends Component {
compute={this.computedMoney}
courseId={getParam('id')}
locationState={this.props.location.state}
groupPrice={this.groupPrice}
groupPrice={groupPrice}
toDetail={this.toCourseDetail}
/>
</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