Blame view

泰额版/Food Labeling Management App UniApp/src/pages/labels/labels.vue 38.8 KB
59e51671   “wangming”   1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  <template>
    <view class="page">
      <view class="header-hero" :style="{ paddingTop: statusBarHeight + 'px' }">
        <view class="top-bar">
          <view class="top-left" @click="goBack">
            <AppIcon name="chevronLeft" size="sm" color="white" />
          </view>
          <view class="top-center">
            <text class="app-name">Labeling</text>
            <LocationPicker />
          </view>
          <view class="top-right" @click="isMenuOpen = true">
            <AppIcon name="menu" size="sm" color="white" />
          </view>
        </view>
  
        <view class="bt-bar" @click="goBluetoothPage">
          <view class="bt-left">
            <AppIcon name="bluetooth" size="sm" color="white" />
            <text class="bt-text">{{ btConnected ? btDeviceName : 'No printer connected' }}</text>
          </view>
          <view class="bt-status" :class="{ connected: btConnected }">
            <text class="bt-dot" />
            <text class="bt-label">{{ btConnected ? 'Connected' : 'Disconnected' }}</text>
          </view>
          <AppIcon name="chevronRight" size="sm" color="white" />
        </view>
      </view>
  
      <view class="body">
        <view class="sidebar">
          <view v-if="listLoading && labelTree.length === 0" class="sidebar-loading">
            <text class="sidebar-loading-text">Loading…</text>
          </view>
          <view
            v-for="cat in labelTree"
            :key="cat.id"
            class="cat-item"
            :class="{ active: selectedCategoryId === cat.id }"
            @click="selectedCategoryId = cat.id"
          >
            <view v-if="selectedCategoryId === cat.id" class="active-bar" />
5a192b24   杨鑫   最新同步
43
44
45
46
47
48
49
50
            <view class="cat-card-frame">
              <view class="cat-card-inner">
              <view
                class="cat-visual"
                :class="[
                  labelCategoryVisual(cat).mode === 'image' ? 'cat-visual--photo' : 'cat-visual--fallback',
                ]"
                :style="labelCategoryVisualZoneStyle(cat)"
59e51671   “wangming”   1
51
              >
5a192b24   杨鑫   最新同步
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
                <image
                  v-if="labelCategoryVisual(cat).mode === 'image'"
                  :src="resolveMediaUrlForApp(labelCategoryVisual(cat).imageUrl) || ''"
                  class="cat-photo-fill"
                  mode="aspectFill"
                />
                <view
                  v-else-if="labelCategoryVisual(cat).mode === 'colorText'"
                  class="cat-visual-text-inner"
                >
                  <text
                    class="cat-visual-text cat-visual-text--on-color"
                    :style="{ color: labelCategoryVisual(cat).textColor || '#ffffff' }"
                  >
                    {{ labelCategoryVisual(cat).text }}
                  </text>
                </view>
                <view v-else-if="labelCategoryVisual(cat).mode === 'color'" class="cat-visual-color-fill" />
                <view v-else-if="labelCategoryVisual(cat).mode === 'text'" class="cat-visual-text-inner">
                  <text class="cat-visual-text">{{ labelCategoryVisual(cat).text }}</text>
                </view>
                <view v-else class="cat-visual-fallback" :class="colorClassForName(cat.categoryName)">
                  <text class="cat-visual-text cat-visual-text--on-color">
                    {{ (cat.categoryName || '').trim().slice(0, 12) }}
                  </text>
                </view>
              </view>
              <view class="cat-name-band">
                <text class="cat-name">{{ cat.categoryName }}</text>
              </view>
              </view>
59e51671   “wangming”   1
83
            </view>
59e51671   “wangming”   1
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
          </view>
        </view>
  
        <scroll-view class="main-panel" scroll-y>
          <view class="panel-inner">
            <view v-if="!locationId" class="empty">
              <AppIcon name="mapPin" size="lg" color="gray" />
              <text class="empty-text">Select a store to load labels.</text>
            </view>
  
            <template v-else>
              <view class="search-box">
                <view class="search-icon-wrap">
                  <AppIcon name="search" size="sm" color="gray" />
                </view>
                <input
                  v-model="searchTerm"
                  class="search-input"
                  placeholder="Search products..."
                  placeholder-class="placeholder"
                />
              </view>
  
              <view v-if="listLoading" class="empty">
                <text class="empty-text">Loading…</text>
              </view>
  
              <view v-else-if="listError" class="empty">
                <text class="empty-text">{{ listError }}</text>
              </view>
  
              <view v-else-if="filteredProductCategories.length === 0" class="empty">
                <AppIcon name="search" size="lg" color="gray" />
                <text class="empty-text">No products found</text>
              </view>
  
              <view v-else class="category-list">
                <view
                  v-for="(pCat, pIdx) in filteredProductCategories"
                  :key="productCategoryRowKey(pCat, pIdx)"
                  class="cat-section"
                >
540ac0e3   杨鑫   前端修改bug
126
127
128
129
130
131
                  <view
                    class="cat-header"
                    :style="catHeaderRowStyle"
                    @click="toggleCategory(productCategoryRowKey(pCat, pIdx))"
                  >
                    <view class="cat-header-left" :style="catHeaderLeftStyle">
59e51671   “wangming”   1
132
                      <view
540ac0e3   杨鑫   前端修改bug
133
                        class="cat-header-thumb"
5a192b24   杨鑫   最新同步
134
                        :class="[
59e51671   “wangming”   1
135
                          productCategoryVisual(pCat).mode === 'image'
540ac0e3   杨鑫   前端修改bug
136
                            ? 'cat-header-thumb--photo'
5a192b24   杨鑫   最新同步
137
138
139
                            : 'cat-header-thumb--fallback',
                          'cat-header-thumb--fixed',
                        ]"
540ac0e3   杨鑫   前端修改bug
140
                        :style="catHeaderThumbStyle(pCat)"
59e51671   “wangming”   1
141
142
143
144
145
146
147
                      >
                        <image
                          v-if="productCategoryVisual(pCat).mode === 'image'"
                          :src="resolveMediaUrlForApp(productCategoryVisual(pCat).imageUrl) || ''"
                          class="cat-photo"
                          mode="aspectFill"
                        />
5a192b24   杨鑫   最新同步
148
                        <view
59e51671   “wangming”   1
149
                          v-else-if="productCategoryVisual(pCat).mode === 'colorText'"
5a192b24   杨鑫   最新同步
150
                          class="cat-header-text-inner"
59e51671   “wangming”   1
151
                        >
5a192b24   杨鑫   最新同步
152
153
154
155
156
157
158
                          <text
                            class="cat-icon-text cat-icon-text--on-color cat-icon-text--header cat-icon-text--wrap"
                            :style="{ color: productCategoryVisual(pCat).textColor || '#ffffff' }"
                          >
                            {{ categoryHeaderThumbText(pCat) }}
                          </text>
                        </view>
