Commit ecf63dbe by zhanghaozhe

膨胀券排序

parent 08c3adaa
...@@ -6,7 +6,6 @@ import Coupon from '../Coupon' ...@@ -6,7 +6,6 @@ import Coupon from '../Coupon'
import { http, getParam } from '@/utils' import { http, getParam } from '@/utils'
import { WithFullSize } from '@/HOCs' import { WithFullSize } from '@/HOCs'
import { Toast } from 'antd-mobile' import { Toast } from 'antd-mobile'
import { isEmpty } from 'lodash'
import { connect } from 'react-redux' import { connect } from 'react-redux'
@connect() @connect()
...@@ -110,19 +109,13 @@ class UseCoupon extends PureComponent { ...@@ -110,19 +109,13 @@ class UseCoupon extends PureComponent {
getMyCoupons = () => { getMyCoupons = () => {
Promise.all([ Promise.all([
http.get(`${API.home}/m/coupon/all`), http.get(`${API.home}/m/coupon/expansion`),
http.get(`${API.home}/m/coupon/expansion`) http.get(`${API.home}/m/coupon/all`)
]).then((coupons) => { ]).then((coupons) => {
let myCoupons = [] let myCoupons = []
const [allCoupons, expansionCoupons] = coupons const [expansionCoupons, allCoupons] = coupons
const {data: all} = allCoupons const {data: all} = allCoupons
const {data: expansion} = expansionCoupons const {data: expansion} = expansionCoupons
if (all.code == 200) {
Array.isArray(all.data) && (myCoupons = myCoupons.concat(all.data))
} else {
Toast.info(all.msg)
}
if (expansion.code == 200) { if (expansion.code == 200) {
Array.isArray(expansion.data) Array.isArray(expansion.data)
&& (expansion.data = expansion.data.map(item => (item.ctype = 4, item))) && (expansion.data = expansion.data.map(item => (item.ctype = 4, item)))
...@@ -130,6 +123,11 @@ class UseCoupon extends PureComponent { ...@@ -130,6 +123,11 @@ class UseCoupon extends PureComponent {
} else { } else {
Toast.info(expansion.msg) Toast.info(expansion.msg)
} }
if (all.code == 200) {
Array.isArray(all.data) && (myCoupons = myCoupons.concat(all.data))
} else {
Toast.info(all.msg)
}
this.setState({ this.setState({
couponList: myCoupons couponList: myCoupons
...@@ -139,12 +137,21 @@ class UseCoupon extends PureComponent { ...@@ -139,12 +137,21 @@ class UseCoupon extends PureComponent {
getAllCoupons = () => { getAllCoupons = () => {
Promise.all([ Promise.all([
http.post(`${API.home}/m/coupon/select`, {course_id: this.state.courseId}), http.get(`${API.home}/m/coupon/expansion`),
http.get(`${API.home}/m/coupon/expansion`) http.post(`${API.home}/m/coupon/select`, {course_id: this.state.courseId})
]).then((coupons) => { ]).then((coupons) => {
const [selectCoupons, expansionCoupons] = coupons const [expansionCoupons, selectCoupons] = coupons
const {data: select} = selectCoupons const {data: select} = selectCoupons
const {data: expansion} = expansionCoupons const {data: expansion} = expansionCoupons
if (expansion.code == 200) {
Array.isArray(expansion.data)
&& (expansion.data = expansion.data.map(item => (item.ctype = 4, item)))
&& (this.setState({
valid_coupons: this.state.valid_coupons.concat(expansion.data)
}))
} else {
Toast.info(expansion.msg)
}
if (select.code === 200) { if (select.code === 200) {
const inuse_coupon = select.data['inuse_coupon'] const inuse_coupon = select.data['inuse_coupon']
this.setState({ this.setState({
...@@ -158,15 +165,6 @@ class UseCoupon extends PureComponent { ...@@ -158,15 +165,6 @@ class UseCoupon extends PureComponent {
} else { } else {
Toast.info(data.msg) Toast.info(data.msg)
} }
if (expansion.code == 200) {
Array.isArray(expansion.data)
&& (expansion.data = expansion.data.map(item => (item.ctype = 4, item)))
&& (this.setState({
valid_coupons: this.state.valid_coupons.concat(expansion.data)
}))
} else {
Toast.info(expansion.msg)
}
}) })
......
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