|
@@ -1,4 +1,6 @@
|
|
import ColResult from '@/components/col-result'
|
|
import ColResult from '@/components/col-result'
|
|
|
|
+import request from '@/helpers/request'
|
|
|
|
+import { state } from '@/state'
|
|
import Item from '@/views/coupons/item'
|
|
import Item from '@/views/coupons/item'
|
|
import { Button, Loading } from 'vant'
|
|
import { Button, Loading } from 'vant'
|
|
import { defineComponent } from 'vue'
|
|
import { defineComponent } from 'vue'
|
|
@@ -11,7 +13,7 @@ export const list = [
|
|
useLimit: '30',
|
|
useLimit: '30',
|
|
endTime: new Date(),
|
|
endTime: new Date(),
|
|
id: 1,
|
|
id: 1,
|
|
- name: '小酷Ai充值券',
|
|
|
|
|
|
+ couponName: '小酷Ai充值券',
|
|
startTime: new Date(),
|
|
startTime: new Date(),
|
|
useState: 'USABLE',
|
|
useState: 'USABLE',
|
|
useTime: new Date()
|
|
useTime: new Date()
|
|
@@ -22,7 +24,7 @@ export const list = [
|
|
useLimit: '20',
|
|
useLimit: '20',
|
|
endTime: new Date(),
|
|
endTime: new Date(),
|
|
id: 2,
|
|
id: 2,
|
|
- name: '小酷Ai充值券',
|
|
|
|
|
|
+ couponName: '小酷Ai充值券',
|
|
startTime: new Date(),
|
|
startTime: new Date(),
|
|
useState: 'USABLE',
|
|
useState: 'USABLE',
|
|
useTime: new Date()
|
|
useTime: new Date()
|
|
@@ -33,7 +35,7 @@ export const list = [
|
|
useLimit: '10',
|
|
useLimit: '10',
|
|
endTime: new Date(),
|
|
endTime: new Date(),
|
|
id: 3,
|
|
id: 3,
|
|
- name: '小酷Ai充值券',
|
|
|
|
|
|
+ couponName: '小酷Ai充值券',
|
|
startTime: new Date(),
|
|
startTime: new Date(),
|
|
useState: 'USABLE',
|
|
useState: 'USABLE',
|
|
useTime: new Date()
|
|
useTime: new Date()
|
|
@@ -44,7 +46,7 @@ export const list = [
|
|
useLimit: '29',
|
|
useLimit: '29',
|
|
endTime: new Date(),
|
|
endTime: new Date(),
|
|
id: 0,
|
|
id: 0,
|
|
- name: '小酷Ai充值券',
|
|
|
|
|
|
+ couponName: '小酷Ai充值券',
|
|
startTime: new Date(),
|
|
startTime: new Date(),
|
|
useState: 'USABLE',
|
|
useState: 'USABLE',
|
|
useTime: new Date()
|
|
useTime: new Date()
|
|
@@ -65,7 +67,7 @@ export default defineComponent({
|
|
emits: ['close', 'submit'],
|
|
emits: ['close', 'submit'],
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
- list: list,
|
|
|
|
|
|
+ list: [],
|
|
consumeAmount: 0, // 消耗金额
|
|
consumeAmount: 0, // 消耗金额
|
|
dataLoading: false
|
|
dataLoading: false
|
|
}
|
|
}
|
|
@@ -82,8 +84,24 @@ export default defineComponent({
|
|
methods: {
|
|
methods: {
|
|
async getList() {
|
|
async getList() {
|
|
this.dataLoading = true
|
|
this.dataLoading = true
|
|
- setTimeout(() => {
|
|
|
|
|
|
+ try {
|
|
|
|
+ // 判断是哪个端
|
|
|
|
+ const url =
|
|
|
|
+ state.platformType === 'STUDENT' ? '/api-student' : '/api-teacher'
|
|
|
|
+ const res = await request.post(`${url}/couponInfo/page`, {
|
|
|
|
+ data: {
|
|
|
|
+ useState: 'USABLE',
|
|
|
|
+
|
|
|
|
+ page: 1,
|
|
|
|
+ rows: 100
|
|
|
|
+ }
|
|
|
|
+ })
|
|
this.dataLoading = false
|
|
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) => {
|
|
this.list.forEach((item: any) => {
|
|
// 如果使用金额大于订单金额则优惠券不可用
|
|
// 如果使用金额大于订单金额则优惠券不可用
|
|
@@ -108,7 +126,9 @@ export default defineComponent({
|
|
this.list = [...canUsable, ...canUsed]
|
|
this.list = [...canUsable, ...canUsed]
|
|
|
|
|
|
this.calcCoupon()
|
|
this.calcCoupon()
|
|
- }, 300)
|
|
|
|
|
|
+ } catch {
|
|
|
|
+ //
|
|
|
|
+ }
|
|
},
|
|
},
|
|
onSubmit() {
|
|
onSubmit() {
|
|
// 返回选中的优惠券
|
|
// 返回选中的优惠券
|