优化功能

This commit is contained in:
wangxiaowei
2026-01-14 18:11:26 +08:00
parent f5e77e997b
commit b7e2d5d4c9
7 changed files with 87 additions and 42 deletions

View File

@ -54,7 +54,7 @@
</template> </template>
<script lang="ts" setup name="DouYinExcharge"> <script lang="ts" setup name="DouYinExcharge">
import { useMessage, useToast } from 'wot-design-uni' import { useMessage, useToast } from 'wot-design-uni'
import { checkDouyinCoupon } from '@/api/user' import { checkDouyinCoupon } from '@/api/user'
import { router } from '@/utils/tools' import { router } from '@/utils/tools'

View File

@ -64,6 +64,7 @@
<!-- 团购券 --> <!-- 团购券 -->
<view v-if="couponType == 2"> <view v-if="couponType == 2">
checkedId--{{checkedId}}
<view class="mx-30rpx"> <view class="mx-30rpx">
<view class="mx30rpx"> <view class="mx30rpx">
<text class="text-[#303133] font-bold text-30rpx leading-42rpx">可用团购券</text> <text class="text-[#303133] font-bold text-30rpx leading-42rpx">可用团购券</text>
@ -181,11 +182,16 @@
}, },
/** /**
* 选择优惠券 * 选择/取消选择优惠券
* @param id 优惠券ID * @param id 优惠券ID
*/ */
handleCheck: (id: number) => { handleCheck: (id: number) => {
checkedId.value = id // 如果是优惠券的话则是可以取消选择
if (couponType.value == 1 && checkedId.value === id) {
checkedId.value = 0 // 再次点击已选中时取消选择
} else {
checkedId.value = id
}
}, },
/** /**
@ -193,12 +199,14 @@
*/ */
handleConfirmCoupon: () => { handleConfirmCoupon: () => {
let coupon = null let coupon = null
if (couponType.value == CouponType.Discount) {
coupon = couponList.value.use.find(item => item.user_coupon_id === checkedId.value) if (checkedId.value > 0) {
} else { if (couponType.value == CouponType.Discount) {
coupon = groupCouponList.value.find(item => item.id === checkedId.value) coupon = couponList.value.use.find(item => item.user_coupon_id === checkedId.value)
} else {
coupon = groupCouponList.value.find(item => item.id === checkedId.value)
}
} }
console.log("🚀 ~ coupon:", coupon)
uni.$emit('chooseCoupon', { coupon }) uni.$emit('chooseCoupon', { coupon })
router.navigateBack() router.navigateBack()

View File

@ -68,7 +68,7 @@
<view> <view>
<view class="mt-20rpx mx-30rpx swiper"> <view class="mt-20rpx mx-30rpx swiper">
<wd-swiper value-key="image" height="320rpx" <wd-swiper value-key="image" height="320rpx"
:indicator="{ type: 'dots-bar' }" :list="swiperList" v-model:current="current" mode="aspectFit"> :indicator="{ type: 'dots-bar' }" :list="swiperList" v-model:current="current" mode="aspectFit" @click="Detail.handlePreviewImage">
</wd-swiper> </wd-swiper>
</view> </view>
@ -90,7 +90,7 @@
<view class="text-[#303133] text-26rpx leading-48rpx font-500" v-if="isGroupBuying">{{ teaRoomPackage.description }}</view> <view class="text-[#303133] text-26rpx leading-48rpx font-500" v-if="isGroupBuying">{{ teaRoomPackage.description }}</view>
<view class="text-[#6A6363] flex-1 text-22rpx leading-32rpx text-right">已售 <view class="text-[#6A6363] flex-1 text-22rpx leading-32rpx text-right">已售
<template v-if="isGroupBuying"> <template v-if="isGroupBuying">
{{ teaRoomPackage.sold > 10 ? '10+' : teaRoomPackage.sold }} {{ teaRoomPackage.sold + '+' }}
</template> </template>
<template v-else> <template v-else>
{{ teaRoom.room?.sold > 10 ? '10+' : teaRoom.room?.sold }} {{ teaRoom.room?.sold > 10 ? '10+' : teaRoom.room?.sold }}
@ -285,7 +285,7 @@
import type { ITeaSpecialistFuture7DaysResult } from '@/api/types/tea' import type { ITeaSpecialistFuture7DaysResult } from '@/api/types/tea'
import { getNext7Days, getTeaRoomBalance, createTeaRoomOrder } from '@/api/tea-room' import { getNext7Days, getTeaRoomBalance, createTeaRoomOrder } from '@/api/tea-room'
import { CouponType } from '@/utils/coupon' import { CouponType } from '@/utils/coupon'
import { router, randomLabelColor } from '@/utils/tools' import { router, randomLabelColor, previewImage } from '@/utils/tools'
import type { IUserInfoVo } from '@/api/types/login' import type { IUserInfoVo } from '@/api/types/login'
import { useUserStore } from '@/store' import { useUserStore } from '@/store'
import { getTeaRoomDetail, createTeaRoomPackageOrder, getTeaRoomPackageDetail, calculateTeaRoomPrice } from '@/api/tea-room' import { getTeaRoomDetail, createTeaRoomPackageOrder, getTeaRoomPackageDetail, calculateTeaRoomPrice } from '@/api/tea-room'
@ -502,18 +502,30 @@
uni.$off('chooseCoupon'); uni.$off('chooseCoupon');
uni.$on('chooseCoupon', params => { uni.$on('chooseCoupon', params => {
console.log("🚀 ~ params:", params)
uni.$off('chooseCoupon') uni.$off('chooseCoupon')
if (type === CouponType.Discount) { if (params.coupon) {
selectedCoupon.value = {id: params.coupon.id, name: `${params.coupon.name}${params.coupon.coupon_price}` } if (type === CouponType.Discount) {
bill.value.coupon = params.coupon.coupon_price selectedCoupon.value = {id: params.coupon.id, name: `${params.coupon.name}${params.coupon.coupon_price}` }
selectCouponId.value = params.coupon.id // 这里的ID是在数据表自增的ID保存下来是为了回显列表的,没有其他作用 bill.value.coupon = params.coupon.coupon_price
selectCouponId.value = params.coupon.id // 这里的ID是在数据表自增的ID保存下来是为了回显列表的,没有其他作用
} else {
selectedGroupCoupon.value = {id: params.coupon.id, name: `团购券-${params.coupon?.title}` }
bill.value.groupCoupon = params.coupon.coupon_price
selectGroupCouponId.value = params.coupon.id // 这里的ID是在数据表自增的ID保存下来是为了回显列表的,没有其他作用
}
} else { } else {
console.log('gropu') // 清空选择
selectedGroupCoupon.value = {id: params.coupon.id, name: `团购券-${params.coupon?.title}` } if (type === CouponType.Discount) {
bill.value.groupCoupon = params.coupon.coupon_price selectedCoupon.value = {id: 0, name: '' }
selectGroupCouponId.value = params.coupon.id // 这里的ID是在数据表自增的ID保存下来是为了回显列表的,没有其他作用 bill.value.coupon = 0
selectCouponId.value = 0
} else {
selectedGroupCoupon.value = {id: 0, name: '' }
bill.value.groupCoupon = 0
selectGroupCouponId.value = 0
}
} }
Detail.handleCalculateTeaRoomPrice() Detail.handleCalculateTeaRoomPrice()
}) })
@ -533,7 +545,7 @@
toast.info('请选择预定时间') toast.info('请选择预定时间')
return return
} }
return false
isSubmitting.value = true isSubmitting.value = true
uni.showLoading({ uni.showLoading({
title: '提交中...' title: '提交中...'
@ -615,6 +627,13 @@
bill.value.groupCoupon = res.details.group_price // 团购优惠 bill.value.groupCoupon = res.details.group_price // 团购优惠
bill.value.total = res.details.order_amount // 订单金额 bill.value.total = res.details.order_amount // 订单金额
}, },
/**
* 预览图片
*/
handlePreviewImage: (e: {index: number, item: any}) => {
previewImage(swiperList.value[e.index], swiperList.value)
}
} }
</script> </script>

