修改代码

This commit is contained in:
wangxiaowei
2026-02-02 02:36:40 +08:00
parent 6edd1b24d3
commit 079a66f287
14 changed files with 460 additions and 248 deletions

View File

@ -57,6 +57,7 @@
import type { IUserCouponListResult } from '@/api/types/user'
import { router } from '@/utils/tools'
import { CouponType } from '@/utils/coupon'
import { getCoupons } from '@/api/user'
const couponType = ref<number>(2) // couponType 1:优惠券 2:团购券
@ -67,21 +68,17 @@
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
// 可用优惠券数量
const useCoupon = ref<number>(0)
onLoad(async (args) => {
teaRoomId.value = args.id
storeId.value = args.storeId || 0
checkedId.value = args.couponId || 0
await Coupons.handleInitCoupon()
await Coupons.handleInitCoupon(args.price)
checkedId.value = Number(args.couponId) || 0
})
@ -89,15 +86,18 @@
/**
* 初始化优惠券列表
*/
handleInitCoupon: async () => {
const res = await getTeaSpecialistCoupons()
const coupon = res.map( item => {
return {
...item,
user_coupon_id: item.id,
}
})
couponList.value.use = coupon
handleInitCoupon: async (price) => {
// const res = await getTeaSpecialistCoupons()
// const coupon = res.map( item => {
// return {
// ...item,
// user_coupon_id: item.id,
// }
// })
// couponList.value.use = coupon
const res = await getCoupons({type_id: 1, price}) // 1茶艺师 2茶室 3 个人中心
useCoupon.value = res.count.yes_use
couponList.value.use = res.result.filter(item => item.is_use == 0)
console.log("🚀 ~ couponList.value.use:", couponList.value.use)
},
@ -106,13 +106,13 @@
* @param id 优惠券ID
*/
handleCheck: (id: number) => {
console.log("🚀 ~ id:", id)
// 如果是优惠券的话则是可以取消选择
if (checkedId.value === id) {
checkedId.value = 0 // 再次点击已选中时取消选择
} else {
checkedId.value = id
}
console.log("🚀 ~ checkedId.value:", checkedId.value)
},
/**
@ -121,7 +121,7 @@
handleConfirmCoupon: () => {
let coupon = null
coupon = couponList.value.use.find(item => {
return item.user_coupon_id === checkedId.value
return item.id === checkedId.value
})
uni.$emit('chooseCoupon', { coupon })
router.navigateBack()

View File

@ -87,7 +87,9 @@
class="flex items-center bg-white p-20rpx rounded-10rpx mx-30rpx mb-20rpx relative"
v-for="(item, index) in list" :key="index" >
<view class="tea-specialist-time absolute z-3 top-6rpx left-0 bg-[#4C9F44] text-[#fff] font-400 text-18rpx flex items-center justify-center">
{{ item.state == 0 ? '可约' : '工作中' }}
<text v-if="item.state == 0">可约</text>
<text v-if="item.state == 1">工作中</text>
<text v-if="item.state == 2">不可约</text>
</view>
<view class="mr-28rpx relative z-2" @click="List.handlePreviewImage(item.image)">
<wd-img width="200rpx" height="200rpx" :src="item.image" mode="aspectFill"></wd-img>

View File

@ -662,6 +662,11 @@
return
}
if (info.value.state === 2) {
toast.show('茶艺师已离线,暂不可预约')
return
}
if (serviceTypeValue.value === 1 && teaHouse.value.id === 0) {
// 到店服务必须要选择门店
toast.show('请先选择门店')
@ -789,6 +794,7 @@
uni.$off('chooseCoupon');
uni.$on('chooseCoupon', params => {
console.log("🚀 ~ params:", params)
uni.$off('chooseCoupon')
if (params.coupon) {
selectedCoupon.value = {id: params.coupon.id, name: params.coupon.name}
@ -807,7 +813,7 @@
})
// 获取预定了几个小时
router.navigateTo(`/bundle_b/pages/tea-specialist/coupon?couponId=${selectCouponId.value}`)
router.navigateTo(`/bundle_b/pages/tea-specialist/coupon?couponId=${selectCouponId.value}&price=${costBill.value.order_amount}`)
},
/**
@ -848,6 +854,11 @@
if (info.value.state === 1) {
toast.show('茶艺师工作中,暂不可预约')
return
}
if (info.value.state === 2) {
toast.show('茶艺师已离线,暂不可预约')
return
}
if (totalHour.value == 0) {