Browse Source

添加扫码调试方法

master
DU 2 months ago
parent
commit
4fe1f50713
  1. 6
      src/config/index.ts
  2. 26
      src/pageScan/startTable/index.tsx
  3. 47
      src/pages/scan/index.scss
  4. 58
      src/pages/scan/index.tsx
  5. 2
      src/services/request.ts

6
src/config/index.ts

@ -5,10 +5,12 @@
// API 基础地址配置 // 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 // 大图服务器地址 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 版本 // API 版本
const API_VERSION = 'v2' const API_VERSION = 'v2'

26
src/pageScan/startTable/index.tsx

@ -10,11 +10,12 @@ import './index.scss'
const phoneIcon = require('./images/phone.png') const phoneIcon = require('./images/phone.png')
// optionCode → 跳转路径映射 // ctrlType / optionCode → 跳转路径映射
// CtrlType: 1-押金 2-定时 3-信用 4-团购券
const OPTION_URL_MAP: Record<number, string> = { const OPTION_URL_MAP: Record<number, string> = {
[CtrlType.DepositStart]: '/pageScan/selfStart/index', [CtrlType.DepositStart]: '/pageScan/selfStart/index', // 1
[CtrlType.TimedStart]: '/pageScan/timedStart/index', [CtrlType.TimedStart]: '/pageScan/timedStart/index', // 2
[CtrlType.CouponStart]: '/pageScan/couponStart/index', [CtrlType.CouponStart]: '/pageScan/couponStart/index', // 4
} }
const StartTable = observer(() => { const StartTable = observer(() => {
@ -24,20 +25,25 @@ const StartTable = observer(() => {
useLoad(() => { useLoad(() => {
console.log('开台页面加载, grpSn:', grpSn) console.log('开台页面加载, grpSn:', grpSn)
console.log('[DEBUG] openOptions:', JSON.stringify(tableStore.scanInfo?.openOptions))
}) })
const handlePhoneCall = () => { const handlePhoneCall = () => {
Taro.makePhoneCall({ phoneNumber: '100-666-XXXX' }).catch(() => {}) 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) { if (!available) {
Taro.showToast({ title: '当前条件不满足,无法使用该开台方式', icon: 'none', duration: 2000 }) Taro.showToast({ title: '当前条件不满足,无法使用该开台方式', icon: 'none', duration: 2000 })
return 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) { if (url) {
Taro.navigateTo({ url: `${url}?grpSn=${grpSn}` }) Taro.navigateTo({ url: `${url}?grpSn=${grpSn}` })
} else if (option.type === CtrlType.CreditStart) {
Taro.showToast({ title: '信用开台功能开发中', icon: 'none', duration: 2000 })
} else { } else {
Taro.showToast({ title: '功能开发中', icon: 'none', duration: 2000 }) Taro.showToast({ title: '功能开发中', icon: 'none', duration: 2000 })
} }
@ -66,16 +72,16 @@ const StartTable = observer(() => {
<View className="price-info"> <View className="price-info">
<View className="price-item"> <View className="price-item">
<Text className="price-value">¥{price ? price.currentPrice.toFixed(2) : '--'}</Text> <Text className="price-value">¥{price ? (price.currentPrice || price.standard || 0).toFixed(2) : '--'}</Text>
<Text className="price-label">/</Text> <Text className="price-label">/</Text>
</View> </View>
<View className="price-item"> <View className="price-item">
<Text className="price-label"></Text> <Text className="price-label"></Text>
<Text className="price-value">¥{price ? price.deposit.toFixed(2) : '--'}</Text> <Text className="price-value">¥{price ? price.deposit.toFixed(2) : '--'}</Text>
</View> </View>
{price && price.memberPrice > 0 && ( {price && (price.memberPrice ?? 0) > 0 && (
<View className="vip-price"> <View className="vip-price">
<Text className="vip-text">VIP ¥{price.memberPrice.toFixed(2)}</Text> <Text className="vip-text">VIP ¥{price.memberPrice!.toFixed(2)}</Text>
</View> </View>
)} )}
</View> </View>
@ -100,7 +106,7 @@ const StartTable = observer(() => {
<View className="method-right"> <View className="method-right">
<View <View
className={`start-btn ${!option.available ? 'disabled' : ''}`} className={`start-btn ${!option.available ? 'disabled' : ''}`}
onClick={() => handleStartTable(option.optionCode, option.available)} onClick={() => handleStartTable(option, option.available)}
> >
<Text className="btn-text">{option.available ? option.actionText || '去开台' : '不可用'}</Text> <Text className="btn-text">{option.available ? option.actionText || '去开台' : '不可用'}</Text>
</View> </View>

47
src/pages/scan/index.scss

@ -14,12 +14,57 @@
} }
.content { .content {
padding: 80px 32px; padding: 40px 32px 80px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
gap: 40px; 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 { .scan-btn {
width: 400px; width: 400px;
height: 400px; height: 400px;

58
src/pages/scan/index.tsx

@ -6,15 +6,50 @@ import Taro, { useLoad } from '@tarojs/taro'
import { observer } from 'mobx-react' import { observer } from 'mobx-react'
import { useState } from 'react' import { useState } from 'react'
import { Dialog } from '@taroify/core' import { Dialog } from '@taroify/core'
import { userStore } from '@/store'
import './index.scss' import './index.scss'
// 测试用设备 SN
const TEST_GRP_SN = 'GRP00000001'
const ScanIndex = observer(() => { const ScanIndex = observer(() => {
const [showUnsettledDialog, setShowUnsettledDialog] = useState(false) const [showUnsettledDialog, setShowUnsettledDialog] = useState(false)
useLoad(() => { useLoad(() => {
console.log('扫码页面加载') 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 等初始化逻辑) // 扫码 - 扫码结果统一交由 qrHandler 页面处理(负责调用 getTableInfo 等初始化逻辑)
const handleScan = () => { const handleScan = () => {
Taro.scanCode({ Taro.scanCode({
@ -94,10 +129,31 @@ const ScanIndex = observer(() => {
<Text className="title"></Text> <Text className="title"></Text>
</View> </View>
<View className="content"> <View className="content">
{/* ─── 联调测试区 ─── */}
<View className="test-section">
<Text className="test-title">🔧 · {TEST_GRP_SN}</Text>
<Text className="test-info">
{userStore.userInfo?.wxOpenId ? '已登录 ✅' : '未登录 ❌'}
</Text>
{userStore.userInfo?.wxOpenId && (
<Text className="test-info">
openId{userStore.userInfo.wxOpenId.slice(0, 12)}...
</Text>
)}
<Button className="test-btn-primary" onClick={handleTestFullFlow}>
</Button>
<Button className="test-btn-secondary" onClick={handleTestCloseTable}>
使
</Button>
</View>
{/* ─── 原有功能 ─── */}
<Button className="scan-btn" onClick={handleScan}> <Button className="scan-btn" onClick={handleScan}>
</Button> </Button>
<Button className="start-table-btn" onClick={handleReservation}> <Button className="start-table-btn" onClick={handleReservation}>
</Button> </Button>
<Button className="start-table-btn" onClick={handleAppointmentStart}> <Button className="start-table-btn" onClick={handleAppointmentStart}>

2
src/services/request.ts

@ -134,7 +134,7 @@ const request = async <T = any>(options: RequestConfig): Promise<ResponseResult<
}) })
if (config.debug) { if (config.debug) {
console.log('[Response]', response.statusCode, response.data) console.log('[Response]', response.statusCode, JSON.stringify(response.data))
} }
// 响应拦截 // 响应拦截

Loading…
Cancel
Save