feat:调整页数参数

This commit is contained in:
2026-06-26 17:20:30 +08:00
parent c07dd81eaa
commit 3d18abf3aa
3 changed files with 20 additions and 23 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ SHOPRO_DEV_BASE_URL=http://www.qflyqzy.net:48090
# SHOPRO_DEV_BASE_URL=https://www.qflyqzy.net/yg-api # SHOPRO_DEV_BASE_URL=https://www.qflyqzy.net/yg-api
# 伟伟 # 伟伟
# SHOPRO_DEV_BASE_URL=http://192.168.1.10:48090 # SHOPRO_DEV_BASE_URL=http://192.168.1.12:48090
# 测试环境 # 测试环境
# SHOPRO_DEV_BASE_URL=https://yougoutest.api.riananyoumu.com # SHOPRO_DEV_BASE_URL=https://yougoutest.api.riananyoumu.com
+1 -1
View File
@@ -39,7 +39,7 @@
<image class="search-icon-white" src="/static/icon/search.svg" mode="aspectFit" /> <image class="search-icon-white" src="/static/icon/search.svg" mode="aspectFit" />
</view> </view>
</view> </view>
<aistore_earnings_carousel v-if="index === 0" /> <aistore_earnings_carousel v-if="index === 0" :pageSize="30" />
<!-- <view class="m-t-16 m-b-8" v-if="timeRound.length && index === 0"> <!-- <view class="m-t-16 m-b-8" v-if="timeRound.length && index === 0">
<scroll-view scroll-x class="time-scroll"> <scroll-view scroll-x class="time-scroll">
<view class="flex"> <view class="flex">
@@ -58,7 +58,7 @@
}, },
pageSize: { pageSize: {
type: Number, type: Number,
default: 5, default: 30,
}, },
autoplay: { autoplay: {
type: Boolean, type: Boolean,
@@ -74,11 +74,13 @@
}, },
}); });
const MAX_PAGES = 30;
const DISPLAY_SIZE = 5;
const currentPageIndex = ref(0); const currentPageIndex = ref(0);
const total = ref(0); const total = ref(0);
const pagesMap = ref({}); const pagesMap = ref({});
const loadingMap = ref({}); const loadingMap = ref({});
const MAX_PAGES = 30;
const normalizeSize = (val, def) => { const normalizeSize = (val, def) => {
const n = Math.floor(Number(val)); const n = Math.floor(Number(val));
@@ -97,8 +99,10 @@
return Number.isFinite(n) && n >= 0 ? n : 450; return Number.isFinite(n) && n >= 0 ? n : 450;
}); });
const totalPages = computed(() => { const totalPages = computed(() => MAX_PAGES);
return MAX_PAGES;
const swiperPages = computed(() => {
return pages.value;
}); });
const normalizePageNo = (pageNo) => { const normalizePageNo = (pageNo) => {
@@ -111,11 +115,10 @@
}; };
const normalizePageList = (list) => { const normalizePageList = (list) => {
const size = normalizeSize(props.pageSize, 5);
const arr = Array.isArray(list) ? list : []; const arr = Array.isArray(list) ? list : [];
if (arr.length === size) return arr; if (arr.length === DISPLAY_SIZE) return arr;
if (arr.length > size) return arr.slice(0, size); if (arr.length > DISPLAY_SIZE) return arr.slice(0, DISPLAY_SIZE);
return [...arr, ...Array.from({ length: size - arr.length }, () => ({}))]; return [...arr, ...Array.from({ length: DISPLAY_SIZE - arr.length }, () => ({}))];
}; };
const pages = computed(() => { const pages = computed(() => {
@@ -128,16 +131,10 @@
return arr; return arr;
}); });
const swiperPages = computed(() => {
if (!pages.value.length) return [];
if (totalPages.value === 1) return [pages.value[0], pages.value[0]];
return pages.value;
});
const fetchPage = async (pageNo) => { const fetchPage = async (pageNo) => {
const res = await earningsPage({ const res = await earningsPage({
pageNo, pageNo,
pageSize: normalizeSize(props.pageSize, 5), pageSize: normalizeSize(props.pageSize, 30),
}).catch(() => ({ code: -1 })); }).catch(() => ({ code: -1 }));
if (res?.code !== 0) return; if (res?.code !== 0) return;
const data = res?.data || {}; const data = res?.data || {};
@@ -162,11 +159,10 @@
const next = Number(e?.detail?.current); const next = Number(e?.detail?.current);
if (!Number.isFinite(next)) return; if (!Number.isFinite(next)) return;
currentPageIndex.value = next; currentPageIndex.value = next;
const currentPageNo = totalPages.value > 1 ? next + 1 : 1; const currentPageNo = next + 1;
ensurePageLoaded(currentPageNo); ensurePageLoaded(currentPageNo, true);
if (totalPages.value > 1) {
ensurePageLoaded(currentPageNo + 1); ensurePageLoaded(currentPageNo + 1);
} ensurePageLoaded(currentPageNo + 2);
}; };
const clampProgress = (val) => { const clampProgress = (val) => {
@@ -201,7 +197,8 @@
total.value = 0; total.value = 0;
pagesMap.value = {}; pagesMap.value = {};
loadingMap.value = {}; loadingMap.value = {};
await ensurePageLoaded(1); await ensurePageLoaded(1, true);
ensurePageLoaded(2);
}; };
watch( watch(