Authored by 郭成尧

'listScroll'

... ... @@ -23,7 +23,6 @@ module.exports = {
getNewsList: (req, res, next) => {
let params = {
page: req.body.page,
limit: req.body.limit,
gender: req.body.gender,
uid: req.user.uid
};
... ...
... ... @@ -17,7 +17,7 @@ module.exports = {
gender: params.gender,
uid: params.uid || '0',
page: params.page,
limit: params.limit,
limit: '5',
app_type: '1'
});
}
... ...
... ... @@ -22,8 +22,14 @@ const newsList = params => {
return api.all([
newsListApi.getNewsListData(params)
]).then(result => {
if (result[0].code === 200) {
Object.assign(finalResult, result[0].data.list.artList);
if (result[0].code === 200 && result[0].data.list) {
Object.assign(finalResult, {
data: {
list: result[0].data.list.artList,
totalPage: result[0].data.totalPage
},
code: 200
});
} else {
logger.error('getNewsListData api code no 200');
}
... ...
<template>
<resources v-bind:content-code.sync="contentCode"></resources>
<div v-for="news in newsList" class="news-box">
<div v-for="news in newsList" class="news-box" v-infinite-scroll="getNewsList()">
<span v-if='news.categoryName !== "最新"' class="tag">{{news.categoryName}}</span>
<div class="img">
<a href='{{"/news/" + news.id}}'>
... ... @@ -87,8 +87,9 @@
contentCode: contentCode.news[qs.cate || 'new'],
newsList: [],
gender: qs.gender,
page: 1,
limit: 10,
page: 0,
busy: false,
scrollDisabled: false
};
},
watch: {
... ... @@ -100,21 +101,30 @@
/* 获取资讯列表数据 */
getNewsList() {
$.post({
url: '/news/get-news-list',
data: {
sortId: this.crntCateId,
page: this.page,
limit: this.limit,
gender: this.gender || '1,2,3'
}
}).done(result => {
if (result) {
this.newsList = result;
} else {
tip('服务端无数据返回');
}
}).fail();
if (this.busy === false) {
this.busy = true;
$.post({
url: '/news/get-news-list',
data: {
sortId: this.crntCateId,
page: this.page++,
gender: this.gender || '1,2,3'
}
}).done(result => {
if (result.code === 200) {
if (this.newsList.length > 0 && result.data.list.length > 0) {
Array.prototype.push.apply(this.newsList, result.data.list);
} else {
this.newsList = result.data.list;
}
} else {
this.scrollDisabled = true;
}
this.busy = false;
}).fail(() => {
tip('服务器错误');
});
}
},
/* 分享资讯 */
... ...