59e51671   “wangming”   1
159
160
161
162
163
                        <view
                          v-else-if="productCategoryVisual(pCat).mode === 'color'"
                          class="cat-header-color-fill"
                          :style="{ backgroundColor: productCategoryVisual(pCat).bg }"
                        />
5a192b24   杨鑫   最新同步
164
                        <view
59e51671   “wangming”   1
165
                          v-else-if="productCategoryVisual(pCat).mode === 'text'"
5a192b24   杨鑫   最新同步
166
                          class="cat-header-text-inner"
59e51671   “wangming”   1
167
                        >
5a192b24   杨鑫   最新同步
168
169
170
171
                          <text class="cat-icon-text cat-icon-text--header cat-icon-text--wrap">
                            {{ categoryHeaderThumbText(pCat) }}
                          </text>
                        </view>
59e51671   “wangming”   1
172
173
174
175
                        <view v-else class="cat-header-fallback" :class="colorClassForName(pCat.name)">
                          <AppIcon name="food" size="sm" color="white" />
                        </view>
                      </view>
540ac0e3   杨鑫   前端修改bug
176
                      <view class="cat-header-info" :style="catHeaderInfoStyle">
59e51671   “wangming”   1
177
178
179
180
                        <text class="cat-header-name">{{ pCat.name }}</text>
                        <text class="cat-header-count">{{ displayProductCategoryItemCount(pCat) }} items</text>
                      </view>
                    </view>
540ac0e3   杨鑫   前端修改bug
181
182
183
184
185
186
187
188
189
190
191
                    <view class="cat-header-chevron" :style="catHeaderChevronStyle">
                      <AppIcon
                        :name="
                          expandedCategories.indexOf(productCategoryRowKey(pCat, pIdx)) >= 0
                            ? 'chevronUp'
                            : 'chevronDown'
                        "
                        size="sm"
                        color="gray"
                      />
                    </view>
59e51671   “wangming”   1
192
193
194
195
196
                  </view>
  
                  <view
                    v-if="expandedCategories.indexOf(productCategoryRowKey(pCat, pIdx)) >= 0"
                    class="cat-foods"
540ac0e3   杨鑫   前端修改bug
197
                    :style="catFoodsStyle"
59e51671   “wangming”   1
198
199
200
201
202
203
204
205
                  >
                    <view class="food-grid">
                      <view
                        v-for="product in pCat.products"
                        :key="product.productId"
                        class="food-card"
                        @click="handleProductClick(product, pCat.name)"
                      >
5a192b24   杨鑫   最新同步
206
207
                        <view class="food-card-frame">
                          <view class="food-card-inner">
59e51671   “wangming”   1
208
                          <view
5a192b24   杨鑫   最新同步
209
210
211
212
213
214
215
                            class="food-visual"
                            :class="
                              productVisual(product, pCat).mode === 'image'
                                ? 'food-visual--photo'
                                : 'food-visual--fallback'
                            "
                            :style="productVisualZoneStyle(product, pCat)"
59e51671   “wangming”   1
216
                          >
5a192b24   杨鑫   最新同步
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
                            <image
                              v-if="productVisual(product, pCat).mode === 'image'"
                              :src="resolveMediaUrlForApp(productVisual(product, pCat).imageUrl) || ''"
                              class="food-img-fill"
                              mode="aspectFill"
                            />
                            <view
                              v-else-if="productVisual(product, pCat).mode === 'colorText'"
                              class="food-visual-text-wrap"
                            >
                              <text
                                class="food-visual-text food-visual-text--on-color"
                                :style="{ color: productVisual(product, pCat).textColor || '#ffffff' }"
                              >
                                {{ productThumbDisplayText(product, pCat) }}
                              </text>
                            </view>
                            <view
                              v-else-if="productVisual(product, pCat).mode === 'text'"
                              class="food-visual-text-wrap"
                            >
                              <text class="food-visual-text">
                                {{ productThumbDisplayText(product, pCat) }}
                              </text>
                            </view>
                            <view
                              v-else-if="productVisual(product, pCat).mode === 'color'"
                              class="food-visual-color-fill"
                            />
                            <view
                              v-else
                              class="food-visual-fallback"
                              :class="colorClassForName(product.productName)"
                            >
                              <text class="food-visual-text food-visual-text--on-color">
                                {{ productThumbFallbackText(product) }}
                              </text>
                            </view>
59e51671   “wangming”   1
255
                          </view>
5a192b24   杨鑫   最新同步
256
257
258
259
260
261
262
263
264
265
266
                          <view class="food-name-band">
                            <text class="food-name">{{ product.productName }}</text>
                          </view>
                          <view class="food-meta-band">
                            <text class="food-meta-size">{{ primaryLabelSizeText(product) }}</text>
                            <text
                              v-if="effectiveLabelTypeCount(product) > 0"
                              class="food-meta-types"
                            >
                              {{ effectiveLabelTypeCount(product) }} Types
                            </text>
59e51671   “wangming”   1
267
                          </view>
59e51671   “wangming”   1
268
269
                          </view>
                        </view>
59e51671   “wangming”   1
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
                      </view>
                    </view>
                  </view>
                </view>
              </view>
            </template>
          </view>
        </scroll-view>
      </view>
  
      <view v-if="showSubTypeModal" class="modal-mask" @click="showSubTypeModal = false">
        <view class="modal-body" @click.stop>
          <text class="modal-title">Select Label Type</text>
          <text class="modal-desc">{{ selectedProduct ? selectedProduct.productName : '' }}</text>
          <view class="subtype-list">
            <view
              v-for="lt in currentLabelTypes"
              :key="lt.labelTypeId"
              class="subtype-item"
              @click="selectLabelType(lt)"
            >
              <text class="subtype-name">{{ lt.typeName }}</text>
              <AppIcon name="chevronRight" size="sm" color="gray" />
            </view>
          </view>
          <view class="modal-cancel" @click="showSubTypeModal = false">
            <text class="modal-cancel-text">Cancel</text>
          </view>
        </view>
      </view>
  
      <SideMenu v-model="isMenuOpen" />
    </view>
  </template>
  
  <script setup lang="ts">
  import { ref, computed, watch } from 'vue'
  import { onShow } from '@dcloudio/uni-app'
  import AppIcon from '../../components/AppIcon.vue'
  import SideMenu from '../../components/SideMenu.vue'
  import LocationPicker from '../../components/LocationPicker.vue'
  import { getStatusBarHeight } from '../../utils/statusBar'
  import { getCurrentPrinterSummary } from '../../utils/print/manager/printerManager'
  import { getCurrentStoreId } from '../../utils/stores'
  import { fetchUsAppLabelingTree } from '../../services/usAppLabeling'
  import type {
    UsAppLabelCategoryTreeNodeDto,
    UsAppLabelingProductNodeDto,
    UsAppLabelTypeNodeDto,
    UsAppProductCategoryNodeDto,
  } from '../../types/usAppLabeling'
  import { resolveMediaUrlForApp } from '../../utils/resolveMediaUrl'
  import { isUsAppSessionExpiredError } from '../../utils/usAppApiRequest'
