/** * 关台页面 */ import { View, Text, Image } from '@tarojs/components' import Taro, { useLoad, useRouter } from '@tarojs/taro' import { useState } from 'react' import { observer } from 'mobx-react' import { ArrowDown } from '@taroify/icons' import FooterButtons from './components/FooterButtons' import { tableStore } from '../../store' import './index.scss' // 使用本地图片资源 const phoneIcon = require('../startTable/images/phone.png') const locationIcon = require('../../assets/icon/locationIcon.png') const CloseTable = observer(() => { const router = useRouter() const { type = 'owner' } = router.params as { type?: 'owner' | 'guest' } // owner: 开台人员, guest: 非开台人 const [expanded, setExpanded] = useState(false) // 订单详情是否展开 const [couponExpanded, setCouponExpanded] = useState(false) // 优惠券详情是否展开 const [priceExpanded, setPriceExpanded] = useState(false) // 收费标准详情是否展开 // 从路由参数获取设备信息和操作记录ID,如果没有则从 store 获取 const grpSn = tableStore.getGrpSn(router.params.grpSn) const operationId = tableStore.getOperationId(Number(router.params.operationId)) const scanInfo = tableStore.scanInfo const opInfo = scanInfo?.opInfo const priceInfo = scanInfo?.price useLoad(() => { console.log('关台页面加载,类型:', type, '设备编码:', grpSn, '操作记录ID:', operationId) if (grpSn) tableStore.setCurrentGrpSn(grpSn) if (operationId) tableStore.setCurrentOperationId(operationId) }) // 拨打电话 const handlePhoneCall = () => { Taro.makePhoneCall({ phoneNumber: '100-666-XXXX', }).catch((err) => { console.error('拨打电话失败:', err) }) } // 切换展开/收起 const handleToggleExpand = () => { setExpanded(!expanded) } return ( {/* 内容区域 */} {/* 台球桌信息卡片 */} {/* 顶部:类型和店名 */} 中式台球 联系店长 {/* 台球桌标题和使用状态 */} {scanInfo?.tableInfo?.name || '--'} {scanInfo?.tableInfo?.statusDescription || '使用中...'} {/* 位置信息 */} {scanInfo?.shopName || '--'} {/* 开台订单信息卡片 */} {/* 顶部:开台方式和详情按钮 */} {opInfo?.ctrlTypeDescription || '开台方式'} 详情 {/* 订单统计 */} {opInfo?.usedTime || '--'} 已消费时长 {opInfo ? `${opInfo.currentAmount.toFixed(2)}元` : '--'} 已消费金额 {/* 收费规则 */} 收费规则 价格: {priceInfo ? `${priceInfo.standard.toFixed(2)}元/小时` : '--'} {priceInfo && priceInfo.memberPrice > 0 && ( 折扣价: {priceInfo.memberPrice.toFixed(2)}元/小时 )} {/* 展开的详细信息 */} {expanded && ( <> {/* 支付信息卡片 */} 支付信息 在线总支付: {opInfo ? `${opInfo.deposit.toFixed(2)}元` : '0元'} 押金 {opInfo ? `${opInfo.deposit.toFixed(2)}元${opInfo.depositStatus ? `(${opInfo.depositStatus})` : ''}` : '--'} 订单原价 {opInfo ? `${opInfo.currentAmount.toFixed(2)}元` : '--'} {/* 优惠券抵扣 - 可展开 */} setCouponExpanded(!couponExpanded)}> 优惠券抵扣 {opInfo && opInfo.discountAmount > 0 ? '已使用' : '不可用'} {opInfo && opInfo.discountAmount > 0 ? `-${opInfo.discountAmount.toFixed(2)}元` : '-0.00元'} {/* 优惠券展开内容 */} {couponExpanded && ( {opInfo && opInfo.discountAmount > 0 ? 优惠金额:{opInfo.discountAmount.toFixed(2)}元 : 暂无优惠券 } )} 待结算: {opInfo ? `${opInfo.payableAmount.toFixed(2)}元` : '--'} {/* 开台信息卡片 */} 开台信息 门店信息 {scanInfo?.shopName || '--'} 桌台信息 {scanInfo?.tableInfo?.name || '--'} 开始时间 {opInfo?.startTime || '--'} 使用时长 {opInfo?.usedTime || '--'} 订单编号 {opInfo?.orderNo || '--'} {/* 收费标准 - 可展开 */} setPriceExpanded(!priceExpanded)}> 收费标准 {priceInfo ? `${priceInfo.currentPrice.toFixed(2)}元/小时` : '--'} {/* 收费标准展开内容 */} {priceExpanded && ( {priceInfo?.descript && {priceInfo.descript}} {priceInfo?.timePrices?.map((tp, i) => ( • {tp.startTime}-{tp.endTime} {tp.description || `${tp.price}元/小时`} ))} )} 支付方式 {opInfo?.payTypeDescription || '--'} )} {/* 底部按钮区域 */} ) }) export default CloseTable