View File

@ -28,9 +28,9 @@
<wd-img width="64rpx" height="64rpx" :src="`${OSS}icon/icon_sc.png`"></wd-img> <wd-img width="64rpx" height="64rpx" :src="`${OSS}icon/icon_sc.png`"></wd-img>
</template> </template>
</view> --> </view> -->
<view @click="showServicePopup = true" class="flex items-center"> <!-- <view @click="showServicePopup = true" class="flex items-center">
<wd-img width="64rpx" height="64rpx" :src="`${OSS}icon/icon_kefu.png`"></wd-img> <wd-img width="64rpx" height="64rpx" :src="`${OSS}icon/icon_kefu.png`"></wd-img>
</view> </view> -->
</view> </view>
</template> </template>
</navbar> </navbar>
@ -39,7 +39,7 @@
<view class="mt-20rpx mx-30rpx swiper"> <view class="mt-20rpx mx-30rpx swiper">
<view> <view>
<wd-swiper value-key="image" height="320rpx" <wd-swiper value-key="image" height="320rpx"
:indicator="{ type: 'dots-bar' }" :list="swiperList" v-model:current="current" mode="aspectFit"> :indicator="{ type: 'dots-bar' }" :list="swiperList" v-model:current="current" mode="aspectFit" @click="Room.handlePreviewImage">
</wd-swiper> </wd-swiper>
</view> </view>
<view class="mt-38rpx flex justify-between"> <view class="mt-38rpx flex justify-between">
@ -122,7 +122,7 @@
<!-- 抖音兑换 --> <!-- 抖音兑换 -->
<view v-if="storeType == StoreType.Direct && tab === 2"> <view v-if="storeType == StoreType.Direct && tab === 2">
<dou-yin-excharge :store-id="teaRoomId" @success="Room.handleExchargeSuccess"/> <dou-yin-excharge :store-id="teaRoomId" @success=""/>
</view> </view>
</view> </view>
</view> </view>
@ -152,7 +152,7 @@
import type { ITeaRoomDetailResult } from '@/api/types/tea-room' import type { ITeaRoomDetailResult } from '@/api/types/tea-room'
import type {IUserInfoVo } from '@/api/types/login' import type {IUserInfoVo } from '@/api/types/login'
import { useUserStore } from '@/store' import { useUserStore } from '@/store'
import { router } from '@/utils/tools' import { router, previewImage } from '@/utils/tools'
import { StoreType } from '@/utils/tea' import { StoreType } from '@/utils/tea'
import DouYinExcharge from '@/bundle/components/DouYinExcharge.vue' import DouYinExcharge from '@/bundle/components/DouYinExcharge.vue'
@ -401,6 +401,13 @@
router.navigateBack().catch(err => { router.navigateBack().catch(err => {
router.switchTab('/pages/index/index') router.switchTab('/pages/index/index')
}) })
},
/**
* 预览图片
*/
handlePreviewImage: (e: {index: number, item: any}) => {
previewImage(swiperList.value[e.index], swiperList.value)
} }
} }
</script> </script>

