|
|
<template>
|
|
|
<ul class="new-cate clearfix">
|
|
|
<li v-for="cate in newsCate" v-bind:class='{"current" : cate.id === crntCateId}' @click="changeCate(cate.id)">{{cate.name}}</li>
|
|
|
</ul>
|
|
|
<resources v-bind:content-code.sync="contentCode"></resources>
|
|
|
<div v-for="news in newsList" class="news-box">
|
|
|
<span class="tag">{{news.categoryName}}</span>
|
|
|
<div class="img">
|
|
|
<a href='{{"/news/" + news.id}}'>
|
|
|
<img v-lazy="news.src | resize 750 470" alt="" />
|
|
|
</a>
|
|
|
</div>
|
|
|
<div class="title"><a href='{{"/news/" + news.id}}'>{{news.title}}</a></div>
|
|
|
<div class="news-des">
|
|
|
{{news.intro}}
|
|
|
</div>
|
|
|
<hr>
|
|
|
<div class="bottom clearfix">
|
|
|
<span class="icon time-icon"></span>
|
|
|
<span class="time">{{news.publishTime}}</span>
|
|
|
<span class="icon share" @click="share(news.title, news.intro, news.src, news.share.url)"></span>
|
|
|
<div v-infinite-scroll="getNewsList()" infinite-scroll-disabled="scrollDisabled">
|
|
|
<div v-for="news in newsList" class="news-box">
|
|
|
<div class="img">
|
|
|
<a href='{{"/news/" + news.id}}'>
|
|
|
<img v-lazy="news.src | resize 750 470" alt="" />
|
|
|
</a>
|
|
|
</div>
|
|
|
<div class="title"><a href='{{"/news/" + news.id}}'>{{news.title}}</a></div>
|
|
|
<div class="news-des">
|
|
|
{{news.intro}}
|
|
|
</div>
|
|
|
<hr>
|
|
|
<div class="bottom clearfix">
|
|
|
<span class="icon time-icon"></span>
|
|
|
<span class="time">{{news.publishTime}}</span>
|
|
|
<span class="icon share" @click="share(news.title, news.intro, news.src, news.share.url)"></span>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
<style>
|
|
|
.new-cate {
|
|
|
color: #b0b0b0;
|
|
|
width: 100%;
|
|
|
height: 90px;
|
|
|
|
|
|
li {
|
|
|
width: 20%;
|
|
|
float: left;
|
|
|
text-align: center;
|
|
|
padding: 28px 0;
|
|
|
}
|
|
|
|
|
|
.current {
|
|
|
color: #000;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
.news-box {
|
|
|
background: #f6f6f6;
|
|
|
|
|
|
.tag {
|
|
|
position: relative;
|
|
|
top: 42px;
|
|
|
left: 0;
|
|
|
padding: 12px 24px;
|
|
|
background: #000;
|
|
|
color: #fff;
|
|
|
}
|
|
|
|
|
|
.img {
|
|
|
width: 100%;
|
|
|
height: 470px;
|
|
|
overflow: hidden;
|
|
|
padding-top: 30px;
|
|
|
|
|
|
img {
|
|
|
width: 100%;
|
...
|
...
|
@@ -105,60 +78,42 @@ |
|
|
data() {
|
|
|
return {
|
|
|
contentCode: contentCode.news[qs.cate || 'new'],
|
|
|
crntCateId: -1,
|
|
|
newsCate: [],
|
|
|
newsList: [],
|
|
|
gender: qs.gender,
|
|
|
page: 1,
|
|
|
limit: 10,
|
|
|
page: 0,
|
|
|
scrollDisabled: false
|
|
|
};
|
|
|
},
|
|
|
watch: {
|
|
|
crntCateId() {
|
|
|
this.getNewsList();
|
|
|
},
|
|
|
gender() {
|
|
|
this.getNewsList();
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
|
|
|
/* 获取资讯分类 */
|
|
|
getNewsCate() {
|
|
|
$.get({
|
|
|
url: '/news/get-news-cate'
|
|
|
}).done(result => {
|
|
|
if (result) {
|
|
|
this.newsCate = result;
|
|
|
this.crntCateId = result[0].id;
|
|
|
} else {
|
|
|
tip('服务端无数据返回');
|
|
|
}
|
|
|
}).fail();
|
|
|
},
|
|
|
|
|
|
/* 改变分类 */
|
|
|
changeCate(cateId) {
|
|
|
this.crntCateId = cateId;
|
|
|
},
|
|
|
|
|
|
/* 获取资讯列表数据 */
|
|
|
getNewsList() {
|
|
|
$.post({
|
|
|
url: '/news/get-news-list',
|
|
|
url: '/news/list.json',
|
|
|
data: {
|
|
|
sortId: this.crntCateId,
|
|
|
page: this.page,
|
|
|
limit: this.limit,
|
|
|
page: this.page++,
|
|
|
gender: this.gender || '1,2,3'
|
|
|
}
|
|
|
}).done(result => {
|
|
|
if (result) {
|
|
|
this.newsList = result;
|
|
|
if (result.code === 200) {
|
|
|
if (this.newsList.length > 0 && result.data.list.length > 0) {
|
|
|
this.$set('newsList', this.newsList.concat(result.data.list));
|
|
|
} else {
|
|
|
this.newsList = result.data.list;
|
|
|
}
|
|
|
} else {
|
|
|
tip('服务端无数据返回');
|
|
|
this.scrollDisabled = true;
|
|
|
tip('没有了...');
|
|
|
}
|
|
|
}).fail();
|
|
|
}).fail(() => {
|
|
|
tip('服务器错误');
|
|
|
});
|
|
|
},
|
|
|
|
|
|
/* 分享资讯 */
|
...
|
...
|
@@ -175,7 +130,7 @@ |
|
|
resources
|
|
|
},
|
|
|
created() {
|
|
|
this.getNewsCate();
|
|
|
this.getNewsList();
|
|
|
}
|
|
|
};
|
|
|
</script> |
...
|
...
|
|