|
@@ -20,13 +20,17 @@ export default defineComponent({
|
|
|
couponCategory: {
|
|
|
type: String,
|
|
|
default: 'UNIVERSAL'
|
|
|
+ },
|
|
|
+ couponList: {
|
|
|
+ type: Array,
|
|
|
+ default: () => []
|
|
|
}
|
|
|
},
|
|
|
emits: ['close', 'submit'],
|
|
|
data() {
|
|
|
return {
|
|
|
- list: [],
|
|
|
- consumeAmount: 0, // 消耗金额
|
|
|
+ list: [] as any,
|
|
|
+ // consumeAmount: 0 // 消耗金额
|
|
|
dataLoading: false
|
|
|
}
|
|
|
},
|
|
@@ -37,55 +41,68 @@ export default defineComponent({
|
|
|
}
|
|
|
},
|
|
|
async mounted() {
|
|
|
- this.getList()
|
|
|
+ // this.getList()
|
|
|
+ // 处理显示已选择的优惠券
|
|
|
+ // 处理可用优惠券是否支付使用
|
|
|
+ this.couponList.forEach((item: any) => {
|
|
|
+ this.useCoupon.forEach((coupon: any) => {
|
|
|
+ if (item.couponIssueId === coupon.couponIssueId) {
|
|
|
+ item.checked = true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ const canUsable = this.couponList.filter((list: any) => !list.disabled)
|
|
|
+ const canUsed = this.couponList.filter((list: any) => list.disabled)
|
|
|
+ this.list = [...canUsable, ...canUsed]
|
|
|
+ this.calcCoupon()
|
|
|
},
|
|
|
methods: {
|
|
|
- async getList() {
|
|
|
- if (this.dataLoading) return
|
|
|
- this.dataLoading = true
|
|
|
- try {
|
|
|
- const res = await request.post(`${state.platformApi}/couponInfo/page`, {
|
|
|
- data: {
|
|
|
- couponCategory: this.couponCategory,
|
|
|
- couponType: 'FULL_DISCOUNT',
|
|
|
- useState: 'USABLE',
|
|
|
- page: 1,
|
|
|
- rows: 100
|
|
|
- }
|
|
|
- })
|
|
|
- this.dataLoading = false
|
|
|
- const result = res.data || {}
|
|
|
- // 处理重复请求数据
|
|
|
- if (this.list.length > 0 && result.pageNo === 1) return
|
|
|
- this.list = result.rows || []
|
|
|
+ // async getList() {
|
|
|
+ // if (this.dataLoading) return
|
|
|
+ // this.dataLoading = true
|
|
|
+ // try {
|
|
|
+ // const res = await request.post(`${state.platformApi}/couponInfo/page`, {
|
|
|
+ // data: {
|
|
|
+ // couponCategory: this.couponCategory,
|
|
|
+ // couponType: 'FULL_DISCOUNT',
|
|
|
+ // useState: 'USABLE',
|
|
|
+ // page: 1,
|
|
|
+ // rows: 100
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // this.dataLoading = false
|
|
|
+ // const result = res.data || {}
|
|
|
+ // // 处理重复请求数据
|
|
|
+ // if (this.list.length > 0 && result.pageNo === 1) return
|
|
|
+ // this.list = result.rows || []
|
|
|
|
|
|
- // 处理可用优惠券是否支付使用
|
|
|
- this.list.forEach((item: any) => {
|
|
|
- item.checked = false
|
|
|
- // 如果使用金额大于订单金额则优惠券不可用
|
|
|
- if (item.useLimit > this.orderAmount) {
|
|
|
- item.disabled = true
|
|
|
- } else {
|
|
|
- item.disabled = false
|
|
|
- }
|
|
|
+ // // 处理可用优惠券是否支付使用
|
|
|
+ // this.list.forEach((item: any) => {
|
|
|
+ // item.checked = false
|
|
|
+ // // 如果使用金额大于订单金额则优惠券不可用
|
|
|
+ // if (item.useLimit > this.orderAmount) {
|
|
|
+ // item.disabled = true
|
|
|
+ // } else {
|
|
|
+ // item.disabled = false
|
|
|
+ // }
|
|
|
|
|
|
- // 处理显示已选择的优惠券
|
|
|
- this.useCoupon.forEach((coupon: any) => {
|
|
|
- if (item.couponIssueId === coupon.couponIssueId) {
|
|
|
- item.checked = true
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
- // 初始化排序
|
|
|
- const canUsable = this.list.filter((list: any) => !list.disabled)
|
|
|
- const canUsed = this.list.filter((list: any) => list.disabled)
|
|
|
- this.list = [...canUsable, ...canUsed]
|
|
|
+ // // 处理显示已选择的优惠券
|
|
|
+ // this.useCoupon.forEach((coupon: any) => {
|
|
|
+ // if (item.couponIssueId === coupon.couponIssueId) {
|
|
|
+ // item.checked = true
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // })
|
|
|
+ // // 初始化排序
|
|
|
+ // const canUsable = this.list.filter((list: any) => !list.disabled)
|
|
|
+ // const canUsed = this.list.filter((list: any) => list.disabled)
|
|
|
+ // this.list = [...canUsable, ...canUsed]
|
|
|
|
|
|
- this.calcCoupon()
|
|
|
- } catch {
|
|
|
- //
|
|
|
- }
|
|
|
- },
|
|
|
+ // this.calcCoupon()
|
|
|
+ // } catch {
|
|
|
+ // //
|
|
|
+ // }
|
|
|
+ // },
|
|
|
onSubmit() {
|
|
|
// 返回选中的优惠券
|
|
|
this.$emit(
|
|
@@ -118,7 +135,7 @@ export default defineComponent({
|
|
|
const useLastAmount = this.orderAmount - usePrice
|
|
|
// 判断使用优惠券之后还有没有其它优惠券可用
|
|
|
this.list.forEach((item: any) => {
|
|
|
- if (Number(item.useLimit) >= useLastAmount && !item.checked) {
|
|
|
+ if (Number(item.useLimit) > useLastAmount && !item.checked) {
|
|
|
item.disabled = true
|
|
|
} else {
|
|
|
item.disabled = false
|