/** * 门店详情页面 */ import { View, Text, Image } from '@tarojs/components' import Taro, { useLoad } from '@tarojs/taro' import { useState, useEffect } from 'react' import { Swiper } from '@taroify/core' import { Arrow, HomeOutlined } from '@taroify/icons' import './index.scss' // 页面配置 - 隐藏导航栏 definePageConfig({ navigationStyle: 'custom', navigationBarTitleText: '' }) // 图片资源 import phoneIcon from '../images/phone.png' import locationIcon from '../images/locationicon.png' import shareIcon from '../images/share.png' import payVipBg from '../images/payVip.png' import billiardTabBg from '../images/billiardtab.png' import paiTabBg from '../images/paitab.png' import storeBoxBg from '../images/storeBox.png' import { getBigImage } from '@/utils/imageHelper' // 台球桌状态类型 type TableStatus = 'available' | 'using' | 'waiting' | 'reserved' // 台球桌数据接口 interface BilliardTable { id: string name: string status: TableStatus waitTime?: string buttons: Array<{ type: 'start' | 'reserve' text: string }> } // 台球桌分类数据 interface BilliardCategory { name: string vipPrice: string originalPrice: string tables: BilliardTable[] } // 棋牌桌数据接口 interface ChessTable { id: string name: string status: TableStatus statusText?: string buttonText?: string waitTime?: string } // 存杆柜数据接口 interface StorageCabinet { id: string status: 'available' | 'rented' price: string } const StoreDetail = () => { const [activeTab, setActiveTab] = useState(0) // 0: 中式台球, 1: 棋牌, 2: 存杆柜 const [statusBarHeight, setStatusBarHeight] = useState(20) // 状态栏高度 const [navBarHeight, setNavBarHeight] = useState(44) // 导航栏内容高度 // 获取系统信息设置导航栏高度 useEffect(() => { const systemInfo = Taro.getSystemInfoSync() setStatusBarHeight(systemInfo.statusBarHeight || 20) // 微信小程序胶囊按钮信息 if (process.env.TARO_ENV === 'weapp') { const menuButtonInfo = Taro.getMenuButtonBoundingClientRect() const navHeight = (menuButtonInfo.top - (systemInfo.statusBarHeight || 0)) * 2 + menuButtonInfo.height setNavBarHeight(navHeight) } }, []) // 返回上一页 const handleBack = () => { const pages = Taro.getCurrentPages() if (pages.length > 1) { Taro.navigateBack() } else { Taro.switchTab({ url: '/pages/index/index' }) } } // 返回首页 const handleGoHome = () => { Taro.switchTab({ url: '/pages/index/index' }) } // 门店信息 const storeInfo = { name: '北京黑八大师联盟球厅店', address: '北京市XXX区XXX街道XXX路XXXXXX大厦101', distance: '10.05km', billiardPrice: '¥10.00起', chessPrice: '¥20.00起' } // Tab 数据 const tabs = [ { name: '中式台球', idleCount: 5 }, { name: '棋牌', idleCount: 1 }, { name: '存杆柜', idleCount: 0 } ] // 台球桌分类数据 const [billiardCategories] = useState([ { name: '独牙&来力.山岩', vipPrice: '¥8.00/小时', originalPrice: '¥10.00/小时', tables: [ { id: '1', name: '独牙01', status: 'available', buttons: [{ type: 'start', text: '立即开台' }] }, { id: '2', name: '独牙02', status: 'waiting', waitTime: '00 时 15 分', buttons: [] }, { id: '3', name: '来力黑金刚03', status: 'available', buttons: [{ type: 'start', text: '立即开台' }] }, { id: '4', name: '来力黑金刚04', status: 'using', buttons: [] } ] }, { name: '乔氏赛台', vipPrice: '¥16.00/小时', originalPrice: '¥20.00/小时', tables: [ { id: '5', name: '乔氏01', status: 'available', buttons: [{ type: 'start', text: '立即开台' }] }, { id: '6', name: '乔氏02', status: 'available', buttons: [{ type: 'reserve', text: '预定' }, { type: 'start', text: '立即开台' }] }, { id: '7', name: '乔氏03', status: 'available', buttons: [{ type: 'start', text: '立即开台' }] } ] } ]) // 棋牌数据 const [chessTables] = useState([ { id: '1', name: 'Q01号', status: 'available', buttonText: '立即开台' }, { id: '2', name: 'Q02号', status: 'using', statusText: '预计 16:00 结束' }, { id: '3', name: 'Q03号', status: 'waiting', statusText: '预计等待:', waitTime: '00 时 15 分' }, { id: '4', name: 'Q04号', status: 'reserved', buttonText: '预约开台' } ]) // 棋牌价格信息 const chessInfo = { timeRange: '00:00-24:00', price: '¥60.00/小时' } // 存杆柜数据 const [storageCabinet] = useState({ id: '1', status: 'available', price: '1元/天' }) useLoad(() => { console.log('门店详情页面加载') }) // 拨打电话 const handlePhoneCall = () => { Taro.makePhoneCall({ phoneNumber: '100-666-XXXX', }).catch((err) => { console.error('拨打电话失败:', err) }) } // 分享 const handleShare = () => { Taro.showToast({ title: '分享功能开发中', icon: 'none' }) } // 开通VIP const handleOpenVip = () => { Taro.navigateTo({ url: '/pagesUser/vipBenefits/index' }) } // Tab 点击,滚动到对应位置 const handleTabClick = (index: number) => { setActiveTab(index) // 获取对应区域的 ID const sectionIds = ['billiard-section', 'chess-section', 'storage-section'] const query = Taro.createSelectorQuery() query.select(`#${sectionIds[index]}`).boundingClientRect() query.select('#scroll-content').scrollOffset() query.exec((res) => { if (res[0] && res[1]) { const targetTop = res[0].top + res[1].scrollTop - 150 // 减去 tab 高度 Taro.pageScrollTo({ scrollTop: targetTop, duration: 300 }) } }) } // 进入预定页面 const handleReserve = (tableId: string) => { Taro.navigateTo({ url: '/pageStore/reservation/index?tableId=' + tableId }) } // 进入开台页面 const handleStartTable = (tableId: string) => { Taro.navigateTo({ url: '/pageScan/startTable/index?tableId=' + tableId }) } // 进入预约开台页面 const handleAppointmentStart = (tableId: string) => { Taro.navigateTo({ url: '/pageStore/appointmentStart/index?tableId=' + tableId }) } // 进入存杆柜租赁页面 const handleCabinetRental = () => { Taro.navigateTo({ url: '/pagesOrder/cabinetRental/index' }) } // 获取台球桌状态文本 const getBilliardStatusText = (table: BilliardTable) => { if (table.status === 'using') return '使用中' if (table.status === 'waiting') return `预计等待:\n${table.waitTime}` return '' } // 获取棋牌状态标签 const getChessStatusTag = (status: TableStatus) => { if (status === 'available') return { text: '空闲中', class: 'available' } if (status === 'using') return { text: '使用中', class: 'using' } if (status === 'waiting') return { text: '使用中', class: 'using' } if (status === 'reserved') return { text: '空闲中', class: 'available' } return { text: '', class: '' } } return ( {/* 自定义透明导航栏 */} {/* */} {/* 轮播图区域 */} {/* 内容区域 */} {/* 门店信息 */} {storeInfo.name} {storeInfo.address} 距离{storeInfo.distance} 台球 {storeInfo.billiardPrice} 棋牌 {storeInfo.chessPrice} {/* VIP 开通横幅 */} 立即开通 {/* Tab 导航 */} {tabs.map((tab, index) => ( handleTabClick(index)} > 空闲 {tab.idleCount} {tab.name} {activeTab === index && } ))} {/* 台球和棋牌区域 */} {/* 台球区域 */} {billiardCategories.map((category, catIndex) => ( {category.name} VIP: {category.vipPrice} 原价: {category.originalPrice} {category.tables.map((table) => ( {table.status !== 'available' && } {table.name} {table.status === 'available' && table.buttons.length > 0 ? ( table.buttons.length === 1 ? ( // 单个按钮 table.buttons[0].type === 'reserve' ? handleReserve(table.id) : handleStartTable(table.id)} > {table.buttons[0].text} ) : ( // 按钮组 {table.buttons.map((btn, btnIndex) => ( btn.type === 'reserve' ? handleReserve(table.id) : handleStartTable(table.id)} > {btn.text} ))} ) ) : ( {getBilliardStatusText(table)} )} ))} ))} {/* 棋牌区域 */} 棋牌 {chessInfo.timeRange} 价格: {chessInfo.price} {chessTables.map((table) => ( {(table.status === 'using' || table.status === 'waiting') && } {/* 状态标签 */} {getChessStatusTag(table.status).text} {table.name} {table.status === 'available' ? ( handleStartTable(table.id)}>{table.buttonText} ) : table.status === 'reserved' ? ( handleAppointmentStart(table.id)}>{table.buttonText} ) : ( {table.statusText} {table.status === 'waiting' && `\n${table.waitTime}`} )} ))} {/* 存杆柜区域 */} 存杆柜 暂未租赁/租赁中 {storageCabinet.price} 租赁 {/* 底部提示 */} 到底了~ ) } export default StoreDetail