feat: banner跳转ai店铺判断
This commit is contained in:
@@ -40,9 +40,14 @@
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
defaultTabName: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
});
|
||||
const hasPurchasedShop = ref(null);
|
||||
const displayList = ref([]);
|
||||
const hasAppliedDefaultTab = ref(false);
|
||||
|
||||
const computeDisplayList = () => {
|
||||
const list = Array.isArray(props.list) ? props.list : [];
|
||||
@@ -67,10 +72,24 @@
|
||||
onReachBottom,
|
||||
);
|
||||
|
||||
const applyDefaultTabIfNeeded = (list) => {
|
||||
const target = String(props.defaultTabName || '').trim();
|
||||
if (!target) return;
|
||||
if (hasAppliedDefaultTab.value) return;
|
||||
const index = (Array.isArray(list) ? list : []).findIndex(
|
||||
(v) => String(v?.name || '').trim() === target,
|
||||
);
|
||||
if (index >= 0) {
|
||||
tabIndex.value = index;
|
||||
hasAppliedDefaultTab.value = true;
|
||||
}
|
||||
};
|
||||
|
||||
const refreshDisplay = () => {
|
||||
const next = computeDisplayList();
|
||||
displayList.value = next;
|
||||
syncMescrollItems(next);
|
||||
applyDefaultTabIfNeeded(next);
|
||||
if (tabIndex.value >= next.length) tabIndex.value = 0;
|
||||
};
|
||||
|
||||
@@ -96,6 +115,15 @@
|
||||
},
|
||||
{ immediate: true, deep: true },
|
||||
);
|
||||
|
||||
watch(
|
||||
() => props.defaultTabName,
|
||||
() => {
|
||||
hasAppliedDefaultTab.value = false;
|
||||
applyDefaultTabIfNeeded(displayList.value);
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
// let tabIndex = ref(0);
|
||||
const navChange = (i) => {
|
||||
// scrollToLastY()
|
||||
|
||||
Reference in New Issue
Block a user