fdce24a6   杨鑫   修改bug
323
324
325
326
327
328
329
  import {
    categoryButtonDisplayTextShellStyle,
    categoryButtonDisplayWidthStyle,
    categoryButtonColorOnlyBoxStyle,
    resolveCategoryButtonVisualFromDto,
    type CategoryVisualRender,
  } from '../../utils/categoryButtonAppearance'
59e51671   “wangming”   1
330
331
332
333
334
335
336
337
338
339
340
341
  
  const statusBarHeight = getStatusBarHeight()
  const isMenuOpen = ref(false)
  const locationId = ref(getCurrentStoreId())
  const selectedCategoryId = ref('')
  const searchTerm = ref('')
  const debouncedSearch = ref('')
  const expandedCategories = ref<string[]>([])
  const showSubTypeModal = ref(false)
  const selectedProduct = ref<UsAppLabelingProductNodeDto | null>(null)
  const currentLabelTypes = ref<UsAppLabelTypeNodeDto[]>([])
  
5a192b24   杨鑫   最新同步
342
343
344
345
346
347
348
349
350
351
352
353
  /** 按屏宽比例缩放列表区图标/间距(基线 375px 逻辑宽) */
  const layoutScale = ref(1)
  
  function refreshLayoutScale() {
    const w = Number(uni.getSystemInfoSync().windowWidth || 375)
    layoutScale.value = Math.min(1.12, Math.max(0.88, w / 375))
  }
  
  function scaleRpx(base: number): number {
    return Math.round(base * layoutScale.value)
  }
  
59e51671   “wangming”   1
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
  const labelTree = ref<UsAppLabelCategoryTreeNodeDto[]>([])
  const listLoading = ref(false)
  const listError = ref('')
  
  const btConnected = ref(false)
  const btDeviceName = ref('')
  
  let searchTimer: ReturnType<typeof setTimeout> | null = null
  
  watch(searchTerm, () => {
    if (searchTimer) clearTimeout(searchTimer)
    searchTimer = setTimeout(() => {
      debouncedSearch.value = searchTerm.value.trim()
    }, 350)
  })
  
  onShow(() => {
5a192b24   杨鑫   最新同步
371
    refreshLayoutScale()
59e51671   “wangming”   1
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
    locationId.value = getCurrentStoreId()
    const summary = getCurrentPrinterSummary()
    btConnected.value = summary.type === 'bluetooth' || summary.type === 'builtin'
    btDeviceName.value = summary.displayName || ''
    if (locationId.value) {
      loadTree()
    }
  })
  
  const selectedLabelCategory = computed(() =>
    labelTree.value.find((c) => c.id === selectedCategoryId.value)
  )
  
  const productCategoriesForSidebar = computed<UsAppProductCategoryNodeDto[]>(() => {
    return selectedLabelCategory.value?.productCategories ?? []
  })
  
  const filteredProductCategories = computed(() => {
    const cats = productCategoriesForSidebar.value
    const s = debouncedSearch.value.toLowerCase()
    if (!s) return cats
    return cats
      .map((cat) => ({
        ...cat,
        products: cat.products.filter((p) => {
          const hay = `${p.productName} ${p.productCode} ${p.subtitle || ''} ${cat.name}`.toLowerCase()
          return hay.indexOf(s) >= 0
        }),
      }))
      .filter((cat) => cat.products.length > 0)
  })
  
  watch(labelTree, (tree) => {
    if (!tree.length) {
      selectedCategoryId.value = ''
      return
    }
    if (!selectedCategoryId.value || !tree.some((t) => t.id === selectedCategoryId.value)) {
      selectedCategoryId.value = tree[0].id
    }
  })
  
  watch(selectedCategoryId, () => {
    expandedCategories.value = []
  })
  
  watch([selectedLabelCategory, listLoading], () => {
    const cats = selectedLabelCategory.value?.productCategories ?? []
    if (cats.length && expandedCategories.value.length === 0) {
      expandedCategories.value = [productCategoryRowKey(cats[0], 0)]
    }
  })
  
  async function loadTree() {
    const loc = locationId.value
    if (!loc) {
      labelTree.value = []
      return
    }
    listLoading.value = true
    listError.value = ''
    try {
      const kw = debouncedSearch.value.trim()
      const rows = await fetchUsAppLabelingTree({
        locationId: loc,
        keyword: kw || undefined,
      })
      labelTree.value = rows
    } catch (e: unknown) {
      if (isUsAppSessionExpiredError(e)) return
      listError.value = e instanceof Error ? e.message : 'Failed to load labeling tree.'
      labelTree.value = []
    } finally {
      listLoading.value = false
    }
  }
  
  watch(debouncedSearch, () => {
    if (locationId.value) loadTree()
  })
  
  function labelCategoryVisual(cat: UsAppLabelCategoryTreeNodeDto): CategoryVisualRender {
    return resolveCategoryButtonVisualFromDto({
      buttonStyleJson: (cat as any).buttonStyleJson,
      buttonAppearance: (cat as any).buttonAppearance,
      displayText: (cat as any).displayText,
      buttonBgColor: (cat as any).buttonBgColor,
      buttonImageUrl: (cat as any).buttonImageUrl,
      buttonTextColor: (cat as any).buttonTextColor,
      categoryPhotoUrl: cat.categoryPhotoUrl,
      categoryName: cat.categoryName,
    })
  }
  
5a192b24   杨鑫   最新同步
466
  function labelCategoryVisualZoneStyle(cat: UsAppLabelCategoryTreeNodeDto): Record<string, string> {
59e51671   “wangming”   1
467
    const v = labelCategoryVisual(cat)
5a192b24   杨鑫   最新同步
468
469
    if (v.mode === 'color' || v.mode === 'colorText') {
      return { backgroundColor: v.bg }
fdce24a6   杨鑫   修改bug
470
    }
5a192b24   杨鑫   最新同步
471
472
473
474
475
476
477
478
479
480
    return {}
  }
  
  function productVisualZoneStyle(
    p: UsAppLabelingProductNodeDto,
    pCat?: UsAppProductCategoryNodeDto,
  ): Record<string, string> {
    const v = productVisual(p, pCat)
    if (v.mode === 'color' || v.mode === 'colorText') {
      return { backgroundColor: v.bg }
fdce24a6   杨鑫   修改bug
481
    }
5a192b24   杨鑫   最新同步
482
    return {}
59e51671   “wangming”   1
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
  }
  
  function productCategoryVisual(p: UsAppProductCategoryNodeDto): CategoryVisualRender {
    return resolveCategoryButtonVisualFromDto({
      buttonStyleJson: (p as any).buttonStyleJson,
      buttonAppearance: (p as any).buttonAppearance,
      displayText: p.displayText,
      buttonBgColor: p.buttonBgColor,
      buttonImageUrl: p.buttonImageUrl,
      buttonTextColor: p.buttonTextColor,
      categoryPhotoUrl: p.categoryPhotoUrl,
      name: p.name,
    })
  }
  
