Browse Source

出版

master
jianglong 3 years ago
parent
commit
0adac658c6
  1. 6
      api/store.js
  2. 47
      components/index-home/index-home.vue
  3. 5
      pages/news_list/news_list.vue
  4. 51
      pages/resource_list/resource_list.vue

6
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})
}
//资料列表

47
components/index-home/index-home.vue

@ -7,6 +7,27 @@
<bubble-tips top="280rpx" :discharge="isDischarge"></bubble-tips>
<view class="content">
<!-- 资讯 -->
<router-link v-if="newsList.length" class="" :to="{path: '/pages/community/community'}" navType="pushTab">
<view class="information bg-white flex m-t-20">
<text class="icon-toutiao" >最新服务</text>
<text class="gap-line" style="margin: 0 10rpx"></text>
<view class="news flex-1 flex">
<view class="shade"></view>
<swiper class="flex-1" autoplay="true" style="height: 76rpx;" vertical="true" circular="true"
:interval="3000">
<swiper-item v-for="(item, index) in articleList" :key="index" class="flex">
<view class="flex-none">
<u-tag shape="circle" text="最新" size="mini" type="primary"
mode="plain" />
</view>
<view class="text-swiper m-l-10 line-1">{{item.title }}</view>
</swiper-item>
</swiper>
</view>
<u-icon name="arrow-right"></u-icon>
</view>
</router-link>
<!-- 导航入口 -->
<view class="nav bg-white m-t-20" v-if="newNavList.length">
<swiper :style="'height:' + navSwiperH + 'rpx;'" @change="swiperChange">
@ -51,6 +72,7 @@
<u-icon name="arrow-right"></u-icon>
</view>
</router-link>
<!-- 活动专区 -->
<view class="activity-zone m-t-20" v-if="activityArea.length">
<view class="flex p-20 row-center xxl bold white">
@ -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

5
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)
}
})
}

51
pages/resource_list/resource_list.vue

@ -53,7 +53,7 @@
<router-link :to="{path: '/bundle/pages/resource_details/resource_details', query: {id: item.id, type}}">
<view class="flex col-top">
<view class="info flex-1">
<view class="title lg line-2 m-b-20">{{ item.title }}</view>
<view class="title lg line-2 m-b-20" style="-webkit-line-clamp:1">{{ item.title }}</view>
<view class="lighter line-2">
<view>{{ item.intro }}</view>
</view>
@ -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 @@
// 使getindexcate
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

Loading…
Cancel
Save