完善功能

This commit is contained in:
wangxiaowei
2026-05-20 14:05:47 +08:00
parent 99263e7bb6
commit ef85346d0e
9 changed files with 412 additions and 56 deletions

View File

@ -71,7 +71,6 @@
const goods = ref<Array<any>[]>([])
const showAction = ref<boolean>(false)
const sheetMenu = ref([])
const showServicePopup = ref<boolean>(false)
const storeType = ref<number>(1) // 1直营 2加盟
@ -130,7 +129,7 @@
const couponRoomId = ref<number>(0)
const couponRoomPrice = ref<number>(0)
onLoad((args) => {
onLoad((args: any) => {
groupCouponId.value = args.groupCouponId
groupCouponOrderId.value = args.groupCouponOrderId
teaRoomId.value = Number(args.teaRoomId)
@ -217,22 +216,6 @@
})
},
// 处理拨打电话逻辑
handleCallPhone: () => {
ChooseRoom.sheetMenuType = 'call'
showAction.value = true
sheetMenu.value = [
{
name: 15005837859,
value: ''
},
{
name: '呼叫',
value: 15005837859
}
]
},
// tab切换获取index
handleChangeTab: (item: { index: number }) => {
// tabIndexs.value = item.index

View File

@ -8,6 +8,55 @@
}</route>
<template>
<view>
<!-- 领取优惠券 -->
<wd-overlay :show="showCoupon" @click="Room.handleCloseCoupon('coupon1')">
<view class="flex flex-col justify-center items-center h-100%">
<view class="w-652rpx h-590rpx relative" >
<wd-img :src="`${OSS}images/home/home_image10.png`" width="100%" height="100%"></wd-img>
<view class="absolute top-200rpx left-1/2 transform -translate-x-1/2 flex flex-col items-center">
<view class="mt-220rpx" @click.stop="Room.handleCloseCoupon('coupon1')">
<view class="h-90rpx relative">
<wd-img :src="`${OSS}images/home/home_image9.png`" width="342rpx" height="90rpx"></wd-img>
<view class="absolute top-20rpx left-1/2 transform -translate-x-1/2 flex flex-col items-center" @click.stop="Room.handleToGetCoupon('coupon1')">立即领取</view>
</view>
</view>
</view>
</view>
<view class="mt-80rpx" @click.stop="Room.handleCloseCoupon('coupon1')">
<wd-img :src="`${OSS}icon/icon_close2.png`" width="72rpx" height="72rpx"></wd-img>
</view>
</view>
</wd-overlay>
<!-- 领取20张20元优惠券 -->
<wd-overlay :show="showCoupon2" @click="Room.handleCloseCoupon('coupon2')">
<view class="flex flex-col justify-center items-center h-100%">
<view class="w-572rpx h-518rpx relative" >
<wd-img :src="`${OSS}images/home/home_image_20.png`" width="100%" height="100%"></wd-img>
<view class="absolute top-50rpx left-1/2 transform -translate-x-1/2">
<view class="text-[#FF5643] font-bold text-32rpx leading-42rpx text-center">通用优惠券</view>
<view class="text-[#E64545] font-bold flex items-end mt-20rpx">
<view class="text-52rpx mb-20rpx"></view>
<view class="text-102rpx">400</view>
</view>
</view>
<view class="absolute top-200rpx left-1/2 transform -translate-x-1/2 flex flex-col items-center">
<view class="mt-160rpx" @click.stop="Room.handleCloseCoupon('coupon2')">
<view class="h-90rpx relative" @click.stop="Room.handleToGetCoupon('coupon2')">
<wd-img :src="`${OSS}images/home/home_image9.png`" width="342rpx" height="90rpx"></wd-img>
<view class="absolute top-20rpx left-1/2 transform -translate-x-1/2 flex flex-col items-center">立即领取</view>
</view>
</view>
</view>
</view>
<view class="mt-80rpx" @click.stop="Room.handleCloseCoupon('coupon2')">
<wd-img :src="`${OSS}icon/icon_close2.png`" width="72rpx" height="72rpx"></wd-img>
</view>
</view>
</wd-overlay>
<view>
<navbar fixed layoutLeft hideLeftIcon>
<template #left>
@ -158,12 +207,12 @@
import RoomList from '@/components/reserve/RoomList.vue'
import {toast} from '@/utils/toast'
import { getTeaRoomDetail, collectTeaRoom, getStoreTeaRoomList, getTeaRoomPackage } from '@/api/tea-room'
import type { ITeaRoomDetailResult } from '@/api/types/tea-room'
import type {IUserInfoVo } from '@/api/types/login'
import { useUserStore } from '@/store'
import { router, previewImage, strToParams } from '@/utils/tools'
import { StoreType } from '@/utils/tea'
import DouYinExcharge from '@/bundle/components/DouYinExcharge.vue'
import { getHomeCouponPopup, claimIndexCoupon } from '@/api/home'
const rightPadding = inject('capsuleOffset')
const OSS = inject('OSS')
@ -176,7 +225,7 @@
const teaRoom = ref<any>({})
// 用户信息
const userInfo = ref<IUserInfoVo>(null)
const userInfo = ref<IUserInfoVo>({})
// tab
const tab = ref<number>(0)
@ -184,7 +233,7 @@
// 弹窗
const showAction = ref<boolean>(false)
const sheetMenu = ref([])
const sheetMenu = ref<any>([])
const showServicePopup = ref<boolean>(false)
const storeType = ref<number>(StoreType.Direct)
@ -207,6 +256,14 @@
// 是否是扫码进入
const isScan = ref<boolean>(false)
// 优惠券状态
const couponStatus = ref<any>({})
// 显示优惠券弹窗
const showCoupon = ref<boolean>(false)
// 显示第2种优惠券弹窗
const showCoupon2 = ref<boolean>(false)
onLoad((args: any) => {
console.log("🚀 ~ args:", args)
// 处理小程序码扫码进入时的 scene 参数
@ -256,6 +313,10 @@
}
})
onShow(() => {
Room.handleIsGetCoupon()
})
const Room = {
sheetMenuType: '', // 记录菜单类型
@ -263,7 +324,7 @@
* 获取茶室预定和团购套餐列表
* @param mescroll
*/
upCallback: (mescroll) => {
upCallback: (mescroll: any) => {
const filter = {
page: mescroll.num,
size: mescroll.size,
@ -300,8 +361,6 @@
handleInit: async () => {
const userStore = useUserStore()
userInfo.value = userStore.userInfo
console.log("🚀 ~ uni.getStorageSync('latitude'):", uni.getStorageSync('latitude'))
console.log("🚀 ~ uni.getStorageSync('longitude'):", uni.getStorageSync('longitude'))
const res = await getTeaRoomDetail({
id: teaRoomId.value,
@ -435,7 +494,68 @@
*/
handlePreviewImage: (e: {index: number, item: any}) => {
previewImage(swiperList.value[e.index], swiperList.value)
}
},
/**
* 是否领取过优惠券
*/
handleIsGetCoupon: async () => {
// 如果是扫码进入,需要弹出优惠券
if (isScan.value) {
const userStore = useUserStore()
userInfo.value = userStore.userInfo
const userId = userStore.userInfo?.id
if (userId) {
// 获取首页优惠券弹窗
const res = await getHomeCouponPopup()
couponStatus.value = res
if (Number(res.status) === 0) {
showCoupon.value = true
} else {
showCoupon.value = false
}
// 如果第一张优惠券的弹窗没有被触发(可能是因为用户关闭了第一个优惠券的弹窗),但是接口返回还可以领第二张优惠券,就继续显示第二个优惠券的弹窗(如果一下子都弹出来,用户可能会觉得烦,所以分开两个弹窗)
if (Number(res.status) !== 0 && Number(res.general_status) === 0 ) {
showCoupon2.value = true
} else {
showCoupon2.value = false
}
}
}
},
/**
* 跳转领取优惠券页面
*/
handleToGetCoupon: async (type: string) => {
// 1是茶艺师优惠券2是茶馆优惠券
if (type === 'coupon1') {
await claimIndexCoupon(1)
showCoupon.value = false
// router.navigateTo('/bundle_b/pages/tea-specialist/list')
Room.handleIsGetCoupon()
} else if (type === 'coupon2') {
await claimIndexCoupon(6)
showCoupon2.value = false
}
},
/**
* 关闭优惠券
*/
handleCloseCoupon: (type: string) => {
if (type === 'coupon1') {
showCoupon.value = false
// 验证下,如果用户关闭了第一个优惠券的弹窗,如果还可以领第二个优惠券,就继续显示第二个优惠券的弹窗(如果一下子都弹出来,用户可能会觉得烦,所以分开两个弹窗)
if (Number(couponStatus.value.general_status) === 0 ) {
showCoupon2.value = true
}
} else if (type === 'coupon2') {
showCoupon2.value = false
}
}
}
</script>

View File

@ -70,7 +70,7 @@
<wd-navbar safeAreaInsetTop :bordered="false" custom-style="background-color: #fff !important;">
<template #left>
<view class="flex items-center" @click="List.handleBack">
<view class="mt-4rpx">
<view class="mt-4rpx pr-10rpx">
<wd-icon name="thin-arrow-left" size="30rpx" color="#121212"></wd-icon>
</view>
<view class="text-[#303133] text-36rpx ml-24rpx leading-48rpx">预约茶艺师</view>
@ -78,8 +78,12 @@
</template>
</wd-navbar>
<view class="search-box px-30rpx pb-10rpx pt-20rpx bg-[#fff]">
<view class="w-full h-72rpx bg-[#F6F7F8] rounded-36rpx flex items-center pl-30rpx pr-6rpx">
<view class="search-box pl-30rpx pb-10rpx pt-10rpx bg-[#fff] flex items-center header-search-box">
<view class="flex items-center line-1 max-w-150rpx mr-20rpx" @click="List.handleToCity">
<view class="mr-10rpx font-400 leading-44rpx text-32rpx line-1">{{ city || LOCATION_DEFAULT_CITY }}</view>
<wd-icon name="arrow-down" size="24rpx" color="#333" custom-class="mt-4rpx"></wd-icon>
</view>
<view class="flex-1 h-72rpx bg-[#F6F7F8] rounded-36rpx flex items-center pl-30rpx pr-6rpx">
<wd-icon name="search" size="32rpx" color="#C0C4CC"></wd-icon>
<input type="text" class="flex-1 ml-16rpx text-28rpx h-full bg-transparent" placeholder="茶艺师名称"
placeholder-style="color: #C0C4CC" v-model="keywords" @confirm="List.handleSearch"
@ -249,6 +253,8 @@ import { getTeaSpecialist } from '@/api/tea-specialist'
import TeaSpecialistLevel from '@/components/TeaSpecialistLevel.vue'
import type { ITeaSpecialistResult } from '@/api/types/tea-specialist'
import { TeaSpecialistLevelValue, TeaSpecialistLevels, GetTeaSpecialistLevelLabel } from '@/utils/teaSpecialist'
import { LOCATION_CITY_KEY, LOCATION_DEFAULT_CITY } from '@/hooks/useLocation'
import { getOpenCityList } from '@/api/tea-room'
const OSS = inject('OSS')
const navbarHeight = inject('navbarHeight')
@ -260,26 +266,57 @@ const selectedLevel = ref<Array<any>>([]) // 当前选中的茶艺师等级
// mescroll
const { mescrollInit, downCallback, getMescroll } = useMescroll(onPageScroll, onReachBottom) // 调用mescroll的hook
const downOption = {
auto: true
auto: false // 关闭自动请求,等城市加载完再请求
}
const upOption = {
empty: {
icon: OSS + 'icon/icon_reserver_empty.png',
tip: '暂无预约信息',
},
auto: true,
auto: false, // 关闭自动请求,等城市加载完再请求
textNoMore: '~ 已经到底啦 ~', //无更多数据的提示
}
const orderStatus = ref<string>('')
const list = ref<Array<any>>([]) // 茶室列表
const keywords = ref<string>('') // 搜索关键词
const city = ref<string>('') // 当前城市名称
const cityId = ref<number>(0)
onLoad(async () => {
console.log("🚀 ~ 213:", 213)
// 首页进来的cityId
const indexCity = ref<number>(0)
// 已开通的城市列表
const openCityList = ref<Array<any>>([])
onLoad(async (args: any) => {
indexCity.value = Number(args.cityId) || 0
console.log("🚀 ~ indexCity.value:", indexCity.value)
// 优先读取独立缓存,如果没有则读取系统默认定位
const listSavedCity = uni.getStorageSync('listCityName')
const listSavedCityId = uni.getStorageSync('listCityId')
if (listSavedCity && listSavedCityId !== '') {
city.value = listSavedCity
cityId.value = listSavedCityId
} else {
city.value = uni.getStorageSync(LOCATION_CITY_KEY) || LOCATION_DEFAULT_CITY
cityId.value = 0
}
uni.$on('refreshTeaSpecialist', () => {
list.value = []
getMescroll().resetUpScroll()
})
// 获取已开通城市列表
getOpenCityList().then(res => {
openCityList.value = res.list
// 获取完毕后再触发列表请求
setTimeout(() => {
getMescroll().resetUpScroll()
}, 100)
})
})
onUnload(() => {
@ -314,10 +351,39 @@ const List = {
return firstThreeStyles[index] || { backgroundColor: '#F3F3F3', color: '#818CA9' }
},
/**
* 跳转城市选择
*/
handleToCity: () => {
uni.$on('locationUpdate', params => {
console.log("🚀 ~ list -> params:", params)
uni.$off('locationUpdate')
city.value = params.city
cityId.value = params.id
uni.setStorageSync('listCityId', params.id)
uni.setStorageSync('listCityName', params.city)
List.handleSearch()
})
const storeLat = uni.getStorageSync('latitude') || import.meta.env.VITE_DEFAULT_LATITUDE
const storeLng = uni.getStorageSync('longitude') || import.meta.env.VITE_DEFAULT_LONGITUDE
router.navigateTo(`/pages/city/city?lat=${storeLat}&lng=${storeLng}`)
},
/**
* 筛选表
*/
upCallback: (mescroll) => {
upCallback: (mescroll: any) => {
// 如果没有城市id就是初始化进入了系统这个时候需要获取到对应的城市id
if (cityId.value == 0) {
openCityList.value.forEach((item: any) => {
if (item.name === city.value) {
cityId.value = item.id
return
}
})
}
console.log("🚀 ~ cityId.value2:", cityId.value)
const filter = {
level: selectedLevel.value.join(',') || '',
page: mescroll.num,
@ -328,7 +394,7 @@ const List = {
server_type: serverType.value || '',
state: condition.value || 0,
gender: gender.value || '',
city_id: uni.getStorageSync('cityId') || 0,
city_id: cityId.value || 0,
}
getTeaSpecialist(filter).then((res: ITeaSpecialistResult) => {

View File

@ -467,9 +467,9 @@
const endTimeValue = ref<string>('') // 结束时间
const now = new Date()
const minTimestamp = Date.now() + 0.5 * 60 * 60 * 1000
// 允许选择今天及未来天的日期
// 允许选择今天及未来三十天的日期
const futureTimestamp = minTimestamp + 2 * 60 * 60 * 1000
const maxTimestamp = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 6, 23, 59, 59, 999).getTime()
const maxTimestamp = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 30, 23, 59, 59, 999).getTime()
const startTimeLayout = ref<string>('')
const endTimeLayout = ref<string>('')
const totalHour = ref<number>(0)
@ -585,7 +585,7 @@
team_user_id: 0, // 茶艺师id
})
onLoad(async (args) => {
onLoad(async (args: any) => {
if (args.id) {
id.value = Number(args.id)
costParams.value.team_user_id = Number(args.id)

View File

@ -14,8 +14,6 @@ export const LOCATION_DEFAULT_CITY = '上海市' // 默认城市
export const LOCATION_DEFAULT_LNG = 121.473629 // 上海经度
export const LOCATION_DEFAULT_LAT = 31.230393 // 上海纬度
// 检查过期时间
export function handleCheckLocationCacheHooks() {
const expire = uni.getStorageSync(LOCATION_EXPIRE_KEY)

View File

@ -132,7 +132,7 @@ const teaPackageTitle = ref<string>('')
// 防止重复提交
const isSubmitting = ref(false)
onLoad(async (args) => {
onLoad(async (args: any) => {
// 订单
orderId.value = Number(args.orderId)
comboId.value = Number(args.cmoboId) || 0

View File

@ -57,7 +57,7 @@
// 已开通城市列表
const openCityList = ref<Array<any>>([])
onLoad((args) => {
onLoad((args: any) => {
if (args.lat && args.lng) {
latitude.value = Number(args.lat)
longitude.value = Number(args.lng)
@ -95,9 +95,10 @@
}
uni.$emit('locationUpdate', params)
// 取消全局城市缓存修改以实现功能页面之间的城市隔离
// uni.setStorageSync(LOCATION_LAT_KEY, item.latitude)
// uni.setStorageSync(LOCATION_LNG_KEY, item.longitude)
uni.setStorageSync(LOCATION_CITY_KEY, item.name)
// uni.setStorageSync(LOCATION_CITY_KEY, item.name)
router.navigateBack()
},

View File

@ -202,10 +202,10 @@
import { router, previewImage } from '@/utils/tools'
import { onPageScroll, onReachBottom } from '@dcloudio/uni-app'
import useMescroll from "@/uni_modules/mescroll-uni/hooks/useMescroll.js"
import { LOCATION_DENY_TIME_KEY, handleEnsureLocationAuthHooks, LOCATION_DEFAULT_CITY, handleGetLocationCity, LOCATION_CITY_KEY, handleForceGetLocation } from '@/hooks/useLocation'
import { LOCATION_DENY_TIME_KEY, handleEnsureLocationAuthHooks, LOCATION_DEFAULT_CITY, handleGetLocationCity } from '@/hooks/useLocation'
import { getHomeBannerList, getHomeCouponPopup, claimIndexCoupon, getTeaArtistEntrance } from '@/api/home'
import { getTeaPackageList } from '@/api/tea-package'
import { getHomeTeaStoreList } from '@/api/tea-room'
import { getHomeTeaStoreList, getOpenCityList } from '@/api/tea-room'
import { useUserStore } from '@/store'
import { useToast } from 'wot-design-uni'
import { getSetting } from '@/api/tea-specialist'
@ -260,6 +260,9 @@
// 茶艺师入口图
const teaArtistEntrance = ref<string>('')
// 已开通的城市列表
const openCityList = ref<Array<any>>([])
onShow(async () => {
// if (canLocation) {
// const location = await handleGetLocationCity(latitude.value, longitude.value)
@ -273,7 +276,9 @@
// 只有经纬度变化时才刷新
if (location.lat !== lastLocation.lat || location.lng !== lastLocation.lng) {
const loc = await handleGetLocationCity(location.lat, location.lng)
city.value = loc.city
if (!uni.getStorageSync('indexCityName')) {
city.value = loc.city
}
latitude.value = location.lat
longitude.value = location.lng
@ -306,7 +311,7 @@
}
})
onLoad(async(args) => {
onLoad(async() => {
// 获取小程序码注册来源
// getWxacode().then( res => {})
@ -318,14 +323,20 @@
latitude.value = lat
longitude.value = lng
// 根据经纬度获取城市信息再重新赋值经纬度和城市
const location = await handleGetLocationCity(lat, lng)
city.value = location.city
latitude.value = location.latitude
longitude.value = location.longitude
// 删除city_id的缓存
uni.removeStorageSync('cityId')
// 如果有首页独立的城市缓存,优先使用;否则使用定位城市
const indexSavedCity = uni.getStorageSync('indexCityName')
const indexSavedCityId = uni.getStorageSync('indexCityId')
if (indexSavedCity && indexSavedCityId !== '') {
city.value = indexSavedCity
city_id.value = indexSavedCityId
} else {
// 根据经纬度获取城市信息再重新赋值经纬度和城市
const location = await handleGetLocationCity(lat, lng)
city.value = location.city
latitude.value = location.latitude
longitude.value = location.longitude
}
Index.handleResetSearch()
})
@ -355,6 +366,16 @@
}
canLocation.value = true
// 如果没有城市id就是初始化进入了系统这个时候需要获取到对应的城市id
if (city_id.value == 0) {
openCityList.value.forEach((item: any) => {
if (item.name === city.value) {
city_id.value = item.id
return
}
})
}
const filter = {
page: mescroll.num,
size: mescroll.size,
@ -411,6 +432,10 @@
teaPackageList.value = res
})
// 获取已开通城市列表
getOpenCityList().then(res => {
openCityList.value = res.list
})
},
/**
@ -424,7 +449,8 @@
city_id.value = params.id
// latitude.value = params.latitude
// longitude.value = params.longitude
uni.setStorageSync('cityId', params.id)
uni.setStorageSync('indexCityId', params.id)
uni.setStorageSync('indexCityName', params.city)
Index.handleResetSearch()
})
router.navigateTo(`/pages/city/city?lat=${latitude.value}&lng=${longitude.value}`)
@ -447,7 +473,7 @@
* 跳转到预约茶室页面
*/
handleToReserveRoom: (id: number = 0, type: number = 1) => {
router.navigateTo( `/bundle/tea-room/room?id=${id}&type=${type}`)
router.navigateTo( `/bundle/tea-room/room?id=${id}&type=${type}` )
},
/**

File diff suppressed because one or more lines are too long