Authored by 徐祁xuqi

remove deplicute keys

... ... @@ -43,6 +43,7 @@ Handlebars.registerHelper('pager', function() {
function getPageNums(ntype) {
var pageNums = [];
var num = showNum;
if (ntype === 'e') {
num = num - 2;
num = num > 2 ? num : 2;
... ... @@ -97,6 +98,7 @@ Handlebars.registerHelper('pager', function() {
function renderItem(arr) {
/** 分页展示页码个数end **/
let ret = '';
if (_.isArray(arr) && arr.length) {
arr.forEach((val) => {
... ... @@ -130,10 +132,12 @@ Handlebars.registerHelper('pager', function() {
}
let items = ALL_TYPES[type] ? ALL_TYPES[type] : type;
items = _.isArray(items) ? items : (items || ALL_TYPES.stand).split('-');
let hasPage = false; // 配置中如果配置了多次 page/pe 则将忽略,只第一次有效
let ret = `<div class="pager ${theme}">`;
items.forEach(function(val) {
switch (val) {
... ... @@ -144,12 +148,14 @@ Handlebars.registerHelper('pager', function() {
break;
case 'p' :
if (page > 1) {
ret += `<a href="${base}` + (page - 1) + '" title="上一页"><span class="iconfont">&#xe60e;</span>上一页</a>';
ret += `<a href="${base}` + (page - 1) +
'" title="上一页"><span class="iconfont">&#xe60e;</span>上一页</a>';
}
break;
case 'n' :
if (page < totalPages) {
ret += `<a href="${base}` + (page + 1) + '" title="下一页">下一页<span class="iconfont">&#xe60c;</span></a>';
ret += `<a href="${base}` + (page + 1) +
'" title="下一页">下一页<span class="iconfont">&#xe60c;</span></a>';
}
break;
case 'l' :
... ...
... ... @@ -21,20 +21,20 @@
Object.assign(app.locals, parent.locals);
});
app.set('views', path.join(__dirname, 'views/action'));
app.engine('.hbs', hbs({
extname: '.hbs',
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: [`${partials}/partial`, `${doraemon}/partial`],
helpers: global.yoho.helpers
}));
require('./helpers/json');
require('./helpers/page');
app.set('views', path.join(__dirname, 'views/action'));
app.engine('.hbs', hbs({
extname: '.hbs',
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: [`${partials}/partial`, `${doraemon}/partial`],
helpers: global.yoho.helpers
}));
require('./helpers/json');
require('./helpers/page');
// router
app.use(require('./router'));
app.use(require('./router'));
module.exports = app;
module.exports = app;
... ...
... ... @@ -105,6 +105,7 @@ const _formatArticle = (articleData, showTag, showAuthor) => {
height = 360,
isSquareImage = true;
if (articleData.conver_image_type === 2) {
width = 360;
height = 240;
... ... @@ -133,7 +134,7 @@ const _formatArticle = (articleData, showTag, showAuthor) => {
};
}
// result.author = articleData.author.name;
result.author = articleData.author.name;
let authorId = articleData.author.author_id;
... ... @@ -253,11 +254,11 @@ const getArticleList = (gender, sortId, uid, udid, page, tag, authorId, limit, u
let list = res.data.list;
if (list.artList) {
artList = _.map(list.artList, it => _formatArticle(it, true, false, uid));
artList = _.map(list.artList, it => _formatArticle(it, true, false));
}
if (list.adlist) {
adsList = _.map(list.artList, it => _formatAd(it, uid));
adsList = _.map(list.artList, it => _formatAd(it));
}
}
... ... @@ -438,7 +439,6 @@ const getArticleInfo = aid => {
}).then(res => {
if (res && res.code === 200 && res.data) {
let d = res.data;
let tags = [];
if (d.tags) {
... ... @@ -466,6 +466,7 @@ const _formatProduct = (products, arr) => {
let result = [];
_.forEach(products, val => {
let goods = {
thumb: helpers.image(val.default_images, 235, 314),
name: val.product_name,
... ... @@ -738,30 +739,28 @@ const getArticleComments = (aid, page, pageSize) => {
pageSize: pageSize
}).then(res => {
if (res && res.code === 200) {
let num = (res.data && res.data.total) || 0;
let list = [];
let num = (res.data && res.data.total) || 0;
let list = [];
if (num > 0 && res.data.list) {
let iList = res.data.list;
if (num > 0 && res.data.list) {
let iList = res.data.list;
for (let i = 0; i < iList.length; i++) {
let it = iList[i];
for (let i = 0; i < iList.length; i++) {
let it = iList[i];
list.push({
avatar: helpers.image(it.avator, 100, 100),
name: it.username,
content: it.content,
time: it.create_time
});
}
list.push({
avatar: helpers.image(it.avator, 100, 100),
name: it.username,
content: it.content,
time: it.create_time
});
}
return {
commentNum: num,
list: list
};
}
return {
commentNum: num,
list: list
};
});
};
... ...