View File

@ -99,7 +99,7 @@
<!-- 轮播图 --> <!-- 轮播图 -->
<view class="mx-30rpx"> <view class="mx-30rpx">
<wd-swiper value-key="image" height="400rpx" <wd-swiper value-key="image" height="400rpx"
:indicator="{ type: 'dots-bar' }" :list="info.image_arr" mode="aspectFit"></wd-swiper> :indicator="{ type: 'dots-bar' }" :list="info.image_arr" mode="aspectFit" @click="Detail.handlePreviewImage"></wd-swiper>
</view> </view>
<!-- 昵称显示 --> <!-- 昵称显示 -->
@ -362,7 +362,7 @@
import type { ITeaSpecialistRewardAmountsResult } from '@/api/types/tea' import type { ITeaSpecialistRewardAmountsResult } from '@/api/types/tea'
import { toast } from '@/utils/toast' import { toast } from '@/utils/toast'
import { TeaSpecialistLevelValue } from '@/utils/teaSpecialist' import { TeaSpecialistLevelValue } from '@/utils/teaSpecialist'
import { router } from '@/utils/tools' import { router, previewImage } from '@/utils/tools'
import { useUserStore } from '@/store' import { useUserStore } from '@/store'
import type {IUserInfoVo } from '@/api/types/login' import type {IUserInfoVo } from '@/api/types/login'
@ -565,6 +565,13 @@
router.navigateBack().catch(err => { router.navigateBack().catch(err => {
router.switchTab('/pages/index/index') router.switchTab('/pages/index/index')
}) })
},
/**
* 预览图片
*/
handlePreviewImage: (e: {index: number, item: any}) => {
previewImage(info.value.image_arr[e.index], info.value.image_arr)
} }
} }
</script> </script>

View File

