1
|
<template>
|
1
|
<template>
|
2
|
<resources v-bind:content-code.sync="contentCode"></resources>
|
2
|
<resources v-bind:content-code.sync="contentCode"></resources>
|
3
|
- <div v-for="news in newsList" class="news-box">
|
3
|
+ <div v-for="news in newsList" class="news-box" v-infinite-scroll="getNewsList()">
|
4
|
<span v-if='news.categoryName !== "最新"' class="tag">{{news.categoryName}}</span>
|
4
|
<span v-if='news.categoryName !== "最新"' class="tag">{{news.categoryName}}</span>
|
5
|
<div class="img">
|
5
|
<div class="img">
|
6
|
<a href='{{"/news/" + news.id}}'>
|
6
|
<a href='{{"/news/" + news.id}}'>
|
|
@@ -87,8 +87,9 @@ |
|
@@ -87,8 +87,9 @@ |
87
|
contentCode: contentCode.news[qs.cate || 'new'],
|
87
|
contentCode: contentCode.news[qs.cate || 'new'],
|
88
|
newsList: [],
|
88
|
newsList: [],
|
89
|
gender: qs.gender,
|
89
|
gender: qs.gender,
|
90
|
- page: 1,
|
|
|
91
|
- limit: 10,
|
90
|
+ page: 0,
|
|
|
91
|
+ busy: false,
|
|
|
92
|
+ scrollDisabled: false
|
92
|
};
|
93
|
};
|
93
|
},
|
94
|
},
|
94
|
watch: {
|
95
|
watch: {
|
|
@@ -100,21 +101,30 @@ |
|
@@ -100,21 +101,30 @@ |
100
|
|
101
|
|
101
|
/* 获取资讯列表数据 */
|
102
|
/* 获取资讯列表数据 */
|
102
|
getNewsList() {
|
103
|
getNewsList() {
|
103
|
- $.post({
|
|
|
104
|
- url: '/news/get-news-list',
|
|
|
105
|
- data: {
|
|
|
106
|
- sortId: this.crntCateId,
|
|
|
107
|
- page: this.page,
|
|
|
108
|
- limit: this.limit,
|
|
|
109
|
- gender: this.gender || '1,2,3'
|
|
|
110
|
- }
|
|
|
111
|
- }).done(result => {
|
|
|
112
|
- if (result) {
|
|
|
113
|
- this.newsList = result;
|
|
|
114
|
- } else {
|
|
|
115
|
- tip('服务端无数据返回');
|
|
|
116
|
- }
|
|
|
117
|
- }).fail();
|
104
|
+ if (this.busy === false) {
|
|
|
105
|
+ this.busy = true;
|
|
|
106
|
+ $.post({
|
|
|
107
|
+ url: '/news/get-news-list',
|
|
|
108
|
+ data: {
|
|
|
109
|
+ sortId: this.crntCateId,
|
|
|
110
|
+ page: this.page++,
|
|
|
111
|
+ gender: this.gender || '1,2,3'
|
|
|
112
|
+ }
|
|
|
113
|
+ }).done(result => {
|
|
|
114
|
+ if (result.code === 200) {
|
|
|
115
|
+ if (this.newsList.length > 0 && result.data.list.length > 0) {
|
|
|
116
|
+ Array.prototype.push.apply(this.newsList, result.data.list);
|
|
|
117
|
+ } else {
|
|
|
118
|
+ this.newsList = result.data.list;
|
|
|
119
|
+ }
|
|
|
120
|
+ } else {
|
|
|
121
|
+ this.scrollDisabled = true;
|
|
|
122
|
+ }
|
|
|
123
|
+ this.busy = false;
|
|
|
124
|
+ }).fail(() => {
|
|
|
125
|
+ tip('服务器错误');
|
|
|
126
|
+ });
|
|
|
127
|
+ }
|
118
|
},
|
128
|
},
|
119
|
|
129
|
|
120
|
/* 分享资讯 */
|
130
|
/* 分享资讯 */
|