|
@@ -5,6 +5,8 @@ export const useInfoStore = defineStore({
|
|
|
id: "info",
|
|
|
state: () => {
|
|
|
return {
|
|
|
+ isLoadMoreLock: false,
|
|
|
+ tabs: ["exhibitions", "activates", "news", "notices"],
|
|
|
exhibitions: [],
|
|
|
activates: [],
|
|
|
news: [],
|
|
@@ -28,37 +30,58 @@ export const useInfoStore = defineStore({
|
|
|
searchKey: "",
|
|
|
type: "",
|
|
|
total: 0,
|
|
|
+ pages: 0,
|
|
|
+ current: 0,
|
|
|
},
|
|
|
};
|
|
|
},
|
|
|
- getters: {},
|
|
|
+ getters: {
|
|
|
+ isLoad() {
|
|
|
+ return this.pagination.total > 0;
|
|
|
+ },
|
|
|
+ isLast() {
|
|
|
+ return (
|
|
|
+ this.pagination.current &&
|
|
|
+ this.pagination.pages &&
|
|
|
+ this.pagination.pages === this.pagination.current
|
|
|
+ );
|
|
|
+ },
|
|
|
+ },
|
|
|
actions: {
|
|
|
- async getExhibition(page) {
|
|
|
+ async getExhibitions(page) {
|
|
|
this.pagination.type = "exhibition";
|
|
|
this.pagination.pageNum = page || 1;
|
|
|
const { data, status } = await request.post("/show/news/pageList", {
|
|
|
...this.pagination,
|
|
|
});
|
|
|
if (data.code === 0) {
|
|
|
- const { records, total, current, page } = data.data;
|
|
|
- this.exhibitions = records;
|
|
|
+ const { records, total, current, pages } = data.data;
|
|
|
+ const lists = this.exhibitions.concat(records);
|
|
|
+ this.exhibitions = lists;
|
|
|
this.pagination.total = total;
|
|
|
this.pagination.current = current;
|
|
|
- this.pagination.page = page;
|
|
|
+ this.pagination.pages = pages;
|
|
|
+ this.isLoadMoreLock = false;
|
|
|
+ } else {
|
|
|
+ this.resetPage();
|
|
|
+ this.exhibitions = [];
|
|
|
}
|
|
|
},
|
|
|
- async getActivity(page) {
|
|
|
+ async getActivates(page) {
|
|
|
this.pagination.pageNum = page || 1;
|
|
|
this.pagination.type = "activity";
|
|
|
const { data, status } = await request.post("/show/news/pageList", {
|
|
|
...this.pagination,
|
|
|
});
|
|
|
if (data.code === 0) {
|
|
|
- const { records, total, current, page } = data.data;
|
|
|
+ const { records, total, current, pages } = data.data;
|
|
|
this.activates = records;
|
|
|
this.pagination.total = total;
|
|
|
this.pagination.current = current;
|
|
|
- this.pagination.page = page;
|
|
|
+ this.pagination.pages = pages;
|
|
|
+ } else {
|
|
|
+ this.resetPage();
|
|
|
+ this.activates = [];
|
|
|
}
|
|
|
},
|
|
|
async getNews(page) {
|
|
@@ -68,11 +91,14 @@ export const useInfoStore = defineStore({
|
|
|
...this.pagination,
|
|
|
});
|
|
|
if (data.code === 0) {
|
|
|
- const { records, total, current, page } = data.data;
|
|
|
+ const { records, total, current, pages } = data.data;
|
|
|
this.news = records;
|
|
|
this.pagination.total = total;
|
|
|
this.pagination.current = current;
|
|
|
- this.pagination.page = page;
|
|
|
+ this.pagination.pages = pages;
|
|
|
+ } else {
|
|
|
+ this.resetPage();
|
|
|
+ this.news = [];
|
|
|
}
|
|
|
},
|
|
|
async getNotices(page) {
|
|
@@ -82,11 +108,14 @@ export const useInfoStore = defineStore({
|
|
|
...this.pagination,
|
|
|
});
|
|
|
if (data.code === 0) {
|
|
|
- const { records, total, current, page } = data.data;
|
|
|
+ const { records, total, current, pages } = data.data;
|
|
|
this.notices = records;
|
|
|
this.pagination.total = total;
|
|
|
this.pagination.current = current;
|
|
|
- this.pagination.page = page;
|
|
|
+ this.pagination.pages = pages;
|
|
|
+ } else {
|
|
|
+ this.resetPage();
|
|
|
+ this.notices = [];
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -98,5 +127,62 @@ export const useInfoStore = defineStore({
|
|
|
this.detail = null;
|
|
|
}
|
|
|
},
|
|
|
+ resetPage() {
|
|
|
+ this.pagination = {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 20,
|
|
|
+ searchKey: "",
|
|
|
+ type: "",
|
|
|
+ total: 0,
|
|
|
+ current: null,
|
|
|
+ pages: null,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ loadMore(currentTab) {
|
|
|
+ if (!this.isLoadMoreLock && !this.isLast) {
|
|
|
+ console.log("loadMore", currentTab);
|
|
|
+ this.isLoadMoreLock = true;
|
|
|
+ const page =
|
|
|
+ this.pagination.pageNum < this.pagination.pages
|
|
|
+ ? this.pagination.pageNum + 1
|
|
|
+ : this.pagination.pages;
|
|
|
+
|
|
|
+ switch (currentTab) {
|
|
|
+ case "exhibitions":
|
|
|
+ this.getExhibitions(page);
|
|
|
+ break;
|
|
|
+ case "activates":
|
|
|
+ this.getActivates(page);
|
|
|
+ break;
|
|
|
+ case "news":
|
|
|
+ this.getNews(page);
|
|
|
+ break;
|
|
|
+ case "notices":
|
|
|
+ this.getNotices(page);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ switchTab(tab) {
|
|
|
+ this.resetPage();
|
|
|
+ switch (tab) {
|
|
|
+ case "exhibitions":
|
|
|
+ this.exhibitions = [];
|
|
|
+ this.getExhibitions();
|
|
|
+ break;
|
|
|
+ case "activates":
|
|
|
+ this.activates = [];
|
|
|
+ this.getActivates();
|
|
|
+ break;
|
|
|
+ case "news":
|
|
|
+ this.news = [];
|
|
|
+ this.getNews();
|
|
|
+ break;
|
|
|
+ case "notices":
|
|
|
+ this.notices = [];
|
|
|
+ this.getNotices();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
});
|