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