540ac0e3   杨鑫   前端修改bug
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
  /** 安卓基座对内联 style 命中最稳;勿与侧栏共用 .cat-icon(64rpx) */
  const catHeaderRowStyle: Record<string, string> = {
    padding: '16rpx 20rpx',
    display: 'flex',
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'space-between',
    boxSizing: 'border-box',
    width: '100%',
  }
  
  const catHeaderLeftStyle: Record<string, string> = {
    display: 'flex',
    flexDirection: 'row',
    alignItems: 'center',
    flex: '1',
    minWidth: '0',
  }
  
5a192b24   杨鑫   最新同步
517
  const catHeaderInfoStyle = computed((): Record<string, string> => ({
540ac0e3   杨鑫   前端修改bug
518
519
    flex: '1',
    minWidth: '0',
5a192b24   杨鑫   最新同步
520
    marginLeft: `${scaleRpx(20)}rpx`,
540ac0e3   杨鑫   前端修改bug
521
    paddingLeft: '0',
5a192b24   杨鑫   最新同步
522
  }))
540ac0e3   杨鑫   前端修改bug
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
  
  const catHeaderChevronStyle: Record<string, string> = {
    flexShrink: '0',
    width: '44rpx',
    height: '44rpx',
    marginLeft: '8rpx',
    display: 'flex',
    alignItems: 'center',
    justifyContent: 'center',
  }
  
  const catFoodsStyle: Record<string, string> = {
    boxSizing: 'border-box',
    paddingTop: '4rpx',
    paddingRight: '20rpx',
    paddingBottom: '16rpx',
    paddingLeft: '20rpx',
  }
  
  function catHeaderThumbStyle(p: UsAppProductCategoryNodeDto): Record<string, string> {
59e51671   “wangming”   1
543
    const v = productCategoryVisual(p)
5a192b24   杨鑫   最新同步
544
545
    const scale = layoutScale.value
    const gap = scaleRpx(18)
fdce24a6   杨鑫   修改bug
546
547
    if (v.mode === 'color') {
      return {
5a192b24   杨鑫   最新同步
548
        marginRight: `${gap}rpx`,
fdce24a6   杨鑫   修改bug
549
550
551
552
553
554
555
556
557
        marginBottom: '0',
        marginTop: '0',
        marginLeft: '0',
        flexShrink: '0',
        display: 'flex',
        alignItems: 'center',
        justifyContent: 'center',
        boxSizing: 'border-box',
        backgroundColor: v.bg,
5a192b24   杨鑫   最新同步
558
        ...categoryButtonColorOnlyBoxStyle(scale),
fdce24a6   杨鑫   修改bug
559
560
      }
    }
540ac0e3   杨鑫   前端修改bug
561
    const style: Record<string, string> = {
5a192b24   杨鑫   最新同步
562
      marginRight: `${gap}rpx`,
540ac0e3   杨鑫   前端修改bug
563
564
565
566
      marginBottom: '0',
      marginTop: '0',
      marginLeft: '0',
      flexShrink: '0',
540ac0e3   杨鑫   前端修改bug
567
568
569
570
571
      display: 'flex',
      alignItems: 'center',
      justifyContent: 'center',
      boxSizing: 'border-box',
      backgroundColor: '#f3f4f6',
5a192b24   杨鑫   最新同步
572
      ...categoryButtonDisplayTextShellStyle(scale),
540ac0e3   杨鑫   前端修改bug
573
    }
fdce24a6   杨鑫   修改bug
574
    if (v.mode === 'image') {
5a192b24   杨鑫   最新同步
575
576
577
      Object.assign(style, categoryButtonDisplayWidthStyle(scale), {
        borderRadius: `${scaleRpx(12)}rpx`,
      })
fdce24a6   杨鑫   修改bug
578
579
    }
    if (v.mode === 'colorText') {
540ac0e3   杨鑫   前端修改bug
580
      style.backgroundColor = v.bg
5a192b24   杨鑫   最新同步
581
582
583
584
      style.alignSelf = 'flex-start'
    }
    if (v.mode === 'text') {
      style.alignSelf = 'flex-start'
540ac0e3   杨鑫   前端修改bug
585
586
    }
    return style
59e51671   “wangming”   1
587
588
  }
  
5a192b24   杨鑫   最新同步
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
  /** 分类标题行图标内文案:Display Text 在框内换行展示 */
  function categoryHeaderThumbText(p: UsAppProductCategoryNodeDto): string {
    const v = productCategoryVisual(p)
    const raw =
      v.mode === 'colorText' || v.mode === 'text'
        ? (v.text || p.name || '').trim()
        : (p.name || '').trim()
    return raw
  }
  
  function productThumbDisplayText(
    p: UsAppLabelingProductNodeDto,
    pCat?: UsAppProductCategoryNodeDto,
  ): string {
    const v = productVisual(p, pCat)
    if (v.mode !== 'text' && v.mode !== 'colorText') return ''
    const t = (v.text ?? '').trim()
    const name = (p.productName ?? '').trim()
    return t || name || '?'
  }
  
59e51671   “wangming”   1
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
  function productCategoryRowKey(p: UsAppProductCategoryNodeDto, index: number): string {
    const id = p.categoryId != null ? String(p.categoryId).trim() : ''
    if (id) return `id:${id}`
    return `name:${p.name}:${index}`
  }
  
  function displayProductCategoryItemCount(p: UsAppProductCategoryNodeDto): number {
    const n = typeof p.itemCount === 'number' ? p.itemCount : NaN
    if (!Number.isNaN(n) && n >= 0) return n
    return p.products?.length ?? 0
  }
  
  const COLOR_CLASSES = ['bg-red', 'bg-blue', 'bg-green', 'bg-orange', 'bg-purple']
  
  function colorClassForName(name: string): string {
    let h = 0
    for (let i = 0; i < name.length; i++) h = (h * 31 + name.charCodeAt(i)) | 0
    return COLOR_CLASSES[Math.abs(h) % COLOR_CLASSES.length]
  }
  
540ac0e3   杨鑫   前端修改bug
630
631
632
633
  function productVisual(
    p: UsAppLabelingProductNodeDto,
    pCat?: UsAppProductCategoryNodeDto,
  ): CategoryVisualRender {
59e51671   “wangming”   1
634
635
636
637
638
639
640
641
642
643
644
645
    const v = resolveCategoryButtonVisualFromDto({
      buttonStyleJson: p.buttonStyleJson,
      buttonAppearance: p.buttonAppearance,
      displayText: p.displayText,
      buttonBgColor: p.buttonBgColor,
      buttonImageUrl: p.buttonImageUrl,
      buttonTextColor: p.buttonTextColor,
      categoryPhotoUrl: p.categoryPhotoUrl,
      categoryName: p.productName,
      name: p.productName,
    })
    if (v.mode !== 'none') return v
540ac0e3   杨鑫   前端修改bug
646
647
648
649
    if (pCat) {
      const fromCat = productCategoryVisual(pCat)
      if (fromCat.mode !== 'none') return fromCat
    }
59e51671   “wangming”   1
650
651
652
653
654
    const legacyImg = (p.productImageUrl ?? '').trim()
    if (legacyImg) return { mode: 'image', imageUrl: legacyImg }
    return { mode: 'none' }
  }
  
