完善页面
This commit is contained in:
@ -21,7 +21,7 @@
|
||||
<view class="mx-30rpx">
|
||||
<view class="mx30rpx">
|
||||
<text class="text-[#303133] font-bold text-30rpx leading-42rpx">可用优惠券</text>
|
||||
<text class="text-[#606266] font-400 text-28rpx leading-40rpx ml-24rpx">{{ couponList.no_use.length }}张</text>
|
||||
<text class="text-[#606266] font-400 text-28rpx leading-40rpx ml-24rpx">{{ couponList.use.length }}张</text>
|
||||
</view>
|
||||
<view class="mt-28rpx radio">
|
||||
<wd-radio-group v-model="checkedId" size="large" checked-color="#4C9F44">
|
||||
@ -70,18 +70,18 @@
|
||||
<view class="mt-28rpx radio">
|
||||
<wd-radio-group v-model="checkedId" size="large" checked-color="#4C9F44">
|
||||
<group-coupon
|
||||
v-for="(item, index) in couponList"
|
||||
v-for="(item, index) in groupCouponList"
|
||||
:key="item.id"
|
||||
:coupon="item"
|
||||
canUse
|
||||
:checked="item.id === checkedId"
|
||||
:onCheck="Coupons.handleCheck"
|
||||
:class="index !== couponList.length - 1 ? 'mb-20rpx' : ''"
|
||||
:class="index !== groupCouponList.length - 1 ? 'mb-20rpx' : ''"
|
||||
></group-coupon>
|
||||
</wd-radio-group>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mx-30rpx">
|
||||
<!-- <view class="mx-30rpx">
|
||||
<view class="mx30rpx">
|
||||
<text class="text-[#303133] font-bold text-30rpx leading-42rpx">不可用团购券</text>
|
||||
<text class="text-[#606266] font-400 text-28rpx leading-40rpx ml-24rpx">2张</text>
|
||||
@ -99,7 +99,7 @@
|
||||
></group-coupon>
|
||||
</wd-radio-group>
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -117,8 +117,10 @@
|
||||
import Coupon from '@/components/coupon/Coupon.vue'
|
||||
import GroupCoupon from '@/components/coupon/GroupCoupon.vue'
|
||||
import { getCoupons } from '@/api/user'
|
||||
import { getTeaRoomGroupCouponList } from '@/api/tea-room'
|
||||
import type { IUserCouponListResult } from '@/api/types/user'
|
||||
import { router } from '@/utils/tools'
|
||||
import { CouponType } from '@/utils/coupon'
|
||||
|
||||
const couponType = ref<number>(2) // couponType 1:优惠券 2:团购券
|
||||
|
||||
@ -126,6 +128,7 @@
|
||||
no_use: [],
|
||||
use: []
|
||||
})
|
||||
const groupCouponList = ref<any>()
|
||||
const checkedId = ref<number>(0)
|
||||
|
||||
const unCouponList = ref([
|
||||
@ -133,17 +136,20 @@
|
||||
{ id: 2, amount: 10, limit: 50, expire: '2024.08.25' }
|
||||
])
|
||||
|
||||
const storeId = ref<number>(0) // 门店ID
|
||||
const teaRoomId = ref<number>(0) // 包间ID
|
||||
|
||||
|
||||
onLoad((args) => {
|
||||
teaRoomId.value = args.id
|
||||
|
||||
storeId.value = args.storeId || 0
|
||||
couponType.value = args.type // 1:优惠券 2:团购券
|
||||
|
||||
// 初始化优惠券数据
|
||||
if (args.id && args.numbers && args.type == 1) {
|
||||
// 获取到包间ID和预定了几个小时
|
||||
Coupons.handleInitCoupon(args.id, args.numbers)
|
||||
} else if (args.id && args.type == 2) {
|
||||
Coupons.handleInitGroupCoupon(args.id, args.numbers)
|
||||
}
|
||||
})
|
||||
|
||||
@ -158,6 +164,14 @@
|
||||
couponList.value = res
|
||||
},
|
||||
|
||||
/**
|
||||
* 初始化团购券列表
|
||||
*/
|
||||
handleInitGroupCoupon: async (id: number, numbers: number) => {
|
||||
const res = await getTeaRoomGroupCouponList({store_id: storeId.value})
|
||||
groupCouponList.value = res.list
|
||||
},
|
||||
|
||||
/**
|
||||
* 选择优惠券
|
||||
* @param id 优惠券ID
|
||||
@ -170,7 +184,12 @@
|
||||
* 确认选择优惠券
|
||||
*/
|
||||
handleConfirmCoupon: () => {
|
||||
const coupon = couponList.value.use.find(item => item.user_coupon_id === checkedId.value)
|
||||
let coupon = null
|
||||
if (couponType.value == CouponType.Discount) {
|
||||
coupon = couponList.value.use.find(item => item.user_coupon_id === checkedId.value)
|
||||
} else {
|
||||
coupon = groupCouponList.value.find(item => item.id === checkedId.value)
|
||||
}
|
||||
uni.$emit('chooseCoupon', { coupon })
|
||||
router.navigateBack()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user