feat(qrCode): 添加payId属性并优化二维码状态检查逻辑
重构qrCode组件,添加payId属性以支持从父组件传入支付ID 优化二维码状态检查逻辑,过滤无效数据并添加空状态处理 调整vite配置,添加/admin代理规则
Showing
3 changed files
with
43 additions
and
28 deletions
| ... | @@ -78,6 +78,10 @@ const props = defineProps({ | ... | @@ -78,6 +78,10 @@ const props = defineProps({ |
| 78 | type: String, | 78 | type: String, |
| 79 | default: '' | 79 | default: '' |
| 80 | }, | 80 | }, |
| 81 | + payId: { | ||
| 82 | + type: String, | ||
| 83 | + default: '' | ||
| 84 | + }, | ||
| 81 | }); | 85 | }); |
| 82 | 86 | ||
| 83 | const select_index = ref(0); | 87 | const select_index = ref(0); |
| ... | @@ -151,7 +155,9 @@ const STATUS_CODE = { | ... | @@ -151,7 +155,9 @@ const STATUS_CODE = { |
| 151 | }; | 155 | }; |
| 152 | 156 | ||
| 153 | const refreshBtn = async () => { | 157 | const refreshBtn = async () => { |
| 154 | - const { code, data } = await qrcodeStatusAPI({ qr_code: userList.value[select_index.value].qr_code }); | 158 | + const current_item = userList.value[select_index.value]; |
| 159 | + if (!current_item?.qr_code) return; | ||
| 160 | + const { code, data } = await qrcodeStatusAPI({ qr_code: current_item.qr_code }); | ||
| 155 | if (code) { | 161 | if (code) { |
| 156 | useStatus.value = data.status; | 162 | useStatus.value = data.status; |
| 157 | } | 163 | } |
| ... | @@ -212,28 +218,31 @@ onMounted(async () => { | ... | @@ -212,28 +218,31 @@ onMounted(async () => { |
| 212 | item.datetime = formatDatetime({ begin_time: item.begin_time, end_time: item.end_time }) | 218 | item.datetime = formatDatetime({ begin_time: item.begin_time, end_time: item.end_time }) |
| 213 | item.sort = 0; | 219 | item.sort = 0; |
| 214 | }); | 220 | }); |
| 215 | - const { code: status_code, data: status_data } = await qrcodeStatusAPI({ qr_code: data[select_index.value]?.qr_code }); | 221 | + const valid_data = data.filter(item => item.qr_code !== ''); |
| 216 | - if (status_code) { | 222 | + if (valid_data.length) { |
| 217 | - useStatus.value = status_data.status; | 223 | + userList.value = formatGroup(valid_data); |
| 218 | - // 剔除qr_code为空的二维码 | 224 | + refreshBtn(); |
| 219 | - userList.value = data.filter(item => item.qr_code !== ''); | 225 | + } else { |
| 220 | - // TAG: 预约码入口的才需要分组 | 226 | + userList.value = []; |
| 221 | - userList.value = formatGroup(userList.value); | ||
| 222 | } | 227 | } |
| 223 | } | 228 | } |
| 224 | } else { | 229 | } else { |
| 225 | - const { code, data } = await billPersonAPI({ pay_id }); | 230 | + const current_pay_id = props.payId || pay_id; |
| 226 | - if (code) { | 231 | + if (current_pay_id) { |
| 227 | - data.forEach(item => { | 232 | + const { code, data } = await billPersonAPI({ pay_id: current_pay_id }); |
| 228 | - // 生成二维码地址 | 233 | + if (code) { |
| 229 | - item.qr_code_url = '/admin?m=srv&a=get_qrcode&key=' + item.qr_code; | 234 | + data.forEach(item => { |
| 230 | - item.sort = 0; | 235 | + // 生成二维码地址 |
| 231 | - }); | 236 | + item.qr_code_url = '/admin?m=srv&a=get_qrcode&key=' + item.qr_code; |
| 232 | - const { code: status_code, data: status_data } = await qrcodeStatusAPI({ qr_code: data[select_index.value]?.qr_code }); | 237 | + item.sort = 0; |
| 233 | - if (status_code) { | 238 | + }); |
| 234 | - useStatus.value = status_data.status; | 239 | + const valid_data = data.filter(item => item.qr_code !== ''); |
| 235 | - // 剔除qr_code为空的二维码 | 240 | + if (valid_data.length) { |
| 236 | - userList.value = data.filter(item => item.qr_code !== ''); | 241 | + userList.value = valid_data; |
| 242 | + refreshBtn(); | ||
| 243 | + } else { | ||
| 244 | + userList.value = []; | ||
| 245 | + } | ||
| 237 | } | 246 | } |
| 238 | } | 247 | } |
| 239 | } | 248 | } | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2024-01-16 13:19:23 | 2 | * @Date: 2024-01-16 13:19:23 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-01-30 16:10:10 | 4 | + * @LastEditTime: 2026-01-22 11:12:18 |
| 5 | - * @FilePath: /xysBooking/src/views/bookingDetail.vue | 5 | + * @FilePath: /git/xysBooking/src/views/bookingDetail.vue |
| 6 | * @Description: 预约记录详情 | 6 | * @Description: 预约记录详情 |
| 7 | --> | 7 | --> |
| 8 | <template> | 8 | <template> |
| 9 | <div class="booking-detail-page"> | 9 | <div class="booking-detail-page"> |
| 10 | - <qrCode :status="qrCodeStatus" type="detail"></qrCode> | 10 | + <qrCode :status="qrCodeStatus" type="detail" :payId="pay_id"></qrCode> |
| 11 | <div v-if="billInfo.pay_id" class="detail-wrapper"> | 11 | <div v-if="billInfo.pay_id" class="detail-wrapper"> |
| 12 | <div class="detail-item"> | 12 | <div class="detail-item"> |
| 13 | <div>参访时间:</div> | 13 | <div>参访时间:</div> | ... | ... |
| 1 | /* | 1 | /* |
| 2 | * @Date: 2023-06-13 13:26:46 | 2 | * @Date: 2023-06-13 13:26:46 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2023-08-25 14:14:26 | 4 | + * @LastEditTime: 2026-01-22 11:28:42 |
| 5 | - * @FilePath: /xysBooking/vite.config.js | 5 | + * @FilePath: /git/xysBooking/vite.config.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ |
| 8 | import vue from '@vitejs/plugin-vue'; | 8 | import vue from '@vitejs/plugin-vue'; |
| ... | @@ -15,16 +15,22 @@ import { defineConfig, loadEnv } from 'vite'; | ... | @@ -15,16 +15,22 @@ import { defineConfig, loadEnv } from 'vite'; |
| 15 | import { createProxy } from './build/proxy' | 15 | import { createProxy } from './build/proxy' |
| 16 | import DefineOptions from 'unplugin-vue-define-options/vite'; | 16 | import DefineOptions from 'unplugin-vue-define-options/vite'; |
| 17 | import AutoImport from 'unplugin-auto-import/vite'; | 17 | import AutoImport from 'unplugin-auto-import/vite'; |
| 18 | -import postcsspxtoviewport from 'postcss-px-to-viewport' | ||
| 19 | 18 | ||
| 20 | var path = require('path'); | 19 | var path = require('path'); |
| 21 | 20 | ||
| 22 | -export default ({ command, mode }) => { | 21 | +export default ({ mode }) => { |
| 23 | const root = process.cwd(); | 22 | const root = process.cwd(); |
| 24 | 23 | ||
| 25 | const viteEnv = loadEnv(mode, root); | 24 | const viteEnv = loadEnv(mode, root); |
| 26 | // let isProd = (command === 'serve'); // 情景配置是否为开发模式 serve 或 build | 25 | // let isProd = (command === 'serve'); // 情景配置是否为开发模式 serve 或 build |
| 27 | 26 | ||
| 27 | + const proxy = createProxy(viteEnv.VITE_PROXY_PREFIX, viteEnv.VITE_PROXY_TARGET); | ||
| 28 | + proxy['/admin'] = { | ||
| 29 | + target: viteEnv.VITE_PROXY_TARGET, | ||
| 30 | + changeOrigin: true, | ||
| 31 | + ws: true, | ||
| 32 | + }; | ||
| 33 | + | ||
| 28 | return defineConfig({ | 34 | return defineConfig({ |
| 29 | // root: '', | 35 | // root: '', |
| 30 | // root: './src/packages', // 多页面应用配置入口根目录 | 36 | // root: './src/packages', // 多页面应用配置入口根目录 |
| ... | @@ -130,7 +136,7 @@ export default ({ command, mode }) => { | ... | @@ -130,7 +136,7 @@ export default ({ command, mode }) => { |
| 130 | // // rewrite: (path) => path.replace(/^\/api/, '') | 136 | // // rewrite: (path) => path.replace(/^\/api/, '') |
| 131 | // }, | 137 | // }, |
| 132 | // }, | 138 | // }, |
| 133 | - proxy: createProxy(viteEnv.VITE_PROXY_PREFIX, viteEnv.VITE_PROXY_TARGET), | 139 | + proxy, |
| 134 | // cors: '', // 为开发服务器配置 CORS。默认启用并允许任何源,传递一个 选项对象 来调整行为或设为 false 表示禁用。 | 140 | // cors: '', // 为开发服务器配置 CORS。默认启用并允许任何源,传递一个 选项对象 来调整行为或设为 false 表示禁用。 |
| 135 | // force: '', // 设置为 true 强制使依赖预构建。 | 141 | // force: '', // 设置为 true 强制使依赖预构建。 |
| 136 | // hmr: '', // 禁用或配置 HMR 连接(用于 HMR websocket 必须使用不同的 http 服务器地址的情况)。 设置 server.hmr.overlay 为 false 可以禁用服务器错误遮罩层。 | 142 | // hmr: '', // 禁用或配置 HMR 连接(用于 HMR websocket 必须使用不同的 http 服务器地址的情况)。 设置 server.hmr.overlay 为 false 可以禁用服务器错误遮罩层。 | ... | ... |
-
Please register or login to post a comment