59e51671   “wangming”   1
655
656
657
658
659
660
661
662
663
664
665
666
  function productThumbFallbackText(p: UsAppLabelingProductNodeDto): string {
    const name = (p.productName ?? '').trim()
    if (!name) return '?'
    const parts = name.split(/\s+/).filter(Boolean)
    if (parts.length >= 2) {
      return (parts[0].slice(0, 1) + parts[1].slice(0, 1)).toUpperCase()
    }
    return name.slice(0, 4)
  }
  
  /** 无商品图时由标签类型尺寸文案拼接展示(接口无单独预览图字段) */
  function primaryLabelSizeText(p: UsAppLabelingProductNodeDto): string {
540ac0e3   杨鑫   前端修改bug
667
668
    const fromCard = (p.templateLabelSizeText ?? '').trim()
    if (fromCard) return fromCard
59e51671   “wangming”   1
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
    const types = p.labelTypes || []
    if (types.length === 0) return '—'
    const texts = types.map((t) => (t.labelSizeText || '').trim()).filter(Boolean)
    if (texts.length === 0) return '—'
    const first = texts[0]
    if (texts.length === 1) return first
    const allSame = texts.every((x) => x === first)
    return allSame ? first : `${first} …`
  }
  
  function effectiveLabelTypeCount(p: UsAppLabelingProductNodeDto): number {
    const fromArr = p.labelTypes?.length ?? 0
    const fromField = typeof p.labelTypeCount === 'number' ? p.labelTypeCount : 0
    return Math.max(fromArr, fromField)
  }
  
  const toggleCategory = (catId: string) => {
    if (expandedCategories.value.indexOf(catId) >= 0) {
      expandedCategories.value = []
    } else {
      expandedCategories.value = [catId]
    }
  }
  
  const handleProductClick = (product: UsAppLabelingProductNodeDto, _productCategoryName: string) => {
    if (product.labelTypes.length > 1) {
      selectedProduct.value = product
      currentLabelTypes.value = product.labelTypes
      showSubTypeModal.value = true
      return
    }
    if (product.labelTypes.length === 1) {
      goPreview(product, product.labelTypes[0], _productCategoryName)
      return
    }
    uni.showToast({ title: 'No label types for this product.', icon: 'none' })
  }
  
  const selectLabelType = (lt: UsAppLabelTypeNodeDto) => {
    const product = selectedProduct.value
    if (!product) return
    const cat =
      productCategoriesForSidebar.value.find((c) => c.products.some((p) => p.productId === product.productId))
        ?.name || ''
    showSubTypeModal.value = false
    goPreview(product, lt, cat)
  }
  
  function goPreview(
    product: UsAppLabelingProductNodeDto,
    lt: UsAppLabelTypeNodeDto,
    categoryName: string
  ) {
    const cat =
      categoryName ||
      productCategoriesForSidebar.value.find((c) => c.products.some((p) => p.productId === product.productId))
        ?.name ||
      ''
    const q = [
      `labelCode=${encodeURIComponent(lt.labelCode)}`,
      `productId=${encodeURIComponent(product.productId)}`,
      `productName=${encodeURIComponent(product.productName)}`,
      `categoryName=${encodeURIComponent(cat)}`,
      `typeName=${encodeURIComponent(lt.typeName)}`,
      `templateSize=${encodeURIComponent(lt.labelSizeText || '')}`,
      `templateName=${encodeURIComponent(lt.templateCode || '')}`,
    ]
    uni.navigateTo({ url: `/pages/labels/preview?${q.join('&')}` })
  }
  
  const goBack = () => {
    const pages = getCurrentPages()
    if (pages.length > 1) {
      uni.navigateBack()
    } else {
      uni.redirectTo({ url: '/pages/index/index' })
    }
  }
  
  const goBluetoothPage = () => {
    uni.navigateTo({ url: '/pages/labels/bluetooth' })
  }
  </script>
  
  <style scoped>
  .page {
    min-height: 100vh;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
  }
  
  .header-hero {
    background: linear-gradient(135deg, var(--theme-primary), var(--theme-primary-dark));
    padding-left: 32rpx;
    padding-right: 32rpx;
    padding-bottom: 0;
  }
  
  .top-bar {
    height: 96rpx;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  
  .top-left,
  .top-right {
    width: 64rpx;
    height: 64rpx;
    border-radius: 999rpx;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .top-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  
  .app-name {
    font-size: 34rpx;
    font-weight: 600;
    color: #ffffff;
  }
  
  .bt-bar {
    display: flex;
    align-items: center;
    gap: 12rpx;
    padding: 16rpx 20rpx;
    margin-top: 16rpx;
    margin-bottom: 16rpx;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 16rpx;
  }
  
  .bt-left {
    display: flex;
    align-items: center;
    gap: 12rpx;
    flex: 1;
    min-width: 0;
  }
  
  .bt-text {
    font-size: 24rpx;
    color: rgba(255, 255, 255, 0.9);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .bt-status {
    display: flex;
    align-items: center;
    gap: 8rpx;
    padding: 6rpx 16rpx;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 999rpx;
    flex-shrink: 0;
  }
  
  .bt-dot {
    width: 12rpx;
    height: 12rpx;
    border-radius: 50%;
    background: #fbbf24;
  }
  
  .bt-status.connected .bt-dot {
    background: #4ade80;
  }
  
  .bt-label {
    font-size: 22rpx;
    color: rgba(255, 255, 255, 0.85);
  }
  
  .body {
    flex: 1;
    display: flex;
    min-height: 0;
  }
  
  .sidebar {
fdce24a6   杨鑫   修改bug
859
    width: 240rpx;
59e51671   “wangming”   1
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
    background: #ffffff;
    border-right: 1rpx solid #e5e7eb;
    padding: 16rpx 0;
    overflow-y: auto;
  }
  
  .sidebar-loading {
    padding: 24rpx 12rpx;
    text-align: center;
  }
  
  .sidebar-loading-text {
    font-size: 22rpx;
    color: #9ca3af;
  }
  
  .cat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
5a192b24   杨鑫   最新同步
880
    padding: 12rpx 10rpx;
59e51671   “wangming”   1
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
    position: relative;
  }
  
  .cat-item.active {
    background: var(--theme-primary-light);
  }
  
  .active-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6rpx;
    background: var(--theme-primary);
    border-radius: 0 6rpx 6rpx 0;
  }
  
5a192b24   杨鑫   最新同步
898
899
900
901
902
903
904
905
906
907
  /* Label Category:外框 3:2,上 70% 视觉区 + 下 30% 名称 */
  .cat-card-frame {
    width: 100%;
    max-width: 200rpx;
    position: relative;
    height: 0;
    padding-top: 66.6667%;
    border-radius: 12rpx;
    overflow: hidden;
    background: #ffffff;
f64eecbf   杨鑫   前端更新
908
    border: 3rpx solid #2563eb;
5a192b24   杨鑫   最新同步
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
    box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.06);
    box-sizing: border-box;
  }
  
  .cat-card-inner {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
  }
  
  .cat-visual {
    flex: 7 1 0;
    min-height: 0;
    width: 100%;
59e51671   “wangming”   1
927
928
929
    display: flex;
    align-items: center;
    justify-content: center;
fdce24a6   杨鑫   修改bug
930
    overflow: hidden;
5a192b24   杨鑫   最新同步
931
    background: #f3f4f6;
f64eecbf   杨鑫   前端更新
932
    border-bottom: 3rpx solid #2563eb;
5a192b24   杨鑫   最新同步
933
    box-sizing: border-box;
59e51671   “wangming”   1
934
935
  }
  
