feat:调整页数参数
This commit is contained in:
@@ -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=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
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
<image class="search-icon-white" src="/static/icon/search.svg" mode="aspectFit" />
|
||||
</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">
|
||||
<scroll-view scroll-x class="time-scroll">
|
||||
<view class="flex">
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
},
|
||||
pageSize: {
|
||||
type: Number,
|
||||
default: 5,
|
||||
default: 30,
|
||||
},
|
||||
autoplay: {
|
||||
type: Boolean,
|
||||
@@ -74,11 +74,13 @@
|
||||
},
|
||||
});
|
||||
|
||||
const MAX_PAGES = 30;
|
||||
const DISPLAY_SIZE = 5;
|
||||
|
||||
const currentPageIndex = ref(0);
|
||||
const total = ref(0);
|
||||
const pagesMap = ref({});
|
||||
const loadingMap = ref({});
|
||||
const MAX_PAGES = 30;
|
||||
|
||||
const normalizeSize = (val, def) => {
|
||||
const n = Math.floor(Number(val));
|
||||
@@ -97,8 +99,10 @@
|
||||
return Number.isFinite(n) && n >= 0 ? n : 450;
|
||||
});
|
||||
|
||||
const totalPages = computed(() => {
|
||||
return MAX_PAGES;
|
||||
const totalPages = computed(() => MAX_PAGES);
|
||||
|
||||
const swiperPages = computed(() => {
|
||||
return pages.value;
|
||||
});
|
||||
|
||||
const normalizePageNo = (pageNo) => {
|
||||
@@ -111,11 +115,10 @@
|
||||
};
|
||||
|
||||
const normalizePageList = (list) => {
|
||||
const size = normalizeSize(props.pageSize, 5);
|
||||
const arr = Array.isArray(list) ? list : [];
|
||||
if (arr.length === size) return arr;
|
||||
if (arr.length > size) return arr.slice(0, size);
|
||||
return [...arr, ...Array.from({ length: size - arr.length }, () => ({}))];
|
||||
if (arr.length === DISPLAY_SIZE) return arr;
|
||||
if (arr.length > DISPLAY_SIZE) return arr.slice(0, DISPLAY_SIZE);
|
||||
return [...arr, ...Array.from({ length: DISPLAY_SIZE - arr.length }, () => ({}))];
|
||||
};
|
||||
|
||||
const pages = computed(() => {
|
||||
@@ -128,16 +131,10 @@
|
||||
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 res = await earningsPage({
|
||||
pageNo,
|
||||
pageSize: normalizeSize(props.pageSize, 5),
|
||||
pageSize: normalizeSize(props.pageSize, 30),
|
||||
}).catch(() => ({ code: -1 }));
|
||||
if (res?.code !== 0) return;
|
||||
const data = res?.data || {};
|
||||
@@ -162,11 +159,10 @@
|
||||
const next = Number(e?.detail?.current);
|
||||
if (!Number.isFinite(next)) return;
|
||||
currentPageIndex.value = next;
|
||||
const currentPageNo = totalPages.value > 1 ? next + 1 : 1;
|
||||
ensurePageLoaded(currentPageNo);
|
||||
if (totalPages.value > 1) {
|
||||
ensurePageLoaded(currentPageNo + 1);
|
||||
}
|
||||
const currentPageNo = next + 1;
|
||||
ensurePageLoaded(currentPageNo, true);
|
||||
ensurePageLoaded(currentPageNo + 1);
|
||||
ensurePageLoaded(currentPageNo + 2);
|
||||
};
|
||||
|
||||
const clampProgress = (val) => {
|
||||
@@ -201,7 +197,8 @@
|
||||
total.value = 0;
|
||||
pagesMap.value = {};
|
||||
loadingMap.value = {};
|
||||
await ensurePageLoaded(1);
|
||||
await ensurePageLoaded(1, true);
|
||||
ensurePageLoaded(2);
|
||||
};
|
||||
|
||||
watch(
|
||||
|
||||
Reference in New Issue
Block a user