Authored by 王水玲

星潮优化

... ... @@ -190,8 +190,9 @@ exports.detail = (req, res) => {
*/
exports.detailList = (req, res, next) => {
let params = req.query;
let uid = req.cookies.guangStarUid || 0;
starModel.getDetailData(params).then((result) => {
starModel.getDetailData(params, uid).then((result) => {
res.render('star/list', _.assign({
layout: false,
params: params,
... ...
... ... @@ -78,7 +78,7 @@ const _processIndexData = (list) => {
_.forEach(data.ext.tags, (tags) => {
avatar.tags.push({
avatarUrl: `/guang/star/detail?tag=${tags.tagName}&openby:yohobuy{"action":"go.h5","params":{"id":"","share":"","shareparam":{},"islogin":"N","type":0,"updateflag":"N","url":"http://m.yohobuy.com/guang/star/detail","param":{"tag":"${tags.tagName}"}}}`, // eslint-disable-line
cover: tags.cover ? (tags.cover + '?imageView2/2/w/104/h/104') : tags.cover,
cover: tags.cover ? (tags.cover + '?imageView2/2/w/104/h/104/q/80') : tags.cover,
tagName: tags.tagName
});
});
... ... @@ -103,7 +103,7 @@ const _processIndexData = (list) => {
formatData.starAvatar.push({
url: url,
cover: data.cover ? (data.cover + '?imageView2/2/w/180/h/180') : data.cover
cover: data.cover ? (data.cover + '?imageView2/2/w/180/h/180/q/80') : data.cover
});
});
}
... ... @@ -111,41 +111,24 @@ const _processIndexData = (list) => {
return formatData;
};
/**
* 明星专题列表数据处理
* 明星专题列表及星搭配数据处理
* @param {[array]} list
* @param {[boolean]} flag 明星专题列表需要转换下日期格式
* @return {[array]}
*/
const _processDetailData = (list) => {
const _processGuangData = (list, flag) => {
const formatData = [];
list = list || [];
list = camelCase(list);
_.forEach(list, (data, key) => {
data.publishTime = helpers.dateFormat('MM月DD日 hh:mm', data.publishTime);
if (key < 4) {
data.islazy = true;
if (flag) {
data.publishTime = helpers.dateFormat('MM月DD日 hh:mm', data.publishTime);
}
formatData.push(data);
});
return formatData;
};
/**
* 星搭配文章列表数据处理
*/
const _processCollocationData = (list) => {
const formatData = [];
list = list || [];
list = camelCase(list);
_.forEach(list, (data, key) => {
if (data.isFavor === 'N') {
data.isCollected = false;
} else {
... ... @@ -155,8 +138,10 @@ const _processCollocationData = (list) => {
if (key < 4) {
data.islazy = true;
}
formatData.push(data);
});
return formatData;
};
... ... @@ -181,19 +166,20 @@ const getIndexData = () => {
/**
* 明星专题
*/
const getDetailData = (params) => {
const getDetailData = (params, uid) => {
return api.get('', sign.apiSign({
method: 'app.starClass.lastTagArticle',
tag: params.tag,
page: params.page || 1,
size: 10,
uid: uid,
client_type: 'iphone'
})).then((result) => {
if (result && result.code === 200) {
if (params.page > result.data.totalPage) {
return '';
} else {
return _processDetailData(result.data.list);
return _processGuangData(result.data.list, true);
}
} else {
logger.error('明星专题文章数据返回 code 不是 200');
... ... @@ -236,7 +222,7 @@ const getCollocationListData = (params, uid) => {
uid: uid
}, params))).then((result) => {
if (result && result.code === 200) {
return _processCollocationData(result.data.list.artList);
return _processGuangData(result.data.list.artList);
} else {
logger.error('获取星搭配文章列表返回 code 不是 200');
return [];
... ... @@ -252,18 +238,18 @@ const setFavorite = (params, uid) => {
});
}
return api.get('', sign.apiSign({
method: params.type === 'del' ? 'app.sns.cancelFavorBackCount' : 'app.sns.setFavorBackCount',
client_type: 'h5',
let url = params.type === 'del' ? '/guang/api/*/favorite/cancelFavorite' : '/guang/api/*/favorite/setFavorite';
return serviceAPI.get(url, sign.apiSign({
article_id: params.articleId,
uid: uid
}));
};
module.exports = {
getIndexData: getIndexData,
getSpecialData: getSpecialData,
getCollocationListData: getCollocationListData,
setFavorite: setFavorite,
getDetailData: getDetailData
getIndexData,
getSpecialData,
getCollocationListData,
setFavorite,
getDetailData
};
... ...
... ... @@ -4,9 +4,9 @@
{{#if src}}
<a href="{{url}}">
{{#if islazy}}
<img src ="{{image src 640 310}}"/>
<img src ="{{image src 640 640}}"/>
{{else}}
<img class="lazy" src ="" data-original="{{image src 640 310}}" />
<img class="lazy" src ="" data-original="{{image src 640 640}}" />
{{/if}}
</a>
{{/if}}
... ...
... ... @@ -14,7 +14,8 @@ var $ = require('yoho-jquery'),
var $window = $(window),
stopLoading = false,
$starMain = $('.star-main');
$starMain = $('.star-main'),
$headTab = $('.head-tab');
/*
$swiperView = $('.swiper-view'),
... ... @@ -91,12 +92,11 @@ function setIndexAction() {
var starIScroll;
var $loadingTip = $('.loading-tip'),
$avatarWrap = $('.avatar-wrap:not(.avatar-clone)'),
avatarHeight = $('.avatar').height();
$avatarWrap = $('.avatar-wrap:not(.avatar-clone)');
// 下拉刷新,上拉加载
starIScroll = new PullRefresh('.star-wrap', {
height: $(window).height() - avatarHeight,
height: $(window).height() - $headTab.height(),
pullDown: function() {
if (!stopLoading) {
stopLoading = true;
... ... @@ -118,7 +118,7 @@ function setIndexAction() {
});
starIScroll.iScroll.on('scroll', function() {
if ($avatarWrap.offset().top <= 0) {
if ($avatarWrap.offset().top <= $headTab.height()) {
$avatarClone.show();
if (!avatarSwiperClone) {
... ...