优化:文章列表支持指定分类

This commit is contained in:
wuhui_zzw 2024-05-23 17:06:16 +08:00
parent eb852c8d17
commit 6c4ae85f86
2 changed files with 48 additions and 21 deletions

View File

@ -69,6 +69,10 @@ export function getUserCoupons(data){
export function getArticleCategoryList(){ export function getArticleCategoryList(){
return request.get('article/category/lst',{},{noAuth:true}) return request.get('article/category/lst',{},{noAuth:true})
} }
// 文章分类详情
export function getArticleCategoryInfo(id){
return request.get('article/category/info/'+id,{},{noAuth:true})
}
/** /**
* 文章列表 * 文章列表
* @param int cid * @param int cid

View File

@ -48,16 +48,17 @@
</template> </template>
<script> <script>
import { import {
getArticleCategoryList, getArticleCategoryList,
getArticleList, getArticleList,
getArticleHotList, getArticleHotList,
getArticleBannerList getArticleBannerList,
getArticleCategoryInfo
} from '@/api/api.js'; } from '@/api/api.js';
import home from '@/components/home'; import home from '@/components/home';
import spread from "../../libs/spread"; import spread from "../../libs/spread";
import { mapGetters } from "vuex"; import { mapGetters } from "vuex";
export default { export default {
components: { components: {
home home
@ -88,7 +89,17 @@
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onLoad: function(options) { onLoad: function(options) {
//
this.active = options.cate_id || 0;
if(this.active > 0) {
//
this.getCidArticle();
this.getArticleInfo();
} else {
//
this.getArticleCate(); this.getArticleCate();
}
//
this.status = false; this.status = false;
this.page = 1; this.page = 1;
this.articleList = []; this.articleList = [];
@ -151,7 +162,19 @@
this.status = false; this.status = false;
this.getCidArticle(); this.getCidArticle();
} }
},
getArticleInfo() {
let _this = this;
getArticleCategoryInfo(_this.active).then(res => {
let data = res.data || {};
let title = data.title || '';
if(title){
uni.setNavigationBarTitle({
title: title
})
} }
});
},
}, },
// #ifdef MP // #ifdef MP
// //