修改代码
This commit is contained in:
@ -51,7 +51,7 @@
|
||||
:key="item.id"
|
||||
:coupon="item"
|
||||
:canUse="false"
|
||||
showChecked
|
||||
:showChecked="false"
|
||||
couponType="coupon"
|
||||
:checked="item.id === checkedId"
|
||||
:onCheck="Coupons.handleCheck"
|
||||
@ -131,14 +131,15 @@
|
||||
no_use: [],
|
||||
use: []
|
||||
})
|
||||
|
||||
// 可用优惠券数量
|
||||
const useCoupon = ref<number>(0)
|
||||
// 不可用优惠券数量
|
||||
const unUseCoupon = ref<number>(0)
|
||||
|
||||
const groupCouponList = ref<Array<any>>([])
|
||||
const checkedId = ref<number>(0)
|
||||
|
||||
const unCouponList = ref([
|
||||
{ id: 1, amount: 20, limit: 100, expire: '2024.08.20' },
|
||||
{ id: 2, amount: 10, limit: 50, expire: '2024.08.25' }
|
||||
])
|
||||
|
||||
const storeId = ref<number>(0) // 门店ID
|
||||
const teaRoomId = ref<number>(0) // 包间ID
|
||||
const couponId = ref<number>(0) // 选中的优惠券ID
|
||||
@ -151,7 +152,7 @@
|
||||
// 初始化优惠券数据
|
||||
if (args.id && args.numbers && args.type == 1) {
|
||||
// 获取到包间ID和预定了几个小时
|
||||
await Coupons.handleInitCoupon(args.id, args.numbers)
|
||||
await Coupons.handleInitCoupon(args.price)
|
||||
checkedId.value = Number(args.couponId) || 0
|
||||
|
||||
} else if (args.id && args.type == 2) {
|
||||
@ -167,9 +168,19 @@
|
||||
* @param id 包间ID
|
||||
* @param numbers 预定时长
|
||||
*/
|
||||
handleInitCoupon: async (id: number, numbers: number) => {
|
||||
const res = await getCoupons({id, numbers, type_id: 2})
|
||||
couponList.value = res
|
||||
handleInitCoupon: async (price: number) => {
|
||||
const res = await getCoupons({type_id: 2, price}) // 1茶艺师 2茶室 3 个人中心
|
||||
// couponList.value = res
|
||||
useCoupon.value = res.count.yes_use
|
||||
unUseCoupon.value = res.count.no_use
|
||||
|
||||
if (res.result.length > 0) {
|
||||
couponList.value.use = res.result.filter(item => item.is_use == 0)
|
||||
couponList.value.no_use = res.result.filter(item => item.is_use == 1)
|
||||
}
|
||||
console.log("🚀 ~ couponList.value:", couponList.value)
|
||||
console.log("🚀 ~ couponList.value:", useCoupon.value)
|
||||
console.log("🚀 ~ couponList.value:", unUseCoupon.value)
|
||||
},
|
||||
|
||||
/**
|
||||
@ -201,7 +212,7 @@
|
||||
|
||||
if (checkedId.value > 0) {
|
||||
if (couponType.value == CouponType.Discount) {
|
||||
coupon = couponList.value.use.find(item => item.user_coupon_id === checkedId.value)
|
||||
coupon = couponList.value.use.find(item => item.id === checkedId.value)
|
||||
} else {
|
||||
coupon = groupCouponList.value.find(item => item.id === checkedId.value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user