From 4fe1f507139419f5ab67bcc13ac2f7aba93c1290 Mon Sep 17 00:00:00 2001 From: DU Date: Tue, 12 May 2026 09:10:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=89=AB=E7=A0=81=E8=B0=83?= =?UTF-8?q?=E8=AF=95=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/index.ts | 6 ++-- src/pageScan/startTable/index.tsx | 26 ++++++++------ src/pages/scan/index.scss | 47 ++++++++++++++++++++++++- src/pages/scan/index.tsx | 58 ++++++++++++++++++++++++++++++- src/services/request.ts | 2 +- 5 files changed, 124 insertions(+), 15 deletions(-) diff --git a/src/config/index.ts b/src/config/index.ts index 7845854..571e22e 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -5,10 +5,12 @@ // API 基础地址配置 // 直接配置,如需修改请更改此处 -const API_BASE_URL = 'http://39.101.75.71:8888' +// const API_BASE_URL = 'http://39.101.75.71:8888' +const API_BASE_URL = 'https://www.tlbar.com' // 大图服务器地址 http://39.101.75.71:8888/img/MiniBgImage/swBG.png -const BIG_IMAGE_URL = 'http://39.101.75.71:8888/img/MiniBgImage' +// const BIG_IMAGE_URL = 'http://39.101.75.71:8888/img/MiniBgImage' +const BIG_IMAGE_URL = 'https://www.tlbar.com/img/MiniBgImage' // API 版本 const API_VERSION = 'v2' diff --git a/src/pageScan/startTable/index.tsx b/src/pageScan/startTable/index.tsx index 6b7dd42..9049276 100644 --- a/src/pageScan/startTable/index.tsx +++ b/src/pageScan/startTable/index.tsx @@ -10,11 +10,12 @@ import './index.scss' const phoneIcon = require('./images/phone.png') -// optionCode → 跳转路径映射 +// ctrlType / optionCode → 跳转路径映射 +// CtrlType: 1-押金 2-定时 3-信用 4-团购券 const OPTION_URL_MAP: Record = { - [CtrlType.DepositStart]: '/pageScan/selfStart/index', - [CtrlType.TimedStart]: '/pageScan/timedStart/index', - [CtrlType.CouponStart]: '/pageScan/couponStart/index', + [CtrlType.DepositStart]: '/pageScan/selfStart/index', // 1 + [CtrlType.TimedStart]: '/pageScan/timedStart/index', // 2 + [CtrlType.CouponStart]: '/pageScan/couponStart/index', // 4 } const StartTable = observer(() => { @@ -24,20 +25,25 @@ const StartTable = observer(() => { useLoad(() => { console.log('开台页面加载, grpSn:', grpSn) + console.log('[DEBUG] openOptions:', JSON.stringify(tableStore.scanInfo?.openOptions)) }) const handlePhoneCall = () => { Taro.makePhoneCall({ phoneNumber: '100-666-XXXX' }).catch(() => {}) } - const handleStartTable = (optionCode: number, available: boolean) => { + const handleStartTable = (option: { optionCode: number; type: number; title: string }, available: boolean) => { if (!available) { Taro.showToast({ title: '当前条件不满足,无法使用该开台方式', icon: 'none', duration: 2000 }) return } - const url = OPTION_URL_MAP[optionCode] + // 先用 optionCode 匹配,匹配不到再用 type 匹配 + const url = OPTION_URL_MAP[option.optionCode] ?? OPTION_URL_MAP[option.type] + console.log(`[DEBUG] 点击开台方式 title=${option.title} optionCode=${option.optionCode} type=${option.type} → url=${url}`) if (url) { Taro.navigateTo({ url: `${url}?grpSn=${grpSn}` }) + } else if (option.type === CtrlType.CreditStart) { + Taro.showToast({ title: '信用开台功能开发中', icon: 'none', duration: 2000 }) } else { Taro.showToast({ title: '功能开发中', icon: 'none', duration: 2000 }) } @@ -66,16 +72,16 @@ const StartTable = observer(() => { - ¥{price ? price.currentPrice.toFixed(2) : '--'} + ¥{price ? (price.currentPrice || price.standard || 0).toFixed(2) : '--'} /小时 押金 ¥{price ? price.deposit.toFixed(2) : '--'} - {price && price.memberPrice > 0 && ( + {price && (price.memberPrice ?? 0) > 0 && ( - VIP ¥{price.memberPrice.toFixed(2)} + VIP ¥{price.memberPrice!.toFixed(2)} )} @@ -100,7 +106,7 @@ const StartTable = observer(() => { handleStartTable(option.optionCode, option.available)} + onClick={() => handleStartTable(option, option.available)} > {option.available ? option.actionText || '去开台' : '不可用'} diff --git a/src/pages/scan/index.scss b/src/pages/scan/index.scss index 5d222e0..6402c23 100644 --- a/src/pages/scan/index.scss +++ b/src/pages/scan/index.scss @@ -14,12 +14,57 @@ } .content { - padding: 80px 32px; + padding: 40px 32px 80px; display: flex; flex-direction: column; align-items: center; gap: 40px; + // ─── 联调测试区 ─── + .test-section { + width: 100%; + background: #1a2a1a; + border: 2px solid #01CA68; + border-radius: 16px; + padding: 28px 32px; + display: flex; + flex-direction: column; + gap: 16px; + + .test-title { + font-size: 28px; + font-weight: bold; + color: #01CA68; + } + + .test-info { + font-size: 24px; + color: #aaaaaa; + } + + .test-btn-primary { + width: 100%; + height: 88px; + background: #01CA68; + border-radius: 44px; + color: #fff; + font-size: 32px; + font-weight: bold; + border: none; + } + + .test-btn-secondary { + width: 100%; + height: 88px; + background: transparent; + border: 2px solid #01CA68; + border-radius: 44px; + color: #01CA68; + font-size: 30px; + font-weight: bold; + } + } + .scan-btn { width: 400px; height: 400px; diff --git a/src/pages/scan/index.tsx b/src/pages/scan/index.tsx index bea90e4..21f1ece 100644 --- a/src/pages/scan/index.tsx +++ b/src/pages/scan/index.tsx @@ -6,15 +6,50 @@ import Taro, { useLoad } from '@tarojs/taro' import { observer } from 'mobx-react' import { useState } from 'react' import { Dialog } from '@taroify/core' +import { userStore } from '@/store' import './index.scss' +// 测试用设备 SN +const TEST_GRP_SN = 'GRP00000001' + const ScanIndex = observer(() => { const [showUnsettledDialog, setShowUnsettledDialog] = useState(false) useLoad(() => { console.log('扫码页面加载') + console.log('[测试] 当前登录状态:', { + openId: userStore.userInfo?.wxOpenId || Taro.getStorageSync('openId') || '未登录', + customerSn: userStore.userInfo?.sn || '无', + balance: userStore.balance, + }) }) + // ─── 测试专用:直通全流程(跳过扫码,用 TEST_GRP_SN) ─── + const handleTestFullFlow = () => { + const openId = userStore.userInfo?.wxOpenId || Taro.getStorageSync('openId') + if (!openId) { + Taro.showModal({ + title: '未登录', + content: '请先去「我的」页面完成微信登录,再测试开台流程', + showCancel: false, + confirmText: '知道了', + }) + return + } + const qrContent = JSON.stringify({ type: 'table_start', grpSn: TEST_GRP_SN }) + Taro.navigateTo({ + url: `/pages/qrHandler/index?qrContent=${encodeURIComponent(qrContent)}` + }) + } + + // ─── 测试专用:直接跳关台页(模拟台球桌已在使用中) ─── + const handleTestCloseTable = () => { + const qrContent = JSON.stringify({ type: 'table_close', grpSn: TEST_GRP_SN }) + Taro.navigateTo({ + url: `/pages/qrHandler/index?qrContent=${encodeURIComponent(qrContent)}` + }) + } + // 扫码 - 扫码结果统一交由 qrHandler 页面处理(负责调用 getTableInfo 等初始化逻辑) const handleScan = () => { Taro.scanCode({ @@ -94,10 +129,31 @@ const ScanIndex = observer(() => { 扫码开台 + + {/* ─── 联调测试区 ─── */} + + 🔧 联调测试 · {TEST_GRP_SN} + + 登录状态:{userStore.userInfo?.wxOpenId ? '已登录 ✅' : '未登录 ❌'} + + {userStore.userInfo?.wxOpenId && ( + + openId:{userStore.userInfo.wxOpenId.slice(0, 12)}... + + )} + + + + + {/* ─── 原有功能 ─── */} -