Authored by 陈峰

merge

/**
* 市场推广
* <jing.li@yoho.cn>
* 2016/09/07
*/
'use strict';
const service = global.yoho.ServiceAPI;
const helpers = global.yoho.helpers;
const _ = require('lodash');
const index = () => {
return service.get('/operations/api/v5/resource/home', {
content_code: '5a9b5bcfd2e13d56c9ba6b867a325dc1',
gender: 1,
limit: 1000,
page: 1,
debug: 'XYZ'
}).then(result => {
let resu = {
swiper: [],
floorAdList: [],
newsList: [],
download: []
};
if (result.data.list[0]) {
let headerTip = result.data.list[0].data.text;
resu = Object.assign(resu, { headerTip });
}
if (result.data.list[1]) {
let adList = result.data.list[1].data.list;
let build = [];
adList.forEach(ad => {
build.push({
img: helpers.image(ad.src, 640, 310),
url: ad.url
});
});
resu.swiper = build;
let floorList = result.data.list[1].data.list;
let floorAdListTitle = result.data.list[1].data.title.title;
resu = _.assign(resu, { floorAdListTitle });
let floor = [];
let i = 0;
floorList.forEach(ad => {
if (i < 12) { // 控制显示条数,默认1-12
floor.push({
img: helpers.image(ad.src, 640, 170),
url: ad.url,
title: ad.title
});
i++;
}
});
resu.floorAdList = floor;
}
if (result.data.list[2]) {
let newsList = result.data.list[2].data.list[0];
let news = [{
img: helpers.image(newsList.src, 640, 370),
url: newsList.url,
title: newsList.title,
alt: newsList.alt
}];
resu.newsList = news;
}
if (result.data.list[3]) {
let downlist = result.data.list[3].data[0];
let down = [{
img: helpers.image(downlist.src, 640, 275),
url: downlist.url,
alt: downlist.alt
}];
resu.download = down;
}
return resu;
});
};
module.exports = {
index
};
... ...
... ... @@ -83,8 +83,8 @@ const _page = (req, res, next) => {
page = req.query.page,
gender = req.query.gender,
authorId = req.query.authorId,
isApp = req.query.isApp,
isTab = req.query.isTab,
isApp = req.yoho.isApp || false,
isTab = req.query.isTab || false,
showAuthor = true;
let uid = req.user.uid,
... ...
... ... @@ -38,7 +38,7 @@ const _category = () => {
return serviceAPI.get('/guang/api/v1/category/get', {
}, {
cache: true,
code: 200
});
};
... ... @@ -139,11 +139,12 @@ const _article = (param) => {
page: param.page || 1,
uid: param.uid,
udid: param.udid,
sort_id: param.type ? param.type : 1,
sort_id: param.type === 0 ? param.type : 1,
tag: param.tag ? param.tag : null,
author_id: param.authorId ? param.authorId : null,
limit: param.limit ? param.limit : null,
}, {
cache: true,
code: 200
}).then(result => {
... ... @@ -159,8 +160,8 @@ const _article = (param) => {
*/
const getArticle = (param) => {
let page = param.page ? param.page : 1;
let page = param.page ? param.page : 1;
Object.assign(param, { page: page });
return api.all([
... ... @@ -172,17 +173,16 @@ const getArticle = (param) => {
let resu = {
guang: {
swiper: true
}
};
// 顶部的分类列表
let curIndex = 0;// 当前tab顺序
let indexTmp = 0;
if (result[0] && result[0].data) {
if (result[0] && result[0].data && result[0].data) {
indexTmp = 0;
... ... @@ -219,7 +219,7 @@ const getArticle = (param) => {
}
if (result[1].data.list.adlist) {
if (result[1].data.list.adlist && result[1].data) {
let swp = [];
... ... @@ -235,11 +235,9 @@ const getArticle = (param) => {
resu.guang.swiper = swp;
// console.log(resu);
}
if (result[1].data.list.artList) {
if (result[1].data.list.artList && result[1].data) {
let inf = [];
... ... @@ -253,76 +251,17 @@ const getArticle = (param) => {
}
return resu;
});
};
/**
* 逛切换
* @param params
*/
const getArticleGroup = (param) => {
let page = param.page ? param.page : 1;
Object.assign(param, { page: page });
return api.all([
_category(),
_article(param)
]).then(result => {
let type = param.type;
let resu = {
guang: {
}
};
if (result[0] && result[0].data) {
let cateList = result[0].data;
let build = [];
let inf = [];
cateList.forEach(val => {
build.push({
typeId: val.id,
type: val.name,
focus: (val.id == type)
});
inf.push({
show: (val.id == type),
typeId: type,
info: []
});
resu.guang.navs = build;
resu.guang.infos = inf;
});
}
// console.log(resu);
return resu;
});
};
module.exports = {
getAuthor: _getAuthor,
getArticleList: _getArticleList,
getPageData: _getPageData,
getArticle,
getArticleGroup
getArticle
};
... ...
... ... @@ -16,14 +16,14 @@
{{#if ../swiper}}
<div class="swiper-container swiper-cont-{{typeId}}">
<div class="swiper-wrapper swiper-wrap-{{typeId}}">
{{# swiper}}
{{# ../swiper}}
<div class="swiper-slide">
<a href="{{url}}">
<img class="swiper-lazy" data-src="{{img}}">
</a>
<div class="swiper-lazy-preloader"></div>
</div>
{{/ swiper}}
{{/ ../swiper}}
</div>
<div class="swiper-pagination swiper-pagi-{{typeId}}"></div>
</div>
... ...
... ... @@ -49,6 +49,8 @@ info.initInfosEvt($infoList);
end: false
};
});
console.log(state);
}());
$nav.bind('contextmenu', function(e) {
return false;
... ...