@ -22,7 +22,7 @@
</template> </template>
</view> </view>
<view class="flex justify-between items-end"> <view class="flex justify-between items-end">
<view class="flex items-center"> <view class="flex items-center whitespace-nowrap">
<view class="flex items-center mr-14rpx"> <view class="flex items-center mr-14rpx">
<price-format color="#FF5951" :first-size="34" :second-size="26" :subscript-size="26" :price="item.price" weight="500"></price-format> <price-format color="#FF5951" :first-size="34" :second-size="26" :subscript-size="26" :price="item.price" weight="500"></price-format>
<view class="text-[#6A6363] text-22rpx leading-30rpx mt-8rpx">/小时</view> <view class="text-[#6A6363] text-22rpx leading-30rpx mt-8rpx">/小时</view>
@ -53,20 +53,17 @@
<view class="bg-[#818CA9] font-400 text-26rpx text-[#fff] h-40rpx wait2-clear-border">预定</view> <view class="bg-[#818CA9] font-400 text-26rpx text-[#fff] h-40rpx wait2-clear-border">预定</view>
</view> </view>
<!-- 预定状态-维护中 -->
<view class="w-108rpx h-52rpx leading-52rpx border-2rpx border-solid border-[#FF5951] rounded-8rpx text-[#FF5951] font-bold text-26rpx text-center" v-if="item.status === RoomStatus.MAINTENANCE">维护中</view> <view class="w-108rpx h-52rpx leading-52rpx border-2rpx border-solid border-[#FF5951] rounded-8rpx text-[#FF5951] font-bold text-26rpx text-center" v-if="item.status === RoomStatus.MAINTENANCE">维护中</view>
<!-- <view class="w-108rpx h-52rpx leading-52rpx border-2rpx border-solid border-[#F29747] rounded-8rpx text-[#F29747] font-bold text-26rpx text-center" <!-- 使用人数 -->
@click="RoomList.handleToPage(ReserveServiceCategory.ReserveRoom, item.store_id, item.id, item.price)"
v-if="item.status === RoomStatus.IN_USE">
使用中
</view> -->
<view class="font-400 text-22rpx text-[#6A6363] leading-32rpx w-200rpx text-right mt-8rpx" v-if="item.people_number">{{ item.people_number }}</view> <view class="font-400 text-22rpx text-[#6A6363] leading-32rpx w-200rpx text-right mt-8rpx" v-if="item.people_number">{{ item.people_number }}</view>
</view> </view>
</view> </view>
</view> </view>
<!-- 团购套餐 --> <!-- 团购套餐 -->
<view class="flex-1 ml-32rpx flex justify-between items-start h-220rpx relative" v-if="isGroupBuying"> <view class="flex-1 ml-32rpx flex justify-between items-start h-220rpx relative" v-if="isGroupBuying" @click="RoomList.handleToPage(ReserveServiceCategory.GroupBuying, item.store_id, item.id, item.price)">
<view> <view>
<view class="text-28rpx text-[#303133] leading-40rpx line-1 w-420rpx">{{ item.title }}</view> <view class="text-28rpx text-[#303133] leading-40rpx line-1 w-420rpx">{{ item.title }}</view>
<view class="mt-20rpx flex items-center h-32rpx"> <view class="mt-20rpx flex items-center h-32rpx">
@ -74,7 +71,7 @@
<wd-tag color="#40AE36" bg-color="#40AE36" plain custom-class="!rounded-4rpx">{{ item.hour }}小时</wd-tag> <wd-tag color="#40AE36" bg-color="#40AE36" plain custom-class="!rounded-4rpx">{{ item.hour }}小时</wd-tag>
</view> </view>
</view> </view>
<view v-if="item.introduce" class="text-[#999] text-22rpx leading-30rpx mt-12rpx w-300rpx line-2">{{ item.introduce }}</view> <view class="text-[#999] text-22rpx leading-30rpx mt-12rpx w-300rpx line-2 h-64rpx">适用包间{{ item.room_name }}</view>
<view class="flex mb-52rpx" :class="`${spec ? 'mt-10rpx' : 'mt-55rpx'}`"> <view class="flex mb-52rpx" :class="`${spec ? 'mt-10rpx' : 'mt-55rpx'}`">
<view class="mr-14rpx"> <view class="mr-14rpx">
<price-format color="#FF5951" :first-size="34" :second-size="26" <price-format color="#FF5951" :first-size="34" :second-size="26"
@ -87,11 +84,9 @@
</view> </view>
</view> </view>
<view class="absolute bottom-0 right-0"> <view class="absolute bottom-0 right-0">
<view class="text-[#6A6363] text-22rpx leading-30rpx">已售 {{ item.sold > 10 ? '10+' : item.sold }}</view> <view class="text-[#6A6363] text-22rpx leading-30rpx">已售 {{ item.sold + '+' }}</view>
<view <view class="w-104rpx h-52rpx mt-16rpx text-26rpx font-400 text-[#4C9F44] leading-52rpx text-center border-[2rpx] border-[#4C9F44] rounded-10rpx">
class="w-104rpx h-52rpx mt-16rpx text-26rpx font-400 text-[#4C9F44] leading-52rpx text-center border-[2rpx] border-[#4C9F44] rounded-10rpx" 抢购
@click="RoomList.handleToPage(ReserveServiceCategory.GroupBuying, item.store_id, item.id, item.price)">
抢购
</view> </view>
</view> </view>
</view> </view>

View File

@ -167,3 +167,12 @@ export function getCurrentDate() {
return `${year}-${month}-${day}`; return `${year}-${month}-${day}`;
} }
/**
* 预览图片
*/
export function previewImage(current: string, urls: string[]) {
uni.previewImage({
current,
urls
})
}