Authored by 王水玲

星潮优化

... ... @@ -24,6 +24,8 @@ const headTab = [
}
];
let md5Str = '';
const processPublicData = (req, title) => {
let renderData = {
module: 'guang',
... ... @@ -49,6 +51,7 @@ exports.index = (req, res, next) => {
pageHeadTab[0].cur = true;
starModel.getIndexData().then((result) => {
md5Str = result.md5;
res.render('star/index', _.assign({
page: 'star',
isStarIndexPage: true,
... ... @@ -58,22 +61,28 @@ exports.index = (req, res, next) => {
data: result.ads
},
starAvatar: result.starAvatar ? result.starAvatar : '',
articles: result.articles
articles: result.articles,
md5: result.md5
}, processPublicData(req, '星潮教室')));
}).catch(next);
};
exports.getIndexHtml = (req, res, next) => {
starModel.getIndexData().then((result) => {
res.render('star/index-html', _.assign({
layout: false,
content: {
focus: true,
data: result.ads
},
starAvatar: result.starAvatar ? result.starAvatar : '',
articles: result.articles
}));
if (md5Str !== result.md5) {
res.render('star/index-html', _.assign({
layout: false,
content: {
focus: true,
data: result.ads
},
starAvatar: result.starAvatar ? result.starAvatar : '',
articles: result.articles
}));
} else {
res.json();
}
}).catch(next);
};
... ...
... ... @@ -44,16 +44,19 @@ const _getResources = (page) => {
* @param {[array]} list
* @return {[array]}
*/
const _processIndexData = (list) => {
const _processIndexData = (dataList) => {
const formatData = {
ads: [],
starAvatar: [],
articles: []
};
list = list || {};
let list = dataList.data || {};
list = camelCase(list);
formatData.md5 = dataList.md5;
// 首页资源位数据处理
if (list.ads) {
_.forEach(list.ads.data, (data) => {
... ... @@ -155,7 +158,7 @@ const getIndexData = () => {
client_type: 'iphone'
})).then((result) => {
if (result && result.code === 200) {
return _processIndexData(result.data);
return _processIndexData(result);
} else {
logger.error('星潮教室首页数据返回 code 不是 200');
return {};
... ...
... ... @@ -102,11 +102,6 @@ function setIndexAction() {
pullDown: function() {
if (!stopLoading) {
stopLoading = true;
if (avatarSwiperClone) {
avatarSwiperClone.destroy(true, true);
avatarSwiperClone = '';
}
getIndexHtml();
}
}
... ... @@ -264,14 +259,17 @@ getIndexHtml = function() {
success: function(data) {
stopLoading = false;
if (!data) {
stopLoading = true;
tip.show('没有更多内容了');
}
if (data) {
if (avatarSwiperClone) {
avatarSwiperClone.destroy(true, true);
avatarSwiperClone = '';
}
$starMain.html(data);
$starMain.html(data);
initAction();
}
initAction();
loading.hideLoadingMask();
},
error: function() {
... ...