5a192b24   杨鑫   最新同步
936
937
938
  .cat-visual--photo,
  .cat-visual--fallback {
    position: relative;
59e51671   “wangming”   1
939
940
  }
  
5a192b24   杨鑫   最新同步
941
942
943
944
  .cat-photo-fill {
    width: 100%;
    height: 100%;
    display: block;
f64eecbf   杨鑫   前端更新
945
    object-fit: cover;
59e51671   “wangming”   1
946
947
  }
  
5a192b24   杨鑫   最新同步
948
  .cat-visual-color-fill {
59e51671   “wangming”   1
949
    width: 100%;
5a192b24   杨鑫   最新同步
950
    height: 100%;
59e51671   “wangming”   1
951
952
  }
  
5a192b24   杨鑫   最新同步
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
  .cat-visual-text-inner {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6rpx 8rpx;
    box-sizing: border-box;
    overflow: hidden;
  }
  
  .cat-visual-text {
    width: 100%;
    max-height: 100%;
    font-size: 18rpx;
59e51671   “wangming”   1
968
969
    font-weight: 700;
    color: #111827;
fdce24a6   杨鑫   修改bug
970
    line-height: 1.15;
59e51671   “wangming”   1
971
    text-align: center;
fdce24a6   杨鑫   修改bug
972
973
    white-space: pre-wrap;
    word-break: break-word;
59e51671   “wangming”   1
974
    overflow: hidden;
5a192b24   杨鑫   最新同步
975
976
977
978
979
980
981
982
983
984
985
986
987
  }
  
  .cat-visual-text--on-color {
    color: #ffffff;
  }
  
  .cat-visual-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6rpx;
fdce24a6   杨鑫   修改bug
988
    box-sizing: border-box;
59e51671   “wangming”   1
989
990
  }
  
5a192b24   杨鑫   最新同步
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
  .cat-visual-fallback.bg-red {
    background: #ef4444;
  }
  .cat-visual-fallback.bg-blue {
    background: #3b82f6;
  }
  .cat-visual-fallback.bg-green {
    background: #22c55e;
  }
  .cat-visual-fallback.bg-orange {
    background: #f97316;
  }
  .cat-visual-fallback.bg-purple {
    background: #a855f7;
  }
  
  .cat-name-band {
    flex: 3 1 0;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
fdce24a6   杨鑫   修改bug
1014
    padding: 4rpx 6rpx;
5a192b24   杨鑫   最新同步
1015
    background: #ffffff;
fdce24a6   杨鑫   修改bug
1016
    box-sizing: border-box;
59e51671   “wangming”   1
1017
1018
1019
  }
  
  .cat-name {
5a192b24   杨鑫   最新同步
1020
1021
    font-size: 18rpx;
    color: #374151;
59e51671   “wangming”   1
1022
    text-align: center;
5a192b24   杨鑫   最新同步
1023
    line-height: 1.2;
59e51671   “wangming”   1
1024
    word-break: break-word;
5a192b24   杨鑫   最新同步
1025
1026
1027
1028
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
59e51671   “wangming”   1
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
  }
  
  .cat-item.active .cat-name {
    color: var(--theme-primary);
    font-weight: 600;
  }
  
  .main-panel {
    flex: 1;
    min-width: 0;
    height: 100%;
  }
  
540ac0e3   杨鑫   前端修改bug
1042
1043
1044
1045
1046
1047
1048
  /**
   * 产品列表布局:手写 rpx(UniApp 安卓部分机型不支持 CSS var,var 会导致 padding 整段失效)。
   */
  .page {
    box-sizing: border-box;
  }
  
59e51671   “wangming”   1
1049
  .panel-inner {
540ac0e3   杨鑫   前端修改bug
1050
1051
    padding: 16rpx 20rpx;
    box-sizing: border-box;
59e51671   “wangming”   1
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
  }
  
  .search-box {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 24rpx;
  }
  
  .search-icon-wrap {
    position: absolute;
    left: 20rpx;
    z-index: 1;
  }
  
  .search-input {
    flex: 1;
    height: 72rpx;
    padding-left: 64rpx;
    padding-right: 20rpx;
    background: #f3f4f6;
    border-radius: 16rpx;
    font-size: 26rpx;
  }
  
  .empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 80rpx 24rpx;
  }
  
  .empty-text {
    font-size: 28rpx;
    color: #9ca3af;
    margin-top: 24rpx;
    text-align: center;
  }
  
  .category-list {
    display: flex;
    flex-direction: column;
540ac0e3   杨鑫   前端修改bug
1094
    gap: 12rpx;
59e51671   “wangming”   1
1095
1096
1097
1098
  }
  
  .cat-section {
    background: #fff;
540ac0e3   杨鑫   前端修改bug
1099
    border-radius: 12rpx;
59e51671   “wangming”   1
1100
1101
    box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
    overflow: hidden;
540ac0e3   杨鑫   前端修改bug
1102
    box-sizing: border-box;
59e51671   “wangming”   1
1103
1104
  }
  
540ac0e3   杨鑫   前端修改bug
1105
  /* 产品分类标题行:主样式见 script 内联 catHeaderRowStyle(安卓 scoped 易失效) */
59e51671   “wangming”   1
1106
  .cat-header {
540ac0e3   杨鑫   前端修改bug
1107
1108
    box-sizing: border-box;
    width: 100%;
59e51671   “wangming”   1
1109
1110
  }
  
540ac0e3   杨鑫   前端修改bug
1111
  .cat-header-thumb {
5a192b24   杨鑫   最新同步
1112
    position: relative;
540ac0e3   杨鑫   前端修改bug
1113
    box-sizing: border-box;
59e51671   “wangming”   1
1114
1115
  }
  
