diff --git a/.gitignore b/.gitignore
index c7721a3..2c2b7d4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,3 @@
unpackage
node_modules/
-.hbuilderx/
\ No newline at end of file
+.hbuilderx/
diff --git a/api/store.js b/api/store.js
index 9d6cd40..81fd54a 100644
--- a/api/store.js
+++ b/api/store.js
@@ -67,7 +67,7 @@ export function getArticleList(data) {
// 文章详情
export function getArticleDetail(data) {
let {type} = data
- let url = type ? 'help/detail' : 'article/detail'
+ let url = type==1 ? 'help/detail' : 'article/detail'
delete data.type
return request.get(url, {
params: { id: data.id }
@@ -207,9 +207,9 @@ export function getGeocoder(params) {
//资料分类
-export function getResourceCategoryList() {
+export function getResourceCategoryList(params) {
let url = 'resource/category'
- return request.get(url)
+ return request.get(url, {params})
}
//资料列表
diff --git a/components/index-home/index-home.vue b/components/index-home/index-home.vue
index ef71dac..2c3ff92 100644
--- a/components/index-home/index-home.vue
+++ b/components/index-home/index-home.vue
@@ -7,6 +7,27 @@
+
+
+
+ 最新服务
+
+
+
+
+
+
+
+
+ {{item.title }}
+
+
+
+
+
+
@@ -51,6 +72,7 @@
+
@@ -132,6 +154,9 @@
arraySlice,
menuJump
} from '@/utils/tools'
+
+ import{getCommunityArticleLists} from '@/api/community.js'
+
import {mapGetters} from 'vuex'
export default {
props: {
@@ -154,6 +179,7 @@
},
data() {
return {
+ articleList:[],
newNavList: [],
navSwiperH: '',
currentSwiper: 0,
@@ -162,12 +188,33 @@
}
},
mounted() {
+ // 每10秒执行一次请求
+ setInterval(this.getCommunityArticleLists, 60000);
+ this.getCommunityArticleLists();
this.isDischarge = false;
},
destroyed() {
this.isDischarge = true;
},
methods: {
+ getCommunityArticleLists() {
+ getCommunityArticleLists({
+ page_no: 1,
+ page_size: 10
+ }).then(res => {
+ if (res.code == 1) {
+ this.articleList = res.data.list
+ this.articleList.forEach((item, index) => {
+ if(item['type'] == 0 ){
+ item['title'] = item['nickname'] +"发布了需求:"+item['content']
+ }else{
+ item['title'] = item['nickname'] +"发布了服务:"+item['content']
+ }
+ })
+ console.log("最新数据,",this.articleList)
+ }
+ });
+ },
swiperChange(e) {
console.log(e)
this.currentSwiper = e.detail.current
diff --git a/pages/news_list/news_list.vue b/pages/news_list/news_list.vue
index fbfa89f..cb595e8 100644
--- a/pages/news_list/news_list.vue
+++ b/pages/news_list/news_list.vue
@@ -70,8 +70,7 @@
},
onLoad(options) {
- this.case = options.case;
- this.cid = options.cate
+ this.cid = this.$Route.query.cate || 0;
this.type = this.$Route.query.type || 0;
if (this.type == 1) {
uni.setNavigationBarTitle({
@@ -126,13 +125,13 @@
} = await getCategoryList({
type: this.type
})
-
if (code == 1) {
this.categoryList = data
console.log("类型:",this.cid)
this.categoryList.forEach((item, index) => {
if(this.cid>0 && item.id == this.cid){
this.active = index+1
+ console.log("active:",this.active)
}
})
}
diff --git a/pages/resource_list/resource_list.vue b/pages/resource_list/resource_list.vue
index d254506..25765dc 100644
--- a/pages/resource_list/resource_list.vue
+++ b/pages/resource_list/resource_list.vue
@@ -53,7 +53,7 @@
- {{ item.title }}
+ {{ item.title }}
{{ item.intro }}
@@ -117,11 +117,15 @@
categoryList: [],
newsList: [],
type: -1,
+ cate_type:0,
};
},
async onShow() {
+ console.log(111)
+ this.categoryList = [],
this.type = 0;
+ this.cate_type = 0;
uni.setNavigationBarTitle({
title: '资料库'
});
@@ -144,14 +148,27 @@
// 使用get方法获取index和cate的值
let p_index = params['index'];
let p_cate = params['cate'];
+ let cate_type = params['cate_type'];
if(p_index !=undefined && p_index!=""){
this.current = parseInt(p_index)
this.currentNav = parseInt(p_index)
}
+
if(p_cate !=undefined && p_cate!=""){
this.cid = parseInt(p_cate)
}
+
+ if(cate_type !=undefined && cate_type!=""){
+ this.cate_type = parseInt(cate_type)
+ this.active = 0
+ if(this.cate_type == 1){
+ uni.setNavigationBarTitle({
+ title: '全国案例'
+ });
+ }
+ }
+
}
@@ -167,7 +184,7 @@
});
console.log(11111)
// 选择城市后是否刷新
- await this.downCallback();
+ // await this.downCallback();
},
@@ -188,13 +205,12 @@
},
upCallback(page) {
const { type, active, categoryList } = this
- console.log(categoryList,11222)
- console.log(categoryList[active-1],22333)
getResourceList({
type: this.type,
cid: this.active ? categoryList[active-1].id : '',
page_size:page.size,
- page_no:page.num
+ page_no:page.num,
+ cate_type: this.cate_type,
}).then(({
data
}) => {
@@ -210,6 +226,8 @@
},
async getCategoryListFun() {
+ this.categoryList = [];
+ console.log("当前分类",this.categoryList)
let {
cityInfo,
isLogin
@@ -218,16 +236,21 @@
code,
data
} = await getResourceCategoryList({
- type: this.type
+ cate_type: this.cate_type,
})
+
if (code == 1) {
this.categoryList = data
}
- let item = {id:0,name:"全国"}
- if(cityInfo.id !=null && cityInfo.id!=undefined && cityInfo.id>0){
- item = {id:"city_"+cityInfo.id,name:"本地"}
+ let item = {}
+
+ if(this.cate_type == 0){
+ let item = {id:0,name:"全国"}
+ if(cityInfo.id !=null && cityInfo.id!=undefined && cityInfo.id>0){
+ item = {id:"city_"+cityInfo.id,name:"本地"}
+ }
+ this.categoryList.push(item)
}
- this.categoryList.push(item)
if(isLogin){
item = {id:"my_buy",name:"我的购买"}
@@ -236,6 +259,14 @@
item = {id:"my_download",name:"我的下载"}
this.categoryList.push(item)
}
+ this.$nextTick(() => {
+ // 在DOM更新之后使用Vue.set来更新数组
+ this.categoryList.forEach((item, index) => {
+ this.$set(this.categoryList, index, item);
+ });
+ });
+ console.log("后续值",this.categoryList)
+ console.log("后续值2",this.cid)
this.categoryList.forEach((item, index) => {
if(this.cid>0 && item.id == this.cid){
this.active = index+1