index.uvue
24.2 KB
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
43
44
45
46
47
48
49
50
51
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
83
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
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
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
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
859
860
861
862
863
864
<template>
<layout-root :page-vars="pageVars">
<view class="page-container">
<!-- 标题 -->
<view class="header">
<text class="title">选择门店</text>
</view>
<!-- 错误提示 -->
<view v-if="errorVisible" class="error-tip">
{{ errorMessage }}
</view>
<!-- 门店列表 -->
<!-- ✅ 性能优化:使用 list-view + CSS 控制多列布局 -->
<list-view
class="store-scroll"
:show-scrollbar="false">
<list-item>
<!-- ✅ 使用 flex-wrap 实现自动换行多列布局 -->
<view class="grid-container" :style="columnCssVars">
<view v-for="(item, index) in stores"
:key="getStoreCodeField(item)"
class="grid-item">
<view class="store-card-v2"
:class="[
selectedStoreCode == getStoreCodeField(item) ? 'active' : '',
]"
:style="getCardStyle(item)"
@touchstart="handleTouchStart(index)"
@touchend="handleTouchEnd"
@click="onSelect(item)">
<!-- ✅ 性能优化:移除未使用的 DOM 节点 -->
<!-- <view class="card-gradient-bg"></view> -->
<!-- 左侧强调条 -->
<view class="card-accent-line"></view>
<!-- 内容区域 -->
<view class="card-body">
<!-- 门店名称 -->
<text class="card-title">{{ getStoreNameField(item) }}</text>
<!-- 门店信息行 -->
<view class="card-meta">
<view class="meta-icon-wrapper">
<text class="meta-icon">#</text>
</view>
<text class="meta-text">{{ getStoreCodeField(item) }}</text>
</view>
</view>
<!-- 右侧选择指示器 -->
<view class="card-indicator">
<view class="indicator-circle"></view>
</view>
</view>
</view>
</view>
</list-item>
</list-view>
<!-- 骨架屏或空状态 - 放在 list-view 外面 -->
<view v-if="isLoading || stores.length == 0" class="skeleton-overlay">
<SkeletonCard :count="skeletonSlotCount" :parent-css-vars="columnCssVars" />
</view>
</view>
</layout-root>
</template>
<script setup lang="uts">
import { ref, computed } from "vue";
import { apiShukeConfirmStore, apiShukeSaveLogin } from "@/api/user-api.uts";
import { storage } from "@/utils/storage.uts";
import { hideNativeTabBar } from "@/utils/tabBarShell.uts";
import { EMPTY_OBJECT, toStr, toObj, isEmptyStr, isNotEmptyStr, toBool, type AnyOrNull, type ObjOrNull, type StrOrNull, type AnyArrOrNull } from "@/utils/common.uts";
import pageVars from "@/pages/common/login/styles/index.vars";
import SkeletonCard from "./SkeletonCard.uvue";
import { useColumnLayout } from "@/services/adapter/hooks";
// ✅ 性能优化:预计算门店的 code 和 name,避免模板中重复调用函数
type StoreItem = {
_code: string;
_name: string;
}
const stores = ref<any[]>([]);
const selectedStoreCode = ref<string>("");
const errorVisible = ref<boolean>(false);
const errorMessage = ref<string>("");
const pressedIndex = ref<number>(-1);
const isLoading = ref<boolean>(true); // 添加加载状态
/** ✅ 性能优化:使用动态列数 Hook(禁用自动更新,避免横竖屏 ANR) */
const { columnCount, cssVars: columnCssVars } = useColumnLayout(false);
/** ✅ 性能优化:根据屏幕高度和列数动态计算骨架屏数量(填满一屏) */
/** 注意:仅在 isLoading 时为 true 时计算,避免横竖屏切换时重复计算 */
const skeletonSlotCount = computed(() => {
// ✅ 如果已经加载完成,返回 0,避免不必要的计算
if (!isLoading.value) {
return 0;
}
// ✅ 性能优化:缓存窗口信息,避免重复调用
const info = uni.getWindowInfo();
const windowHeight = info.windowHeight; // 窗口高度
const headerHeight = 60; // 标题栏高度估算
const availableHeight = windowHeight - headerHeight; // 可用高度
// 每个卡片的高度约 90px + 间距 12px = 102px
const cardHeight = 102;
const rows = Math.floor(availableHeight / cardHeight); // 可显示的行数
// 最少显示 4 个,最多填满一屏
const count = columnCount.value * Math.max(rows, 2);
return count;
});
function handleTouchStart(index: number): void {
pressedIndex.value = index;
}
function handleTouchEnd(): void {
pressedIndex.value = -1;
}
function getStoreCode(item: AnyOrNull): string {
if (item == null) {
return "";
}
const o = toObj(item);
const c1 = toStr(o["storeCode"]);
if (isNotEmptyStr(c1)) {
return c1;
}
const c2 = toStr(o["spCode"]);
return c2 != null ? c2 : "";
}
function getStoreName(item: AnyOrNull): string {
if (item == null) {
return "";
}
const o = toObj(item);
return toStr(o["storeName"]);
}
/** ✅ 辅助函数:获取门店的 _code */
function getStoreCodeField(item: AnyOrNull): string {
if (item == null) {
return "";
}
const o = toObj(item);
return toStr(o["_code"]);
}
/** ✅ 辅助函数:获取门店的 _name */
function getStoreNameField(item: AnyOrNull): string {
if (item == null) {
return "";
}
const o = toObj(item);
return toStr(o["_name"]);
}
/** ✅ 获取单个卡片的 CSS 变量(根据是否选中返回不同值) */
function getCardStyle(item: AnyOrNull): UTSJSONObject {
const code = getStoreCodeField(item);
const isSelected = selectedStoreCode.value == code;
// ✅ 极致性能优化:只使用 opacity 控制,避免任何重绘
return toObj({
"--card-opacity": isSelected ? "1" : "0.85", // 整体透明度(提高未选中亮度)
"--accent-opacity": isSelected ? "1" : "0", // 左侧强调条(无过渡,立即显示)
"--indicator-opacity": isSelected ? "1" : "0.3" // 指示器透明度
});
}
const showError = (msg: string): void => {
errorMessage.value = isEmptyStr(msg) ? "操作失败" : msg;
errorVisible.value = true;
};
/** 与 `loginForm` 同结构;选店成功后 `loginForm` 会删,切换门店仍要靠 confirm 接口,故保留一份(退出/切换账号时清) */
const SHUKE_LAST_CONFIRM_FORM_KEY = "shukeLastConfirmForm";
function hasValidLoginCredentials(form: UTSJSONObject): boolean {
const u = toStr(form["username"]);
const p = toStr(form["password"]);
const sp = toStr(form["spCode"]);
return isNotEmptyStr(u) && isNotEmptyStr(p) && isNotEmptyStr(sp);
}
/** ✅ 性能优化:缓存 loginForm,避免重复读取 Storage */
let cachedLoginForm: ObjOrNull = null;
let cachedLoginFormTime: number = 0;
const LOGIN_FORM_CACHE_TTL = 5000; // 5秒缓存
function readLoginFormForSelectStore(): UTSJSONObject {
const now = Date.now();
// 如果缓存有效,直接返回
const cached = cachedLoginForm;
if (cached != null && (now - cachedLoginFormTime) < LOGIN_FORM_CACHE_TTL) {
return cached;
}
const primary = storage.parse("loginForm");
if (hasValidLoginCredentials(primary)) {
cachedLoginForm = primary;
cachedLoginFormTime = now;
return primary;
}
const fallback = storage.parse(SHUKE_LAST_CONFIRM_FORM_KEY);
cachedLoginForm = fallback;
cachedLoginFormTime = now;
return fallback;
}
/** ✅ 性能优化:同步处理门店数据(用于小数据量) */
function normalizeStoreList(list: any[]): any[] {
const result: any[] = [];
for (let i = 0; i < list.length; i++) {
const item = list[i];
const o = toObj(item);
// 提取 code
let code = "";
const c1 = toStr(o["storeCode"]);
if (c1 != null && c1 !== "") {
code = c1;
} else {
const c2 = toStr(o["spCode"]);
code = c2 != null ? c2 : "";
}
// 提取 name
const name = toStr(o["storeName"]);
// 直接在原对象上添加预计算字段(避免创建新对象)
o["_code"] = code;
o["_name"] = name;
result.push(item);
}
return result;
}
/** ✅ 性能优化:异步分批处理门店数据(动态递增 batchSize,平衡首屏速度和总时间) */
function normalizeStoreListAsync(list: any[]): Promise<any[]> {
return new Promise((resolve) => {
const result: any[] = [];
let currentIndex = 0;
let batchIndex = 0;
// 动态递增的 batchSize 策略:5 → 20 → 40 → 60 → 60...
// 避免单批次过大导致 ANR,同时保持渐进式加速
const getBatchSize = (index: number): number => {
if (index == 0) return 5; // 第一批:快速显示,让用户看到内容
if (index == 1) return 20; // 第二批:适度加速
if (index == 2) return 40; // 第三批:继续加速
return 60; // 后续批次:稳定速度,避免 ANR
};
function processBatch(): void {
const batchSize = getBatchSize(batchIndex);
const endIndex = Math.min(currentIndex + batchSize, list.length);
for (let i = currentIndex; i < endIndex; i++) {
const item = list[i];
const o = toObj(item);
// 提取 code
let code = "";
const c1 = toStr(o["storeCode"]);
if (c1 != null && c1 !== "") {
code = c1;
} else {
const c2 = toStr(o["spCode"]);
code = c2 != null ? c2 : "";
}
// 提取 name
const n = toStr(o["storeName"]);
const name = n != null ? n : "";
// 直接在原对象上添加预计算字段
o["_code"] = code;
o["_name"] = name;
result.push(item);
}
currentIndex = endIndex;
batchIndex++;
if (currentIndex < list.length) {
// ✅ 使用 nextTick 让出控制权,避免低端机 ANR
void nextTick(() => {
processBatch();
});
} else {
// 全部处理完成
resolve(result);
}
}
// 开始处理
processBatch();
});
}
/** ✅ 性能优化:异步批量存储,避免阻塞主线程 */
function asyncStorageSet(key: string, value: any): void {
storage.setAsync(key, value, 0);
}
/** pendingShukeStores 同样可能被序列化为字符串 */
function readStoreListFromStorage(key: string): any[] {
const raw = storage.get(key);
if (raw == null) {
return [];
}
// 如果是 JSON 字符串,尝试解析
if (typeof raw === "string") {
try {
const parsed = JSON.parse(raw);
if (Array.isArray(parsed)) {
return parsed as any[];
}
} catch (e) {
console.error(`[readStoreListFromStorage] JSON 解析失败:`, e);
}
return [];
}
// 如果已经是数组,直接返回
if (Array.isArray(raw)) {
return raw as any[];
}
return [];
}
/** ✅ 性能优化:提取商户 ID(支持多字段回退) */
function extractMerchantId(obj: ObjOrNull, fallback: string = ""): string {
if (obj == null) return fallback;
const fields = ["shopMerchantId", "merchantId"];
for (let i = 0; i < fields.length; i++) {
const val = obj[fields[i]] as string | number | null;
if (val != null) {
const str = `${val}`;
if (str !== "") return str;
}
}
return fallback;
}
/** ✅ 性能优化:提取商户名称(支持多字段回退) */
function extractMerchantName(obj: ObjOrNull, fallback: string = ""): string {
if (obj == null) return fallback;
const fields = ["shopMerchantName", "merchantName"];
for (let i = 0; i < fields.length; i++) {
const val = toStr(obj[fields[i]]);
if (isNotEmptyStr(val)) return val;
}
return fallback;
}
/** ✅ 性能优化:补全商户信息(避免重复逻辑) */
function enrichProfile(profile: UTSJSONObject, userObj: ObjOrNull, storeObj: ObjOrNull, storeCode: string, storeName: string): void {
// 补全 shopMerchantId
let merchantId = extractMerchantId(profile);
if (merchantId === "") {
merchantId = userObj != null ? extractMerchantId(userObj) : "";
}
if (merchantId === "") {
merchantId = storeObj != null ? extractMerchantId(storeObj) : "";
}
if (merchantId === "" && storeCode !== "") {
merchantId = storeCode;
}
profile["shopMerchantId"] = merchantId;
// 补全 shopMerchantName
let merchantName = extractMerchantName(profile);
if (merchantName === "") {
merchantName = userObj != null ? extractMerchantName(userObj) : "";
}
if (merchantName === "") {
merchantName = storeName !== "" ? storeName : "门店";
}
profile["shopMerchantName"] = merchantName;
}
/** 与 simgle_app `confirmLoginStore` 一致:请求体必须含 loginForm 内 username、password(加密)、spCode */
const confirmOne = async (store: AnyOrNull): Promise<void> => {
const loginFormRaw = readLoginFormForSelectStore();
if (hasValidLoginCredentials(loginFormRaw) != true) {
showError("登录信息已失效,请重新登录");
return;
}
const username = toStr(loginFormRaw["username"]);
const password = toStr(loginFormRaw["password"]);
const spCode = toStr(loginFormRaw["spCode"]);
const noSignIn = toBool(loginFormRaw["noSignIn"]);
const storeCode = getStoreCode(store);
if (isEmptyStr(username) || isEmptyStr(password) || isEmptyStr(spCode) || storeCode === "") {
showError("参数异常");
return;
}
// ✅ 性能优化:立即显示 loading,不使用 setTimeout
uni.showLoading({ title: "加载中", mask: true });
try {
const res = await apiShukeConfirmStore({
username,
password,
spCode,
storeCode
} as UTSJSONObject);
const resCode = toStr(res["code"]);
if (`${resCode}` === "500") {
let msg = toStr(res["msg"]);
if (isEmptyStr(msg)) {
msg = toStr(res["message"]);
}
if (isEmptyStr(msg)) {
msg = "确认门店失败";
}
showError(msg);
return;
}
const data = toObj(res["data"]);
if (data == null) {
showError("确认门店失败");
return;
}
let token = toStr(data["token"]);
if (isEmptyStr(token)) {
token = toStr(data["sessionId"]);
}
if (isEmptyStr(token)) {
token = toStr(data["access_token"]);
}
if (isEmptyStr(token)) {
showError("登录失败:未获取到 token");
return;
}
// ✅ 性能优化:异步存储,避免阻塞
asyncStorageSet("sessionId", token);
const loginUser = toObj(data["loginUser"]);
const userObj = toObj(data["user"]);
if (loginUser == null && userObj == null) {
showError("确认门店失败:未返回用户信息");
return;
}
const profile = loginUser != null ? loginUser : userObj;
const storeObj = toObj(store);
const storeName = getStoreName(store);
// ✅ 性能优化:使用统一函数补全商户信息
enrichProfile(profile, userObj, storeObj, storeCode, storeName);
// ✅ 性能优化:关键数据异步存储,避免阻塞(移除重复的 sessionId)
asyncStorageSet("userInfo", profile);
asyncStorageSet(
"storeInfo",
toObj({
storeCode,
storeName
})
);
if (noSignIn == true) {
asyncStorageSet("noSignInUuid", username);
// ✅ 性能优化:不等待 saveLogin 完成,直接继续
apiShukeSaveLogin(EMPTY_OBJECT).catch((e) => {
console.log("saveLoginInfo", e);
});
}
if (isNotEmptyStr(spCode)) {
asyncStorageSet("shukeSpCode", spCode);
}
/** 供再次进入选店页调 confirm(与 simgle 侧栏「切换」一致:不依赖未持久化的 loginForm) */
asyncStorageSet(
SHUKE_LAST_CONFIRM_FORM_KEY,
toObj({
username,
password,
spCode,
noSignIn: noSignIn == true
})
);
// ✅ 性能优化:异步删除,避免阻塞主线程
storage.removeAsync("loginForm");
storage.removeAsync("pendingShukeStores");
// ✅ 性能优化:先隐藏 loading,再跳转
uni.hideLoading();
// ✅ 立即跳转,不使用 setTimeout
uni.switchTab({ url: "/pages/index/index" });
} catch (e) {
showError(`${e}`);
} finally {
uni.hideLoading();
}
};
const onSelect = (item: AnyOrNull): void => {
if (item == null) {
showError("门店数据异常");
return;
}
const code = getStoreCode(item);
if (code === "") {
showError("门店编码为空");
return;
}
selectedStoreCode.value = code;
// confirmOne 内部会立即显示 loading
confirmOne(item);
};
function parseStoresFromOptions(options: ObjOrNull): AnyArrOrNull {
if (options == null) {
return null;
}
const rawStores = options["stores"] as StrOrNull;
if (isEmptyStr(rawStores)) {
return null;
}
try {
// ✅ 确保非空后再调用 decodeURIComponent
const decodedRaw = decodeURIComponent(rawStores ?? "");
const decoded = decodedRaw != null ? `${decodedRaw}` : "";
if (decoded === "") {
return null;
}
const parsed = JSON.parse(decoded) as any[] | null;
if (parsed != null && Array.isArray(parsed) && parsed.length > 0) {
return parsed;
}
} catch (_e) {
}
return null;
}
/** ✅ 性能优化:异步加载门店数据(使用 nextTick 分批处理,避免 ANR) */
async function loadStoresData(options: ObjOrNull): Promise<void> {
const fromUrl = parseStoresFromOptions(options);
if (fromUrl != null) {
console.log('[selectStore] 从 URL 参数获取门店数据:', fromUrl.length);
// ✅ 使用 nextTick 异步分批处理
const normalized = await normalizeStoreListAsync(fromUrl);
stores.value = normalized;
asyncStorageSet("pendingShukeStores", fromUrl);
} else {
const arr = readStoreListFromStorage("pendingShukeStores");
if (arr.length > 0) {
// ✅ 使用 nextTick 异步分批处理
const normalized = await normalizeStoreListAsync(arr);
stores.value = normalized;
}
}
// ✅ 关键优化:数据设置后,等待多个 nextTick 让 DOM 完全渲染
await nextTick();
isLoading.value = false; // 加载完成
if (stores.value.length == 0) {
showError("暂无门店");
return;
}
/** 与 simgle_app 一致:多店进页不拦;仅「单店自动 confirm」必须有凭据 */
if (stores.value.length == 1) {
const cred = readLoginFormForSelectStore();
if (hasValidLoginCredentials(cred) != true) {
showError("缺少登录凭据,请重新登录后再选店");
return;
}
const only = stores.value[0];
selectedStoreCode.value = getStoreCodeField(only);
// ✅ 立即执行 confirm
confirmOne(only);
return;
}
}
function applyStoresList(list: any[] | null): void {
if (list == null || list.length == 0) {
return;
}
// ✅ 性能优化:预处理门店数据
stores.value = normalizeStoreList(list);
// ✅ 性能优化:异步存储,避免阻塞
asyncStorageSet("pendingShukeStores", list);
}
onLoad((options: ObjOrNull): void => {
// ✅ 性能优化:使用 nextTick 确保骨架屏先渲染,再加载数据
isLoading.value = true;
stores.value = []; // 确保初始为空
// ✅ 使用 nextTick 替代 setTimeout,避免低端机 ANR
void nextTick(() => {
loadStoresData(options);
});
});
onShow((): void => {
hideNativeTabBar();
// 不在 onShow 中加载数据,避免与 onLoad 冲突
// 数据统一在 onLoad 中处理
});
</script>
<style scoped lang="scss">
/* ✅ 优化:合并 select-store-page-root 和 select-store-page */
.page-container {
width: 100%;
height: 100%;
min-height: 0;
display: flex;
flex-direction: column;
padding: 24px 20px;
box-sizing: border-box;
position: relative; /* 为骨架屏覆盖层提供定位上下文 */
}
.header {
margin-bottom: 24px;
display: flex;
align-items: center;
justify-content: center;
}
.title {
font-size: 20px;
font-weight: 700;
color: #1e293b;
letter-spacing: 0.5px;
text-align: center;
}
.error-tip {
padding: 16px 20px;
margin-bottom: 20px;
background-color: var(--bg-error, #FEF2F2);
border-radius: 12px;
border-left: 4px solid #EF4444;
box-shadow: 0 2px 8px rgba(239, 68, 68, 0.08);
box-sizing: border-box;
font-size: 14px;
color: #b91c1c;
letter-spacing: 0.2px;
}
.store-scroll {
flex: 1;
height: 0;
width: 100%;
box-sizing: border-box;
}
/* 骨架屏覆盖层 */
.skeleton-overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
flex-direction: column;
padding: 24px 20px;
box-sizing: border-box;
z-index: 10;
background-color: #F8FAFC;
}
/* ✅ list-view 自动处理布局 */
// ✅ UVUE 不支持 animation,低端机性能优化
// .fade-in-up { }
/* 网格容器 - 使用 flex-wrap 实现多列布局 */
.grid-container {
display: flex;
flex-direction: row;
flex-wrap: wrap; // ✅ 自动换行
width: 100%;
padding: 6px 0; // 上下间距
box-sizing: border-box;
// ✅ UVUE 不支持 gap,使用负 margin + 正 padding 替代
margin-left: var(--grid-row-margin-left, 0px);
margin-right: var(--grid-row-margin-right, 0px);
}
/* 网格项 - 使用 CSS 变量控制宽度 */
.grid-item {
// ✅ 使用 CSS 变量控制宽度(由 Hook 动态设置)
width: var(--column-width, 100%);
flex-shrink: 0; // 不允许收缩,保持固定宽度
box-sizing: border-box;
// ✅ 左右间距(与负 margin 配合)
padding-left: var(--grid-cell-padding-left, 0px);
padding-right: var(--grid-cell-padding-right, 0px);
// ✅ 底部间距
padding-bottom: 12px;
}
/* 门店卡片 v2 - 现代设计风格 */
.store-card-v2 {
width: 100%;
min-height: 90px;
background-color: #FFFFFF;
border-radius: 16px;
padding: 16px;
display: flex;
flex-direction: column;
justify-content: space-between;
box-sizing: border-box;
border: 1.5px solid #F1F5F9;
// ✅ 性能优化:移除 box-shadow,减少渲染压力
position: relative;
overflow: hidden;
// ✅ 低端机优化:默认启用 pointer-events
pointer-events: auto;
// ✅ 性能优化:移除渐变背景,减少渲染压力
// .card-gradient-bg { }
// ✅ 性能优化:使用 opacity 控制高亮,减少重绘开销
opacity: var(--card-opacity, 1); // 默认完全不透明
// ❌ 移除 transition,避免延迟感,立即响应
// 左侧强调条
.card-accent-line {
position: absolute;
left: 0;
top: 20%;
bottom: 20%;
width: 3px;
background-color: #6366F1; // ✅ 固定紫色
border-radius: 0 2px 2px 0;
opacity: var(--accent-opacity, 0); // ✅ 通过变量控制
// ❌ 移除 transition,立即显示/隐藏
z-index: 1;
}
// ✅ 选中状态 - 父元素有 .active 时控制子元素
&.active {
transform: scale(0.98);
background-color: #F8FAFC;
border-color: #6366F1;
.card-accent-line {
opacity: 1;
}
.card-title {
color: #4F46E5;
font-weight: 700;
}
.meta-icon-wrapper {
background-color: #EEF2FF;
}
.meta-text {
color: #4F46E5;
font-weight: 600;
}
.indicator-circle {
border-color: #6366F1;
background-color: #6366F1;
}
}
// 内容区域
.card-body {
position: relative;
z-index: 2;
display: flex;
flex-direction: column;
justify-content: center;
flex: 1;
min-width: 0;
.card-title {
font-size: 15px;
font-weight: 600; // ✅ 固定字重,避免重绘
color: #1E293B; // ✅ 固定颜色
line-height: 1.4;
letter-spacing: 0.3px;
margin-bottom: 10px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.card-meta {
display: flex;
flex-direction: row;
align-items: center;
.meta-icon-wrapper {
width: 20px;
height: 20px;
border-radius: 6px;
background-color: #F1F5F9; // ✅ 固定背景
display: flex;
align-items: center;
justify-content: center;
margin-right: 8px;
flex-shrink: 0;
.meta-icon {
font-size: 11px;
font-weight: 700;
color: #64748B;
line-height: 1;
}
}
.meta-text {
font-size: 12px;
font-weight: 500;
color: #64748B; // ✅ 固定颜色
letter-spacing: 0.5px;
font-family: 'Courier New', monospace;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
flex: 1;
min-width: 0;
}
}
}
// 右侧选择指示器
.card-indicator {
position: absolute;
right: 12px;
top: 12px;
z-index: 2;
.indicator-circle {
width: 18px;
height: 18px;
border-radius: 50%;
border: 2px solid #6366F1; // ✅ 固定紫色边框
background-color: #6366F1; // ✅ 固定紫色背景
opacity: var(--indicator-opacity, 0.3); // ✅ 通过 opacity 控制高亮(GPU 合成)
// ❌ 移除 transition,立即响应
}
}
}
</style>