5a192b24   杨鑫   最新同步
1116
  .cat-header-thumb--fixed {
540ac0e3   杨鑫   前端修改bug
1117
1118
1119
    overflow: hidden;
  }
  
5a192b24   杨鑫   最新同步
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
  .cat-header-text-inner {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 4rpx 6rpx;
    box-sizing: border-box;
  }
  
540ac0e3   杨鑫   前端修改bug
1131
  .cat-header .cat-header-thumb .cat-icon-text,
5a192b24   杨鑫   最新同步
1132
1133
  .cat-header .cat-header-thumb .cat-icon-text--on-color,
  .cat-header .cat-header-thumb .cat-icon-text--header {
fdce24a6   杨鑫   修改bug
1134
1135
    font-size: 20rpx;
    line-height: 1.15;
5a192b24   杨鑫   最新同步
1136
    padding: 0;
fdce24a6   杨鑫   修改bug
1137
1138
1139
1140
    max-width: 100%;
    white-space: pre-wrap;
    word-break: break-word;
    overflow: hidden;
59e51671   “wangming”   1
1141
1142
  }
  
5a192b24   杨鑫   最新同步
1143
1144
1145
1146
1147
  .cat-header-thumb--photo,
  .cat-header-thumb--fallback {
    overflow: hidden;
  }
  
