diff --git a/pages/tabbar/home/home.vue b/pages/tabbar/home/home.vue index b96e0ef..64b1b12 100644 --- a/pages/tabbar/home/home.vue +++ b/pages/tabbar/home/home.vue @@ -21,14 +21,14 @@ - + - + 精品分类 @@ -38,7 +38,7 @@ - + 还没有任何分类~ @@ -194,9 +194,7 @@ export default { }, // 获取轮播图 fnGetBanner() { - if (this.haloConfigs.basicConfig.auditModeEnabled) { - return; - } + const _this = this; const _format = function (list) { return list.map((item, index) => { @@ -245,9 +243,6 @@ export default { }, // 文章列表 fnGetArticleList() { - if (this.haloConfigs.basicConfig.auditModeEnabled) { - return; - } // 设置状态为加载中 if (!this.isLoadMore) { this.loading = 'loading'; diff --git a/pagesA/archives/archives.vue b/pagesA/archives/archives.vue index 21566a1..209b9a2 100644 --- a/pagesA/archives/archives.vue +++ b/pagesA/archives/archives.vue @@ -41,28 +41,26 @@ - - - - - + 该日期下暂无归档文章! @@ -146,6 +144,7 @@ this.fnResetSetAniWaitIndex(); this.queryParams.page = 0; this.dataList = this.handleGetShowDataList(this.handleGetPosts(this.cacheDataList)) + this.fnToTopPage(); }, fnGetData() { if (this.isLoadMore) { @@ -154,9 +153,8 @@ }) } else { this.loading = 'loading'; - this.loadMoreText = "加载中..."; } - + this.loadMoreText = "加载中..."; const paramsStr = qs.stringify(this.queryParams, { allowDots: true, encodeValuesOnly: true, @@ -173,7 +171,10 @@ const posts = this.handleGetPosts(data.items) const showDataList = this.handleGetShowDataList(posts) if (this.isLoadMore) { - this.cacheDataList = this.cacheDataList.concat(data.items); + this.cacheDataList = this.handleUniqueCacheDatalist([...this.cacheDataList, ... + data + .items + ]); this.handleMergeDataList2(showDataList) } else { this.dataList = [] @@ -185,6 +186,7 @@ this.loadMoreText = data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~'; uni.hideLoading(); uni.stopPullDownRefresh(); + }, fail: (err) => { this.loading = 'error'; @@ -237,11 +239,11 @@ } dataListResult.push(postData) }) - if (this.tab.activeIndex == 1) { - dataListResult.sort((a, b) => { - return Number(b.year) - Number(a.year) - }) - } + + dataListResult.sort((a, b) => { + return Number(b.sort) - Number(a.sort) + }) + return dataListResult; }, handleMergeDataList(list1, list2) { @@ -270,22 +272,31 @@ return Object.values(merged); }, handleMergeDataList2(list) { - const tempList = [...list] - this.dataList.forEach((item, index) => { + list.forEach((item, index) => { const find = this.dataList.find(x => x.key == item.key) if (find) { item.posts.forEach(post => { - if (!find.posts.some(x => x.metadata.name == post.metadata.name)) { + if (!find.posts.find(x => x.metadata.name == post.metadata.name)) { find.posts.push(post) } }) - tempList.splice(index, 1) } }) - tempList.forEach(post => { - this.dataList.push(post) + list.forEach(post => { + if (!this.dataList.find(x => x.key === post.key)) { + this.dataList.push(post) + } }) - console.log("this.dataList", this.dataList) + + this.dataList.sort((a, b) => { + return Number(b.sort) - Number(a.sort) + }) + }, + handleUniqueCacheDatalist(dataList) { + const seen = new Set(); + return dataList.filter(item => { + return seen.has(item.metadata.name) ? false : seen.add(item.metadata.name); + }); }, fnToArticleDetail(article) { uni.navigateTo({