fix: 修复Halo最新版本搜索接口字段不存在问题

This commit is contained in:
小莫唐尼 2024-08-05 19:04:55 +08:00
parent ff31e0d8e8
commit 88fb74a795

View File

@ -26,7 +26,7 @@
</view> </view>
<block v-else> <block v-else>
<!-- 文章卡片 --> <!-- 文章卡片 -->
<tm-translate v-for="(article, index) in dataList" :key="article.name" animation-name="fadeUp" <tm-translate v-for="(article, index) in dataList" :key="article.metadataName" animation-name="fadeUp"
:wait="calcAniWait(index)"> :wait="calcAniWait(index)">
<view class="article-card" @click="fnToArticleDetail(article)"> <view class="article-card" @click="fnToArticleDetail(article)">
<rich-text style="font-size: 32rpx;font-weight: bold;color: #333;" <rich-text style="font-size: 32rpx;font-weight: bold;color: #333;"
@ -40,7 +40,7 @@
</tm-translate> </tm-translate>
<tm-flotbutton @click="fnToTopPage" size="m" color="light-blue" icon="icon-angle-up"></tm-flotbutton> <tm-flotbutton @click="fnToTopPage" size="m" color="light-blue" icon="icon-angle-up"></tm-flotbutton>
<view class="load-text">{{ loadMoreText }}</view>
</block> </block>
</view> </view>
</view> </view>
@ -81,9 +81,6 @@ export default {
dataList: [], dataList: [],
total: 0 total: 0
}, },
hasNext: false,
isLoadMore: false,
loadMoreText: '加载中...',
dataList: [] dataList: []
}; };
}, },
@ -99,7 +96,6 @@ export default {
}, },
onPullDownRefresh() { onPullDownRefresh() {
this.fnResetSetAniWaitIndex(); this.fnResetSetAniWaitIndex();
this.isLoadMore = false;
this.fnGetData(); this.fnGetData();
}, },
@ -121,7 +117,7 @@ export default {
}, },
fnOnSearch() { fnOnSearch() {
this.fnResetSetAniWaitIndex(); this.fnResetSetAniWaitIndex();
this.isLoadMore = false;
if (!this.queryParams.keyword) { if (!this.queryParams.keyword) {
this.dataList = [] this.dataList = []
} else { } else {
@ -129,34 +125,17 @@ export default {
} }
}, },
fnGetData() { fnGetData() {
// uni.showLoading({
// mask: true,
// title: '...'
// });
// //
if (!this.isLoadMore) {
this.loading = 'loading'; this.loading = 'loading';
}
this.loadMoreText = '加载中...';
this.$httpApi.v2 this.$httpApi.v2
.getPostListByKeyword(this.queryParams) .getPostListByKeyword(this.queryParams)
.then(res => { .then(res => {
console.log('请求结果:');
console.log(res);
this.loading = 'success'; this.loading = 'success';
this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
this.hasNext = res.hasNext;
if (this.isLoadMore) {
this.dataList = this.dataList.concat(res.hits);
} else {
this.dataList = res.hits; this.dataList = res.hits;
}
}) })
.catch(err => { .catch(err => {
console.error(err); console.error(err);
this.loading = 'error'; this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
}) })
.finally(() => { .finally(() => {
setTimeout(() => { setTimeout(() => {
@ -169,7 +148,7 @@ export default {
// //
fnToArticleDetail(article) { fnToArticleDetail(article) {
uni.navigateTo({ uni.navigateTo({
url: '/pagesA/article-detail/article-detail?name=' + article.name, url: '/pagesA/article-detail/article-detail?name=' + article.metadataName,
animationType: 'slide-in-right' animationType: 'slide-in-right'
}); });
} }