1
0
mirror of https://github.com/ialley-workshop-open/uni-halo.git synced 2026-06-12 13:19:31 +08:00

fix: 修复首页加载异常问题

This commit is contained in:
小莫唐尼
2024-05-22 00:43:24 +08:00
parent f6069cad95
commit 512a4013b9
16 changed files with 366 additions and 62 deletions
+4
View File
@@ -20,6 +20,10 @@
uni.switchTab({
url: '/pages/tabbar/home/home'
});
// uni.navigateTo({
// url:'/pagesA/test-page/test-page'
// })
} else {
uni.redirectTo({
url: '/pagesA/start/start'
+19 -15
View File
@@ -12,20 +12,19 @@
<tm-empty icon="icon-shiliangzhinengduixiang-" label="暂无数据"></tm-empty>
</view>
<block v-else>
<block v-for="(item, index) in dataList" :key="index">
<!-- 卡片 -->
<tm-translate style="box-sizing: border-box;width: 50%;padding: 0 8rpx;" animation-name="fadeUp"
:wait="calcAniWait()">
<view class="catgory-card" :style="{backgroundImage:`url(${item.spec.cover})`}">
<view class="content">
<view style="font-size: 32rpx;color: #ffffff;">{{item.spec.displayName}}</view>
<view style="font-size: 24rpx;color: #ffffff;margin-top: 6rpx;">
{{item.postCount}} 篇文章
</view>
<tm-translate v-for="(item, index) in dataList" :key="index"
style="box-sizing: border-box;width: 50%;padding: 0 8rpx;" animation-name="fadeUp"
:wait="calcAniWait(index)">
<view class="catgory-card" :style="{backgroundImage:`url(${item.spec.cover})`}">
<view class="content" @click="handleToCategory(item)">
<view style="font-size: 32rpx;color: #ffffff;">{{item.spec.displayName}}</view>
<view style="font-size: 24rpx;color: #ffffff;margin-top: 6rpx;">
{{item.postCount}} 篇文章
</view>
</view>
</tm-translate>
</block>
</view>
</tm-translate>
<tm-flotbutton @click="fnToTopPage" size="m" color="light-blue" icon="icon-angle-up"></tm-flotbutton>
<view class="load-text">{{ loadMoreText }}</view>
</block>
@@ -57,7 +56,7 @@
size: 20,
page: 1
},
result: null,
hasNext: false,
dataList: [],
isLoadMore: false,
loadMoreText: '加载中...'
@@ -80,7 +79,7 @@
},
onReachBottom(e) {
if (this.result.hasNext) {
if (this.hasNext) {
this.queryParams.page += 1;
this.isLoadMore = true;
this.fnGetData();
@@ -111,7 +110,7 @@
this.loading = 'success';
this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
// 处理数据
this.result = res;
this.hasNext = res.hasNext;
const tempItems = res.items.map(item => {
item.spec.cover = this.$utils.checkThumbnailUrl(item.spec.cover, true)
@@ -141,6 +140,11 @@
current: index,
urls: list.map(item => item.url)
})
},
handleToCategory(data) {
uni.navigateTo({
url: `/pagesA/category-detail/category-detail?name=${data.metadata.name}&title=${data.spec.displayName}`
})
}
}
};
+3 -3
View File
@@ -81,7 +81,7 @@
},
isLoadMore: false,
loadMoreText: '',
result: {},
hasNext: false,
dataList: []
};
},
@@ -101,7 +101,7 @@
this.fnGetData();
},
onReachBottom(e) {
if (this.result.hasNext) {
if (this.hasNext) {
this.queryParams.page += 1;
this.isLoadMore = true;
this.fnGetData();
@@ -150,7 +150,7 @@
.getPhotoListByGroupName(this.queryParams)
.then(res => {
console.log("相册 res", res)
this.result = res;
this.hasNext = res.hasNext;
this.loading = 'success';
if (res.items.length != 0) {
const _list = res.items.map((item, index) => {
+8 -13
View File
@@ -20,14 +20,12 @@
</view>
<block v-else>
<view class="bg-white pb-24">
<!-- 轮播图+广告 -->
<view class="banner bg-white ml-24 mr-24 mt-12 round-3" v-if="bannerList.length != 0">
<e-swiper :dotPosition="globalAppSettings.banner.dotPosition" :autoplay="true"
:useDot="globalAppSettings.banner.useDot" :list="bannerList"
@on-click="fnOnBannerClick"></e-swiper>
</view>
</view>
<!-- 精品分类 -->
<view class="flex flex-between mt-16 mb-24 pl-24 pr-24">
<view class="page-item_title text-weight-b ">精品分类</view>
<view class="show-more flex flex-center bg-white round-3" @click="fnToCategoryPage">
@@ -64,9 +62,9 @@
label="博主还没有发表任何文章~"></tm-empty></view>
<block v-else>
<view :class="globalAppSettings.layout.home">
<tm-translate v-for="(article, index) in articleList" :key="article.metadata.name" class="ani-item"
<tm-translate v-for="(article, index) in articleList" :key="index" class="ani-item"
animation-name="fadeUp" :wait="calcAniWait(index)">
<article-card from="home" :article="article" @on-click="fnToArticleDetail"></article-card>
<article-card from="home" :article="article" :post="article" @on-click="fnToArticleDetail"></article-card>
</tm-translate>
</view>
<view class="load-text mt-12">{{ loadMoreText }}</view>
@@ -258,19 +256,16 @@
}
this.loadMoreText = '加载中...';
this.$httpApi.v2
.getPostList(this.queryParams)
.then(res => {
console.log('加载成功', res);
setTimeout(() => {
this.result = res;
if (this.isLoadMore) {
this.articleList = this.articleList.concat(res.items);
} else {
this.articleList = res.items;
}
}, 200)
this.result.hasNext = res.hasNext;
if (this.isLoadMore) {
this.articleList = this.articleList.concat(res.items);
} else {
this.articleList = res.items;
}
this.loading = 'success';
this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
})
+4 -5
View File
@@ -79,7 +79,7 @@
size: 10,
page: 1
},
result: null,
hasNext: false,
dataList: [],
isLoadMore: false,
loadMoreText: '加载中...'
@@ -102,7 +102,7 @@
},
onReachBottom(e) {
if (this.result.hasNext) {
if (this.hasNext) {
this.queryParams.page += 1;
this.isLoadMore = true;
this.fnGetData();
@@ -131,9 +131,8 @@
console.log(res);
this.loading = 'success';
this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
// 处理数据
this.result = res;
this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
this.hasNext = res.hasNext;
const tempItems = res.items.map(item => {
item.spec.user = {
+1
View File
@@ -47,6 +47,7 @@ export default {
},
result: null,
dataList: [],
hasNext:false,
isLoadMore: false,
loadMoreText: '加载中...'
};