完善茶室订单
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
<route lang="jsonc" type="page">
|
||||
{
|
||||
"needLogin": true,
|
||||
"layout": "default",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
@ -15,24 +16,24 @@
|
||||
|
||||
<view>
|
||||
<view class="mt-30rpx">
|
||||
<view v-if="couponType == 1">
|
||||
<view v-if="couponType == 1">
|
||||
<!-- 优惠券 -->
|
||||
<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>
|
||||
<text class="text-[#606266] font-400 text-28rpx leading-40rpx ml-24rpx">{{ couponList.no_use.length }}张</text>
|
||||
</view>
|
||||
<view class="mt-28rpx radio">
|
||||
<wd-radio-group v-model="checkedId" size="large" checked-color="#4C9F44">
|
||||
<coupon
|
||||
v-for="(item, index) in couponList"
|
||||
v-for="(item, index) in couponList.use"
|
||||
:key="item.id"
|
||||
:coupon="item"
|
||||
canUse
|
||||
showChecked
|
||||
:checked="item.id === checkedId"
|
||||
:onCheck="coupons.handleCheck"
|
||||
:class="index !== couponList.length - 1 ? 'mb-20rpx' : ''"
|
||||
:onCheck="Coupons.handleCheck"
|
||||
:class="index !== couponList.use.length - 1 ? 'mb-20rpx' : ''"
|
||||
></coupon>
|
||||
</wd-radio-group>
|
||||
</view>
|
||||
@ -40,19 +41,19 @@
|
||||
<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>
|
||||
<text class="text-[#606266] font-400 text-28rpx leading-40rpx ml-24rpx">{{ couponList.no_use.length }}张</text>
|
||||
</view>
|
||||
<view class="mt-28rpx radio">
|
||||
<wd-radio-group v-model="checkedId" size="large" checked-color="#4C9F44">
|
||||
<coupon
|
||||
v-for="(item, index) in unCouponList"
|
||||
v-for="(item, index) in couponList.no_use"
|
||||
:key="item.id"
|
||||
:coupon="item"
|
||||
:canUse="false"
|
||||
showChecked
|
||||
:checked="item.id === checkedId"
|
||||
:onCheck="coupons.handleCheck"
|
||||
:class="index !== couponList.length - 1 ? 'mb-20rpx' : ''"
|
||||
:onCheck="Coupons.handleCheck"
|
||||
:class="index !== couponList.no_use.length - 1 ? 'mb-20rpx' : ''"
|
||||
></coupon>
|
||||
</wd-radio-group>
|
||||
</view>
|
||||
@ -74,7 +75,7 @@
|
||||
:coupon="item"
|
||||
canUse
|
||||
:checked="item.id === checkedId"
|
||||
:onCheck="coupons.handleCheck"
|
||||
:onCheck="Coupons.handleCheck"
|
||||
:class="index !== couponList.length - 1 ? 'mb-20rpx' : ''"
|
||||
></group-coupon>
|
||||
</wd-radio-group>
|
||||
@ -93,7 +94,7 @@
|
||||
:coupon="item"
|
||||
:canUse="false"
|
||||
:checked="item.id === checkedId"
|
||||
:onCheck="coupons.handleCheck"
|
||||
:onCheck="Coupons.handleCheck"
|
||||
:class="index !== couponList.length - 1 ? 'mb-20rpx' : ''"
|
||||
></group-coupon>
|
||||
</wd-radio-group>
|
||||
@ -104,26 +105,27 @@
|
||||
</view>
|
||||
|
||||
<view class="fixed left-0 right-0 bottom-0 z-2 bg-[#fff] flex justify-between items-center" :style="{ height: '140rpx'}">
|
||||
<view class="ml-60rpx text-[#121212] text-24rpx leading-34rpx">已选择1张</view>
|
||||
<view class="ml-60rpx text-[#121212] text-24rpx leading-34rpx">已选择{{ checkedId ? 1 : 0 }}张</view>
|
||||
<view class="mr-30rpx">
|
||||
<wd-button custom-class='!bg-[#4C9F44] !rounded-8rpx !h-70rpx'>确定</wd-button>
|
||||
<wd-button custom-class='!bg-[#4C9F44] !rounded-8rpx !h-70rpx' @click="Coupons.handleConfirmCoupon">确定</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {ref} from 'vue'
|
||||
import Coupon from '@/components/coupon/Coupon.vue'
|
||||
import GroupCoupon from '@/components/coupon/GroupCoupon.vue'
|
||||
import { getCoupons } from '@/api/user'
|
||||
import type { IUserCouponListResult } from '@/api/types/user'
|
||||
import { router } from '@/utils/tools'
|
||||
|
||||
const couponType = ref<number>(2) // couponType 1:优惠券 2:团购券
|
||||
const OSS = inject('OSS')
|
||||
|
||||
const couponList = ref([
|
||||
{ id: 1, amount: 20, limit: 100, expire: '2024.08.20' },
|
||||
{ id: 2, amount: 10, limit: 50, expire: '2024.08.25' }
|
||||
])
|
||||
const couponList = ref<IUserCouponListResult>({
|
||||
no_use: [],
|
||||
use: []
|
||||
})
|
||||
const checkedId = ref<number>(0)
|
||||
|
||||
const unCouponList = ref([
|
||||
@ -131,16 +133,46 @@
|
||||
{ id: 2, amount: 10, limit: 50, expire: '2024.08.25' }
|
||||
])
|
||||
|
||||
const teaRoomId = ref<number>(0) // 包间ID
|
||||
|
||||
onLoad((args) => {
|
||||
if (args.type) {
|
||||
couponType.value = args.type
|
||||
teaRoomId.value = args.id
|
||||
|
||||
couponType.value = args.type // 1:优惠券 2:团购券
|
||||
|
||||
// 初始化优惠券数据
|
||||
if (args.id && args.numbers && args.type == 1) {
|
||||
// 获取到包间ID和预定了几个小时
|
||||
Coupons.handleInitCoupon(args.id, args.numbers)
|
||||
}
|
||||
})
|
||||
|
||||
const coupons = {
|
||||
const Coupons = {
|
||||
/**
|
||||
* 初始化优惠券列表
|
||||
* @param id 包间ID
|
||||
* @param numbers 预定时长
|
||||
*/
|
||||
handleInitCoupon: async (id: number, numbers: number) => {
|
||||
const res = await getCoupons({id, numbers, type_id: 2})
|
||||
couponList.value = res
|
||||
},
|
||||
|
||||
/**
|
||||
* 选择优惠券
|
||||
* @param id 优惠券ID
|
||||
*/
|
||||
handleCheck: (id: number) => {
|
||||
checkedId.value = id
|
||||
console.log("🚀 ~ checkedId.value :", checkedId.value )
|
||||
},
|
||||
|
||||
/**
|
||||
* 确认选择优惠券
|
||||
*/
|
||||
handleConfirmCoupon: () => {
|
||||
const coupon = couponList.value.use.find(item => item.user_coupon_id === checkedId.value)
|
||||
uni.$emit('chooseCoupon', { coupon })
|
||||
router.navigateBack()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user