wui-components-v2 1.2.55 → 1.2.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,786 @@
1
+ <!--
2
+ WuiScanPanel 扫码识别面板(跨端持续扫码)
3
+ - 本组件不包含导航栏(由使用方通过公共导航栏承载),
4
+ 组件仅负责扫码识别区 + 状态行 + 手电筒按钮
5
+ - 中部白卡:扫码识别区 + 四角蓝色线框 + 扫描线动画 + 提示语
6
+ - 底部状态条与"开启手电筒"按钮
7
+ - 扫码能力(进入即持续扫描,自动识别):
8
+ H5 -> html5-qrcode 摄像头实时识别
9
+ 微信小程序 -> <camera> 常驻画面 + onCameraFrame + jsQR 实时识别
10
+ APP / 其他 -> 点击识别区触发 uni.scanCode
11
+ - 说明:本组件不包含图片识别与摄像头翻转功能
12
+ -->
13
+ <script setup lang="ts">
14
+ import { computed, nextTick, onMounted, onUnmounted, ref } from 'vue'
15
+ import { useManualTheme } from '../../core-components/composables/useManualTheme'
16
+
17
+ // 注意:不要在顶部静态 import 'html5-qrcode' / 'jsqr'(会打包进小程序/APP),
18
+ // 各端需要时在函数内动态 import() 加载,其他平台完全不会引入该依赖。
19
+
20
+ defineOptions({
21
+ name: 'WuiScanPanel',
22
+ })
23
+
24
+ // 获取项目当前主题色(跟随用户选择的主题色,默认 #2164F3)
25
+ const { currentThemeColor } = useManualTheme()
26
+
27
+ const props = withDefaults(
28
+ defineProps<{
29
+ /** 中部提示语 */
30
+ tipText?: string
31
+ /** 状态文案(如"识别中") */
32
+ statusText?: string
33
+ /** 状态后缀文案(如"请保持二维码清晰") */
34
+ statusSuffix?: string
35
+ /** 手电筒按钮文案 */
36
+ torchText?: string
37
+ /** 按钮主色 */
38
+ primaryColor?: string
39
+ /** 是否禁用手电筒 */
40
+ torchDisabled?: boolean
41
+ /** 挂载后自动启动扫码 */
42
+ autoStart?: boolean
43
+ }>(),
44
+ {
45
+ tipText: '将二维码放入框内即可自动识别',
46
+ statusText: '识别中',
47
+ statusSuffix: '请保持二维码清晰',
48
+ torchText: '开启手电筒',
49
+ // primaryColor 默认为空,使用项目主题色 var(--wsp-primary)
50
+ primaryColor: '',
51
+ torchDisabled: false,
52
+ autoStart: true,
53
+ }
54
+ )
55
+
56
+ const emit = defineEmits<{
57
+ (e: 'torch'): void
58
+ (e: 'scan', data: string): void
59
+ (e: 'error', message: string): void
60
+ }>()
61
+
62
+ // ---- 扫码状态 ----
63
+ const isScanning = ref(false)
64
+ const isLoading = ref(false)
65
+ const torchOn = ref(false)
66
+ const statusOpen = ref(false)
67
+
68
+ // 识别区是否正在显示摄像头画面
69
+ const showCamera = ref(false)
70
+
71
+ // 小程序 camera 闪光灯模式(微信小程序支持 'torch',类型用 any 规避枚举限制)
72
+ const cameraFlash = computed<any>(() => (torchOn.value ? 'torch' : 'off'))
73
+
74
+ // ======================== 统一扫码成功处理 ========================
75
+ function handleScanSuccess(text: string) {
76
+ if (!text) return
77
+ uni.showToast({ title: '扫描成功', icon: 'success' })
78
+ emit('scan', text)
79
+ }
80
+
81
+ // ======================== H5 平台扫码(html5-qrcode) ========================
82
+ type Html5QrcodeInstance = {
83
+ start: (config: object, opts: object, onSuccess: (text: string) => void, onFailure: () => void) => Promise<void>
84
+ stop: () => Promise<void>
85
+ clear: () => Promise<void>
86
+ isScanning?: boolean
87
+ }
88
+
89
+ // #ifdef H5
90
+ let html5QrcodeScanner: Html5QrcodeInstance | null = null
91
+ let scanLocked = false
92
+
93
+ /** 环境检测:需 https 或 localhost */
94
+ function checkCameraEnvironment(): { ok: boolean; reason?: string } {
95
+ if (typeof window === 'undefined') return { ok: true }
96
+ const hostname = window.location.hostname
97
+ if (hostname === 'localhost' || hostname === '127.0.0.1') return { ok: true }
98
+ if (window.location.protocol !== 'https:') {
99
+ return { ok: false, reason: '当前非 HTTPS 环境,请在 https 下使用扫码功能' }
100
+ }
101
+ return { ok: true }
102
+ }
103
+
104
+ /** 启动 H5 摄像头扫码(html5-qrcode 动态加载,仅 H5 平台) */
105
+ async function startH5Scan() {
106
+ if (isScanning.value || scanLocked) return
107
+ const envCheck = checkCameraEnvironment()
108
+ if (!envCheck.ok) {
109
+ emit('error', envCheck.reason || '环境不支持')
110
+ uni.showToast({ title: envCheck.reason || '环境不支持', icon: 'none' })
111
+ return
112
+ }
113
+
114
+ isLoading.value = true
115
+ isScanning.value = true
116
+ scanLocked = false
117
+ showCamera.value = true
118
+
119
+ try {
120
+ // 动态加载,避免打包进小程序/APP
121
+ const { Html5Qrcode } = await import('html5-qrcode')
122
+
123
+ await nextTick()
124
+ await new Promise(r => setTimeout(r, 200))
125
+
126
+ const container = document.getElementById('wsp-scan-reader')
127
+ if (!container) throw new Error('扫码容器未找到')
128
+
129
+ html5QrcodeScanner = new Html5Qrcode('wsp-scan-reader') as unknown as Html5QrcodeInstance
130
+
131
+ await html5QrcodeScanner.start(
132
+ { facingMode: 'environment' },
133
+ { fps: 5 },
134
+ (decodedText: string) => {
135
+ if (scanLocked || !isScanning.value) return
136
+ scanLocked = true
137
+ console.log('[WuiScanPanel] 扫码成功:', decodedText)
138
+ handleScanSuccess(decodedText)
139
+ stopH5Scan()
140
+ },
141
+ () => {} // 忽略中间帧未识别错误
142
+ )
143
+
144
+ // JS 强制 video 填充识别区
145
+ const videoEl = document.querySelector('#wsp-scan-reader video') as HTMLVideoElement | null
146
+ if (videoEl) {
147
+ Object.assign(videoEl.style, {
148
+ width: '100%',
149
+ height: '100%',
150
+ objectFit: 'cover',
151
+ objectPosition: 'center',
152
+ })
153
+ }
154
+ } catch (error: unknown) {
155
+ console.error('[WuiScanPanel] 启动失败:', error)
156
+ const errMsg = error instanceof Error ? error.message : String(error)
157
+ let msg = '摄像头访问失败'
158
+ if (/Permission|NotAllowed/i.test(errMsg)) msg = '请允许浏览器使用摄像头'
159
+ else if (/NotFound|not found/i.test(errMsg)) msg = '未检测到摄像头设备'
160
+ else if (/secure origin|insecure/i.test(errMsg)) msg = '需要 HTTPS 环境才能使用摄像头'
161
+
162
+ emit('error', msg)
163
+ isScanning.value = false
164
+ showCamera.value = false
165
+ uni.showModal({ title: '提示', content: msg, showCancel: false })
166
+ } finally {
167
+ isLoading.value = false
168
+ }
169
+ }
170
+
171
+ /** 停止 H5 摄像头扫码 */
172
+ async function stopH5Scan() {
173
+ isScanning.value = false
174
+ scanLocked = false
175
+ showCamera.value = false
176
+ if (html5QrcodeScanner) {
177
+ try {
178
+ if (html5QrcodeScanner.isScanning) await html5QrcodeScanner.stop()
179
+ await html5QrcodeScanner.clear()
180
+ } catch {
181
+ /* ignore cleanup error */
182
+ }
183
+ html5QrcodeScanner = null
184
+ }
185
+ }
186
+ // #endif
187
+
188
+ // ======================== 微信小程序扫码(<camera> + jsQR) ========================
189
+ // #ifdef MP-WEIXIN
190
+ let cameraContext: any = null
191
+ let frameListener: ((frame: any) => void) | null = null
192
+ let jsQR: ((data: Uint8ClampedArray, width: number, height: number) => any) | null = null
193
+ let mpScanLocked = false
194
+ let frameCounter = 0
195
+
196
+ /** 初始化并启动微信小程序常驻扫码 */
197
+ async function startMpScan() {
198
+ if (isScanning.value || mpScanLocked) return
199
+
200
+ isLoading.value = true
201
+ isScanning.value = true
202
+ mpScanLocked = false
203
+ showCamera.value = true
204
+
205
+ try {
206
+ // 动态加载 jsQR(jsqr 为 default 导出)
207
+ const jsqrModule = await import('jsqr')
208
+ jsQR = jsqrModule.default
209
+
210
+ await nextTick()
211
+ await new Promise(r => setTimeout(r, 200))
212
+
213
+ // 创建摄像头上下文
214
+ cameraContext = uni.createCameraContext()
215
+ if (!cameraContext || typeof cameraContext.onCameraFrame !== 'function') {
216
+ throw new Error('当前环境不支持摄像头实时帧识别')
217
+ }
218
+
219
+ // 监听摄像头帧,隔帧识别二维码
220
+ frameListener = (frame: any) => {
221
+ if (mpScanLocked || !isScanning.value || !jsQR) return
222
+ // 每 3 帧识别一次,降低 CPU 压力
223
+ frameCounter++
224
+ if (frameCounter % 3 !== 0) return
225
+
226
+ try {
227
+ const data = new Uint8ClampedArray(frame.data)
228
+ const code = jsQR(data, frame.width, frame.height)
229
+ if (code && code.data) {
230
+ mpScanLocked = true
231
+ console.log('[WuiScanPanel] 扫码成功:', code.data)
232
+ handleScanSuccess(code.data)
233
+ stopMpScan()
234
+ }
235
+ } catch (e) {
236
+ console.error('[WuiScanPanel] 帧识别失败:', e)
237
+ }
238
+ }
239
+ cameraContext.onCameraFrame(frameListener)
240
+ // 开始发送帧数据
241
+ if (typeof cameraContext.startRecord === 'function') {
242
+ // onCameraFrame 会随摄像头自动回调,无需 startRecord
243
+ }
244
+ } catch (error: unknown) {
245
+ console.error('[WuiScanPanel] 小程序扫码启动失败:', error)
246
+ const msg = error instanceof Error ? error.message : '摄像头启动失败'
247
+ emit('error', msg)
248
+ isScanning.value = false
249
+ showCamera.value = false
250
+ uni.showModal({ title: '提示', content: msg, showCancel: false })
251
+ } finally {
252
+ isLoading.value = false
253
+ }
254
+ }
255
+
256
+ /** 停止微信小程序扫码 */
257
+ function stopMpScan() {
258
+ isScanning.value = false
259
+ mpScanLocked = false
260
+ showCamera.value = false
261
+ if (cameraContext && frameListener) {
262
+ try {
263
+ if (typeof cameraContext.onCameraFrame === 'function') {
264
+ // 通过再次调用并传入空监听不可行,需保存 listener 以清除
265
+ cameraContext.onCameraFrame(null)
266
+ }
267
+ } catch {
268
+ /* ignore */
269
+ }
270
+ frameListener = null
271
+ }
272
+ jsQR = null
273
+ }
274
+ // #endif
275
+
276
+ // ======================== 其他平台(APP 等)扫码 ========================
277
+ function startUniScanCode() {
278
+ // #ifdef APP-PLUS
279
+ uni.scanCode({
280
+ scanType: ['qrCode', 'barCode'],
281
+ onlyFromCamera: true,
282
+ success(res) {
283
+ const result = (res && res.result) || ''
284
+ if (!result) {
285
+ uni.showToast({ title: '扫码结果为空', icon: 'none' })
286
+ return
287
+ }
288
+ handleScanSuccess(result)
289
+ },
290
+ fail() {
291
+ emit('error', '扫描已取消')
292
+ },
293
+ })
294
+ // #endif
295
+ }
296
+
297
+ // ======================== 统一入口 ========================
298
+ function startScan() {
299
+ // #ifdef H5
300
+ startH5Scan()
301
+ // #endif
302
+ // #ifdef MP-WEIXIN
303
+ startMpScan()
304
+ // #endif
305
+ // #ifndef H5 || MP-WEIXIN
306
+ startUniScanCode()
307
+ // #endif
308
+ }
309
+
310
+ function stopScan() {
311
+ // #ifdef H5
312
+ stopH5Scan()
313
+ // #endif
314
+ // #ifdef MP-WEIXIN
315
+ stopMpScan()
316
+ // #endif
317
+ }
318
+
319
+ /** 供父组件调用 */
320
+ defineExpose({ startScan, stopScan })
321
+
322
+ // ======================== 交互事件 ========================
323
+ /** 点击识别区:APP 等平台触发系统扫码 */
324
+ function onScanAreaClick() {
325
+ // #ifndef H5 || MP-WEIXIN
326
+ startUniScanCode()
327
+ // #endif
328
+ }
329
+
330
+ /** 手电筒开关 */
331
+ function onTorch() {
332
+ if (props.torchDisabled) return
333
+ torchOn.value = !torchOn.value
334
+ // #ifdef MP-WEIXIN
335
+ // 微信小程序可切换 camera flash
336
+ const flashMode = torchOn.value ? 'torch' : 'off'
337
+ if (cameraContext) {
338
+ try {
339
+ cameraContext.setCameraFlash({ flash: flashMode })
340
+ } catch {
341
+ /* ignore */
342
+ }
343
+ }
344
+ // #endif
345
+ uni.showToast({ title: torchOn.value ? '手电筒已开启' : '手电筒已关闭', icon: 'none' })
346
+ emit('torch')
347
+ }
348
+
349
+ function toggleStatus() {
350
+ statusOpen.value = !statusOpen.value
351
+ }
352
+
353
+ // ======================== 生命周期 ========================
354
+ onMounted(() => {
355
+ if (props.autoStart) startScan()
356
+ })
357
+ onUnmounted(() => {
358
+ // #ifdef H5
359
+ stopH5Scan()
360
+ // #endif
361
+ // #ifdef MP-WEIXIN
362
+ stopMpScan()
363
+ // #endif
364
+ })
365
+ </script>
366
+
367
+ <template>
368
+ <view class="wsp-root" :style="{ '--wsp-primary': currentThemeColor.primary }">
369
+ <!-- 内容区 -->
370
+ <view class="wsp-body">
371
+ <view class="wsp-card">
372
+ <!-- 二维码识别区 -->
373
+ <view class="wsp-scan-area">
374
+ <!-- 微信小程序:常驻摄像头画面 + 扫描线 -->
375
+ <!-- #ifdef MP-WEIXIN -->
376
+ <view class="wsp-camera">
377
+ <camera
378
+ id="wsp-camera"
379
+ class="wsp-camera-el"
380
+ device-position="back"
381
+ :flash="cameraFlash"
382
+ resolution="medium"
383
+ />
384
+ <view class="wsp-scan-line" />
385
+ </view>
386
+ <!-- #endif -->
387
+
388
+ <!-- H5:摄像头画面 + 扫描线(html5-qrcode 容器始终渲染) -->
389
+ <!-- #ifdef H5 -->
390
+ <view class="wsp-camera">
391
+ <div id="wsp-scan-reader" class="wsp-camera-reader" />
392
+ <view class="wsp-scan-line" />
393
+ </view>
394
+ <!-- #endif -->
395
+
396
+ <!-- APP 等平台:点击识别区触发系统扫码 -->
397
+ <!-- #ifndef H5 || MP-WEIXIN -->
398
+ <view class="wsp-scan-guide" @click="onScanAreaClick">
399
+ <view class="wsp-scan-guide-icon">
400
+ <wd-icon name="scan" size="60rpx" :color="currentThemeColor.primary" />
401
+ </view>
402
+ <text class="wsp-scan-guide-text">点击开始扫码</text>
403
+ </view>
404
+ <!-- #endif -->
405
+
406
+ <!-- 加载遮罩(摄像头启动中) -->
407
+ <view v-if="isLoading" class="wsp-loading-mask">
408
+ <view class="wsp-loading-box">
409
+ <text class="wsp-loading-text">正在启动摄像头...</text>
410
+ </view>
411
+ </view>
412
+ </view>
413
+
414
+ <!-- 提示语 -->
415
+ <view class="wsp-tip">
416
+ <text class="wsp-tip-text">
417
+ {{ props.tipText }}
418
+ </text>
419
+ </view>
420
+
421
+ <!-- 状态行 -->
422
+ <view class="wsp-status">
423
+ <view class="wsp-status-left" @click="toggleStatus">
424
+ <text class="wsp-status-text">
425
+ {{ props.statusText }}
426
+ </text>
427
+ <text class="wsp-status-caret" :class="{ 'is-open': statusOpen }">▼</text>
428
+ </view>
429
+ <text class="wsp-status-suffix">
430
+ {{ props.statusSuffix }}
431
+ </text>
432
+ </view>
433
+ </view>
434
+ </view>
435
+
436
+ <!-- 底部按钮:仅手电筒 -->
437
+ <view class="wsp-footer">
438
+ <view
439
+ class="wsp-btn wsp-btn--primary wsp-btn--single"
440
+ :class="{ 'is-disabled': props.torchDisabled }"
441
+ :style="{ background: props.primaryColor || 'var(--wsp-primary)' }"
442
+ @click="onTorch"
443
+ >
444
+ <text class="wsp-btn-text">
445
+ {{ props.torchText }}
446
+ </text>
447
+ </view>
448
+ </view>
449
+ </view>
450
+ </template>
451
+
452
+ <style lang="scss">
453
+ /* html5-qrcode 渲染容器(全局,避免 scoped 裁剪) */
454
+ #wsp-scan-reader {
455
+ width: 100% !important;
456
+ height: 100% !important;
457
+ border-radius: 16rpx;
458
+
459
+ video {
460
+ width: 100% !important;
461
+ height: 100% !important;
462
+ object-fit: cover !important;
463
+ object-position: center !important;
464
+ border-radius: 16rpx;
465
+ }
466
+
467
+ #qr-shaded-region {
468
+ border-radius: inherit;
469
+ }
470
+ }
471
+ </style>
472
+
473
+ <style scoped lang="scss">
474
+ .wsp-root {
475
+ position: relative;
476
+ width: 100%;
477
+ min-height: 100vh;
478
+ // 背景继承页面全局主题背景(theme.json 的 bgColor),不在此处硬编码
479
+ background: transparent;
480
+ display: flex;
481
+ flex-direction: column;
482
+ overflow: hidden;
483
+ }
484
+
485
+ // ============== 内容卡片 ==============
486
+ .wsp-body {
487
+ flex: 1;
488
+ padding: 60rpx 40rpx 0;
489
+ display: flex;
490
+ justify-content: center;
491
+ }
492
+
493
+ .wsp-card {
494
+ width: 100%;
495
+ max-width: 660rpx;
496
+ background: #ffffff;
497
+ border-radius: 28rpx;
498
+ padding: 80rpx 60rpx 0;
499
+ box-sizing: border-box;
500
+ box-shadow:
501
+ 0 16rpx 40rpx rgba(0, 0, 0, 0.06),
502
+ 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
503
+ position: relative;
504
+ display: flex;
505
+ flex-direction: column;
506
+ }
507
+
508
+ // 识别区
509
+ .wsp-scan-area {
510
+ position: relative;
511
+ width: 100%;
512
+ aspect-ratio: 1 / 1;
513
+ display: flex;
514
+ align-items: center;
515
+ justify-content: center;
516
+
517
+ .wsp-corner {
518
+ position: absolute;
519
+ width: 56rpx;
520
+ height: 56rpx;
521
+ border-color: var(--wsp-primary, #2164f3);
522
+ border-style: solid;
523
+ border-width: 0;
524
+ z-index: 6;
525
+ }
526
+ .wsp-corner--tl {
527
+ top: -10rpx;
528
+ left: -10rpx;
529
+ border-top-width: 6rpx;
530
+ border-left-width: 6rpx;
531
+ border-top-left-radius: 24rpx;
532
+ }
533
+ .wsp-corner--tr {
534
+ top: -10rpx;
535
+ right: -10rpx;
536
+ border-top-width: 6rpx;
537
+ border-right-width: 6rpx;
538
+ border-top-right-radius: 24rpx;
539
+ }
540
+ .wsp-corner--bl {
541
+ bottom: -10rpx;
542
+ left: -10rpx;
543
+ border-bottom-width: 6rpx;
544
+ border-left-width: 6rpx;
545
+ border-bottom-left-radius: 24rpx;
546
+ }
547
+ .wsp-corner--br {
548
+ bottom: -10rpx;
549
+ right: -10rpx;
550
+ border-bottom-width: 6rpx;
551
+ border-right-width: 6rpx;
552
+ border-bottom-right-radius: 24rpx;
553
+ }
554
+
555
+ // 摄像头区域(H5 / 微信小程序)
556
+ .wsp-camera {
557
+ width: 100%;
558
+ height: 100%;
559
+ border-radius: 16rpx;
560
+ overflow: hidden;
561
+ position: relative;
562
+ background: #000;
563
+
564
+ .wsp-camera-reader {
565
+ width: 100%;
566
+ height: 100%;
567
+ }
568
+
569
+ .wsp-camera-el {
570
+ width: 100%;
571
+ height: 100%;
572
+ }
573
+
574
+ .wsp-scan-line {
575
+ position: absolute;
576
+ left: 8%;
577
+ right: 8%;
578
+ top: 0;
579
+ height: 4rpx;
580
+ background: linear-gradient(90deg, transparent, #07c160 20%, #07c160 80%, transparent);
581
+ border-radius: 2rpx;
582
+ box-shadow: 0 0 16rpx 4rpx rgba(7, 193, 96, 0.8);
583
+ animation: wsp-sweep 2.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
584
+ pointer-events: none;
585
+ z-index: 5;
586
+ }
587
+ }
588
+
589
+ // 非 H5/小程序平台扫码引导(点击识别区触发系统扫码)
590
+ .wsp-scan-guide {
591
+ width: 78%;
592
+ height: 78%;
593
+ background: #f6f8ff;
594
+ border-radius: 16rpx;
595
+ display: flex;
596
+ flex-direction: column;
597
+ align-items: center;
598
+ justify-content: center;
599
+ gap: 24rpx;
600
+ cursor: pointer;
601
+
602
+ &:active {
603
+ opacity: 0.8;
604
+ }
605
+
606
+ .wsp-scan-guide-icon {
607
+ width: 120rpx;
608
+ height: 120rpx;
609
+ border-radius: 50%;
610
+ background: #eaf0ff;
611
+ display: flex;
612
+ align-items: center;
613
+ justify-content: center;
614
+ }
615
+
616
+ .wsp-scan-guide-text {
617
+ color: var(--wsp-primary, #2164f3);
618
+ font-size: 28rpx;
619
+ font-weight: 500;
620
+ letter-spacing: 1rpx;
621
+ }
622
+ }
623
+
624
+ // 加载遮罩
625
+ .wsp-loading-mask {
626
+ position: absolute;
627
+ inset: 0;
628
+ display: flex;
629
+ align-items: center;
630
+ justify-content: center;
631
+ z-index: 10;
632
+ background: rgba(0, 0, 0, 0.4);
633
+ border-radius: 16rpx;
634
+
635
+ .wsp-loading-box {
636
+ background: rgba(0, 0, 0, 0.7);
637
+ padding: 24rpx 40rpx;
638
+ border-radius: 12rpx;
639
+
640
+ .wsp-loading-text {
641
+ color: #fff;
642
+ font-size: 26rpx;
643
+ }
644
+ }
645
+ }
646
+ }
647
+
648
+ // 提示语
649
+ .wsp-tip {
650
+ margin-top: 50rpx;
651
+ display: flex;
652
+ justify-content: center;
653
+
654
+ .wsp-tip-text {
655
+ color: #4b5563;
656
+ font-size: 28rpx;
657
+ letter-spacing: 1rpx;
658
+ }
659
+ }
660
+
661
+ // 状态行
662
+ .wsp-status {
663
+ margin-top: 60rpx;
664
+ padding: 40rpx 0;
665
+ border-top: 1rpx solid #e5e7eb;
666
+ display: flex;
667
+ align-items: center;
668
+ gap: 24rpx;
669
+
670
+ .wsp-status-left {
671
+ display: flex;
672
+ align-items: center;
673
+ gap: 8rpx;
674
+ }
675
+
676
+ .wsp-status-text {
677
+ color: #1f2937;
678
+ font-size: 30rpx;
679
+ font-weight: 600;
680
+ }
681
+
682
+ .wsp-status-caret {
683
+ color: #9ca3af;
684
+ font-size: 20rpx;
685
+ transition: transform 0.2s ease;
686
+ &.is-open {
687
+ transform: rotate(180deg);
688
+ }
689
+ }
690
+
691
+ .wsp-status-suffix {
692
+ color: #9ca3af;
693
+ font-size: 26rpx;
694
+ }
695
+ }
696
+
697
+ // ============== 底部按钮 ==============
698
+ .wsp-footer {
699
+ padding: 100rpx 48rpx calc(80rpx + env(safe-area-inset-bottom, 0));
700
+ display: flex;
701
+ justify-content: center;
702
+
703
+ .wsp-btn {
704
+ height: 96rpx;
705
+ border-radius: 48rpx;
706
+ display: flex;
707
+ align-items: center;
708
+ justify-content: center;
709
+ transition:
710
+ opacity 0.2s ease,
711
+ transform 0.15s ease;
712
+
713
+ &:active {
714
+ transform: scale(0.98);
715
+ }
716
+
717
+ &.is-disabled {
718
+ opacity: 0.5;
719
+ }
720
+ }
721
+
722
+ .wsp-btn--primary {
723
+ color: #fff;
724
+
725
+ .wsp-btn-text {
726
+ color: #fff;
727
+ font-size: 32rpx;
728
+ font-weight: 600;
729
+ letter-spacing: 2rpx;
730
+ }
731
+ }
732
+
733
+ // 单个按钮时居中,宽度约为内容两倍
734
+ .wsp-btn--single {
735
+ width: 360rpx;
736
+ }
737
+ }
738
+
739
+ @keyframes wsp-sweep {
740
+ 0% {
741
+ top: 2%;
742
+ opacity: 1;
743
+ }
744
+ 45% {
745
+ opacity: 1;
746
+ }
747
+ 100% {
748
+ top: 94%;
749
+ opacity: 0.25;
750
+ }
751
+ }
752
+
753
+ // ============== 暗黑模式适配 ==============
754
+ ::global(.wot-theme-dark) {
755
+ .wsp-card {
756
+ background: var(--wot-dark-background2, #1f2937);
757
+ box-shadow:
758
+ 0 16rpx 40rpx rgba(0, 0, 0, 0.5),
759
+ 0 2rpx 8rpx rgba(0, 0, 0, 0.3);
760
+ }
761
+
762
+ .wsp-status {
763
+ border-top-color: rgba(255, 255, 255, 0.08);
764
+
765
+ .wsp-status-text {
766
+ color: #f9fafb;
767
+ }
768
+
769
+ .wsp-status-suffix {
770
+ color: #6b7280;
771
+ }
772
+ }
773
+
774
+ .wsp-tip-text {
775
+ color: #d1d5db !important;
776
+ }
777
+
778
+ .wsp-scan-guide {
779
+ background: rgba(255, 255, 255, 0.04);
780
+
781
+ .wsp-scan-guide-icon {
782
+ background: rgba(33, 100, 243, 0.2);
783
+ }
784
+ }
785
+ }
786
+ </style>