59e51671   “wangming”   1
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
  .cat-header-color-fill {
    width: 100%;
    height: 100%;
  }
  
  .cat-header-fallback {
    width: 100%;
    height: 100%;
    border-radius: 14rpx;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .cat-header-fallback.bg-red {
    background: #ef4444;
  }
  .cat-header-fallback.bg-blue {
    background: #3b82f6;
  }
  .cat-header-fallback.bg-green {
    background: #22c55e;
  }
  .cat-header-fallback.bg-orange {
    background: #f97316;
  }
  .cat-header-fallback.bg-purple {
    background: #a855f7;
  }
  
  .cat-header-info {
    flex: 1;
    min-width: 0;
540ac0e3   杨鑫   前端修改bug
1181
1182
    margin: 0;
    padding: 0;
59e51671   “wangming”   1
1183
1184
1185
  }
  
  .cat-header-name {
540ac0e3   杨鑫   前端修改bug
1186
    font-size: 26rpx;
59e51671   “wangming”   1
1187
1188
1189
    font-weight: 600;
    color: #111827;
    display: block;
540ac0e3   杨鑫   前端修改bug
1190
    line-height: 1.25;
59e51671   “wangming”   1
1191
1192
1193
  }
  
  .cat-header-count {
540ac0e3   杨鑫   前端修改bug
1194
    font-size: 20rpx;
59e51671   “wangming”   1
1195
1196
    color: #9ca3af;
    display: block;
540ac0e3   杨鑫   前端修改bug
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
    margin-top: 4rpx;
    line-height: 1.2;
  }
  
  .cat-header-chevron {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44rpx;
    height: 44rpx;
    margin-left: 8rpx;
    margin-right: 0;
59e51671   “wangming”   1
1210
1211
1212
  }
  
  .cat-foods {
540ac0e3   杨鑫   前端修改bug
1213
    box-sizing: border-box;
59e51671   “wangming”   1
1214
1215
1216
1217
    border-top: 1rpx solid #f3f4f6;
  }
  
  .food-grid {
540ac0e3   杨鑫   前端修改bug
1218
1219
1220
1221
1222
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-content: flex-start;
    padding-top: 8rpx;
5a192b24   杨鑫   最新同步
1223
1224
    margin-left: -6rpx;
    margin-right: -6rpx;
59e51671   “wangming”   1
1225
1226
  }
  
5a192b24   杨鑫   最新同步
1227
  /* Product:外框 3:2,上 70% 视觉 + 中 20% 名称 + 下 10% 尺寸/类型 */
59e51671   “wangming”   1
1228
  .food-card {
540ac0e3   杨鑫   前端修改bug
1229
    width: 47%;
5a192b24   杨鑫   最新同步
1230
    max-width: 260rpx;
540ac0e3   杨鑫   前端修改bug
1231
1232
    flex: 0 0 auto;
    box-sizing: border-box;
5a192b24   杨鑫   最新同步
1233
1234
    margin: 0 6rpx 14rpx 6rpx;
    min-width: 0;
59e51671   “wangming”   1
1235
1236
  }
  
5a192b24   杨鑫   最新同步
1237
1238
  .food-card:active .food-card-frame {
    opacity: 0.92;
59e51671   “wangming”   1
1239
1240
  }
  
5a192b24   杨鑫   最新同步
1241
  .food-card-frame {
59e51671   “wangming”   1
1242
1243
    width: 100%;
    position: relative;
540ac0e3   杨鑫   前端修改bug
1244
    height: 0;
5a192b24   杨鑫   最新同步
1245
1246
    padding-top: 66.6667%;
    border-radius: 12rpx;
59e51671   “wangming”   1
1247
    overflow: hidden;
5a192b24   杨鑫   最新同步
1248
    background: #ffffff;
f64eecbf   杨鑫   前端更新
1249
    border: 3rpx solid #2563eb;
5a192b24   杨鑫   最新同步
1250
    box-sizing: border-box;
59e51671   “wangming”   1
1251
1252
  }
  
5a192b24   杨鑫   最新同步
1253
  .food-card-inner {
59e51671   “wangming”   1
1254
1255
1256
    position: absolute;
    left: 0;
    top: 0;
5a192b24   杨鑫   最新同步
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
  }
  
  .food-visual {
    flex: 7 1 0;
    min-height: 0;
    width: 100%;
    position: relative;
    overflow: hidden;
    background: #f3f4f6;
f64eecbf   杨鑫   前端更新
1270
    border-bottom: 3rpx solid #2563eb;
5a192b24   杨鑫   最新同步
1271
1272
1273
1274
1275
1276
1277
    box-sizing: border-box;
  }
  
  .food-img-fill {
    width: 100%;
    height: 100%;
    display: block;
f64eecbf   杨鑫   前端更新
1278
    object-fit: cover;
5a192b24   杨鑫   最新同步
1279
1280
1281
  }
  
  .food-visual-color-fill {
59e51671   “wangming”   1
1282
1283
1284
1285
    width: 100%;
    height: 100%;
  }
  
5a192b24   杨鑫   最新同步
1286
  .food-visual-text-wrap {
59e51671   “wangming”   1
1287
1288
1289
1290
1291
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
5a192b24   杨鑫   最新同步
1292
    padding: 8rpx 10rpx;
59e51671   “wangming”   1
1293
    box-sizing: border-box;
5a192b24   杨鑫   最新同步
1294
1295
1296
1297
1298
1299
1300
    overflow: hidden;
  }
  
  .food-visual-text {
    width: 100%;
    max-height: 100%;
    font-size: 20rpx;
59e51671   “wangming”   1
1301
1302
    font-weight: 700;
    color: #111827;
5a192b24   杨鑫   最新同步
1303
    line-height: 1.2;
59e51671   “wangming”   1
1304
    text-align: center;
5a192b24   杨鑫   最新同步
1305
    white-space: pre-wrap;
59e51671   “wangming”   1
1306
    word-break: break-word;
5a192b24   杨鑫   最新同步
1307
    overflow: hidden;
59e51671   “wangming”   1
1308
1309
  }
  
5a192b24   杨鑫   最新同步
1310
  .food-visual-text--on-color {
59e51671   “wangming”   1
1311
1312
1313
    color: #ffffff;
  }
  
5a192b24   杨鑫   最新同步
1314
  .food-visual-fallback {
59e51671   “wangming”   1
1315
1316
1317
1318
1319
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
5a192b24   杨鑫   最新同步
1320
    padding: 8rpx;
59e51671   “wangming”   1
1321
1322
1323
    box-sizing: border-box;
  }
  
5a192b24   杨鑫   最新同步
1324
  .food-visual-fallback.bg-red {
59e51671   “wangming”   1
1325
1326
    background: #ef4444;
  }
5a192b24   杨鑫   最新同步
1327
  .food-visual-fallback.bg-blue {
59e51671   “wangming”   1
1328
1329
    background: #3b82f6;
  }
5a192b24   杨鑫   最新同步
1330
  .food-visual-fallback.bg-green {
59e51671   “wangming”   1
1331
1332
    background: #22c55e;
  }
5a192b24   杨鑫   最新同步
1333
  .food-visual-fallback.bg-orange {
59e51671   “wangming”   1
1334
1335
    background: #f97316;
  }
5a192b24   杨鑫   最新同步
1336
  .food-visual-fallback.bg-purple {
59e51671   “wangming”   1
1337
1338
1339
    background: #a855f7;
  }
  
5a192b24   杨鑫   最新同步
1340
1341
1342
1343
1344
1345
1346
1347
1348
  .food-name-band {
    flex: 2 1 0;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rpx 8rpx;
    background: #ffffff;
f64eecbf   杨鑫   前端更新
1349
    border-bottom: 3rpx solid #2563eb;
5a192b24   杨鑫   最新同步
1350
    box-sizing: border-box;
59e51671   “wangming”   1
1351
1352
1353
  }
  
  .food-name {
5a192b24   杨鑫   最新同步
1354
1355
    width: 100%;
    font-size: 20rpx;
59e51671   “wangming”   1
1356
1357
    font-weight: 600;
    color: #111827;
5a192b24   杨鑫   最新同步
1358
1359
1360
    line-height: 1.2;
    text-align: center;
    word-break: break-word;
59e51671   “wangming”   1
1361
    overflow: hidden;
5a192b24   杨鑫   最新同步
1362
1363
1364
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
59e51671   “wangming”   1
1365
1366
  }
  
5a192b24   杨鑫   最新同步
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
  .food-meta-band {
    flex: 1 1 0;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 4rpx;
    padding: 0 8rpx 4rpx;
    background: #ffffff;
    box-sizing: border-box;
  }
  
  .food-meta-size,
  .food-meta-types {
    flex: 1;
    min-width: 0;
    font-size: 14rpx;
59e51671   “wangming”   1
1386
    color: #6b7280;
5a192b24   杨鑫   最新同步
1387
1388
    font-weight: 500;
    line-height: 1.15;
59e51671   “wangming”   1
1389
1390
1391
1392
1393
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
5a192b24   杨鑫   最新同步
1394
1395
1396
1397
1398
1399
1400
1401
  .food-meta-size {
    text-align: left;
  }
  
  .food-meta-types {
    text-align: right;
  }
  
59e51671   “wangming”   1
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
  .modal-mask {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
  }
  
  .modal-body {
    width: 100%;
    background: #fff;
    border-radius: 32rpx 32rpx 0 0;
    padding: 40rpx 32rpx;
    max-height: 70vh;
    overflow-y: auto;
  }
  
  .modal-title {
    font-size: 36rpx;
    font-weight: 700;
    color: #111827;
    display: block;
    margin-bottom: 8rpx;
  }
  
  .modal-desc {
    font-size: 28rpx;
    color: #6b7280;
    display: block;
    margin-bottom: 32rpx;
  }
  
  .subtype-list {
    display: flex;
    flex-direction: column;
    gap: 16rpx;
    margin-bottom: 24rpx;
  }
  
  .subtype-item {
    display: flex;
    align-items: center;
    gap: 20rpx;
    padding: 28rpx 24rpx;
    background: #f9fafb;
    border-radius: 16rpx;
    border: 2rpx solid #e5e7eb;
  }
  
  .subtype-item:active {
    background: var(--theme-primary-light);
    border-color: var(--theme-primary);
  }
  
  .subtype-name {
    flex: 1;
    min-width: 0;
    font-size: 30rpx;
    font-weight: 600;
    color: #111827;
  }
  
  .modal-cancel {
    width: 100%;
    height: 88rpx;
    background: #f3f4f6;
    border-radius: 16rpx;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .modal-cancel-text {
    font-size: 30rpx;
    font-weight: 500;
    color: #374151;
    line-height: 1;
  }
  
  @media (min-width: 768px) {
540ac0e3   杨鑫   前端修改bug
1487
1488
1489
1490
    .panel-inner {
      padding: 20rpx 24rpx;
    }
  
540ac0e3   杨鑫   前端修改bug
1491
1492
    .food-card {
      width: 31%;
5a192b24   杨鑫   最新同步
1493
1494
      max-width: 300rpx;
      margin: 0 8rpx 16rpx 8rpx;
540ac0e3   杨鑫   前端修改bug
1495
1496
    }
  
5a192b24   杨鑫   最新同步
1497
1498
1499
1500
1501
1502
1503
    .food-name {
      font-size: 22rpx;
    }
  
    .food-meta-size,
    .food-meta-types {
      font-size: 16rpx;
59e51671   “wangming”   1
1504
1505
    }
  
540ac0e3   杨鑫   前端修改bug
1506
1507
    .sidebar {
      width: 260rpx;
59e51671   “wangming”   1
1508
    }
5a192b24   杨鑫   最新同步
1509
1510
1511
1512
  
    .cat-card-frame {
      max-width: 220rpx;
    }
59e51671   “wangming”   1
1513
  }
f64eecbf   杨鑫   前端更新
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
  
  @media (min-width: 768px) and (max-width: 820px) {
    .panel-inner {
      padding: 18rpx 20rpx;
    }
  
    .sidebar {
      width: 250rpx;
    }
  
    .food-grid {
      margin-left: -8rpx;
      margin-right: -8rpx;
    }
  
    .food-card {
      width: 47%;
      max-width: 260rpx;
      margin: 0 8rpx 18rpx 8rpx;
    }
  
    .food-name {
      font-size: 22rpx;
      -webkit-line-clamp: 1;
    }
  
    .food-meta-size,
    .food-meta-types {
      font-size: 16rpx;
    }
  }
59e51671   “wangming”   1
1545
  </style>