Authored by 陈峰

merge

  1 +/**
  2 + * 市场推广
  3 + * <jing.li@yoho.cn>
  4 + * 2016/09/07
  5 + */
  6 +
  7 +'use strict';
  8 +const service = global.yoho.ServiceAPI;
  9 +const helpers = global.yoho.helpers;
  10 +const _ = require('lodash');
  11 +const index = () => {
  12 +
  13 + return service.get('/operations/api/v5/resource/home', {
  14 + content_code: '5a9b5bcfd2e13d56c9ba6b867a325dc1',
  15 + gender: 1,
  16 + limit: 1000,
  17 + page: 1,
  18 + debug: 'XYZ'
  19 + }).then(result => {
  20 +
  21 + let resu = {
  22 + swiper: [],
  23 + floorAdList: [],
  24 + newsList: [],
  25 + download: []
  26 + };
  27 +
  28 + if (result.data.list[0]) {
  29 +
  30 + let headerTip = result.data.list[0].data.text;
  31 +
  32 + resu = Object.assign(resu, { headerTip });
  33 +
  34 + }
  35 +
  36 + if (result.data.list[1]) {
  37 +
  38 + let adList = result.data.list[1].data.list;
  39 +
  40 + let build = [];
  41 +
  42 + adList.forEach(ad => {
  43 + build.push({
  44 + img: helpers.image(ad.src, 640, 310),
  45 + url: ad.url
  46 + });
  47 + });
  48 +
  49 + resu.swiper = build;
  50 +
  51 + let floorList = result.data.list[1].data.list;
  52 +
  53 + let floorAdListTitle = result.data.list[1].data.title.title;
  54 +
  55 + resu = _.assign(resu, { floorAdListTitle });
  56 +
  57 + let floor = [];
  58 +
  59 + let i = 0;
  60 +
  61 + floorList.forEach(ad => {
  62 + if (i < 12) { // 控制显示条数,默认1-12
  63 + floor.push({
  64 + img: helpers.image(ad.src, 640, 170),
  65 + url: ad.url,
  66 + title: ad.title
  67 + });
  68 + i++;
  69 + }
  70 + });
  71 +
  72 + resu.floorAdList = floor;
  73 +
  74 + }
  75 +
  76 + if (result.data.list[2]) {
  77 +
  78 + let newsList = result.data.list[2].data.list[0];
  79 +
  80 + let news = [{
  81 + img: helpers.image(newsList.src, 640, 370),
  82 + url: newsList.url,
  83 + title: newsList.title,
  84 + alt: newsList.alt
  85 + }];
  86 +
  87 + resu.newsList = news;
  88 +
  89 + }
  90 +
  91 + if (result.data.list[3]) {
  92 +
  93 + let downlist = result.data.list[3].data[0];
  94 +
  95 + let down = [{
  96 + img: helpers.image(downlist.src, 640, 275),
  97 + url: downlist.url,
  98 + alt: downlist.alt
  99 + }];
  100 +
  101 + resu.download = down;
  102 +
  103 + }
  104 +
  105 + return resu;
  106 +
  107 + });
  108 +
  109 +};
  110 +
  111 +module.exports = {
  112 + index
  113 +};
@@ -83,8 +83,8 @@ const _page = (req, res, next) => { @@ -83,8 +83,8 @@ const _page = (req, res, next) => {
83 page = req.query.page, 83 page = req.query.page,
84 gender = req.query.gender, 84 gender = req.query.gender,
85 authorId = req.query.authorId, 85 authorId = req.query.authorId,
86 - isApp = req.query.isApp,  
87 - isTab = req.query.isTab, 86 + isApp = req.yoho.isApp || false,
  87 + isTab = req.query.isTab || false,
88 showAuthor = true; 88 showAuthor = true;
89 89
90 let uid = req.user.uid, 90 let uid = req.user.uid,
@@ -38,7 +38,7 @@ const _category = () => { @@ -38,7 +38,7 @@ const _category = () => {
38 return serviceAPI.get('/guang/api/v1/category/get', { 38 return serviceAPI.get('/guang/api/v1/category/get', {
39 39
40 }, { 40 }, {
41 - 41 + cache: true,
42 code: 200 42 code: 200
43 }); 43 });
44 }; 44 };
@@ -139,11 +139,12 @@ const _article = (param) => { @@ -139,11 +139,12 @@ const _article = (param) => {
139 page: param.page || 1, 139 page: param.page || 1,
140 uid: param.uid, 140 uid: param.uid,
141 udid: param.udid, 141 udid: param.udid,
142 - sort_id: param.type ? param.type : 1, 142 + sort_id: param.type === 0 ? param.type : 1,
143 tag: param.tag ? param.tag : null, 143 tag: param.tag ? param.tag : null,
144 author_id: param.authorId ? param.authorId : null, 144 author_id: param.authorId ? param.authorId : null,
145 limit: param.limit ? param.limit : null, 145 limit: param.limit ? param.limit : null,
146 }, { 146 }, {
  147 + cache: true,
147 code: 200 148 code: 200
148 }).then(result => { 149 }).then(result => {
149 150
@@ -159,8 +160,8 @@ const _article = (param) => { @@ -159,8 +160,8 @@ const _article = (param) => {
159 */ 160 */
160 const getArticle = (param) => { 161 const getArticle = (param) => {
161 162
162 - let page = param.page ? param.page : 1;  
163 163
  164 + let page = param.page ? param.page : 1;
164 Object.assign(param, { page: page }); 165 Object.assign(param, { page: page });
165 166
166 return api.all([ 167 return api.all([
@@ -172,17 +173,16 @@ const getArticle = (param) => { @@ -172,17 +173,16 @@ const getArticle = (param) => {
172 173
173 let resu = { 174 let resu = {
174 guang: { 175 guang: {
175 - swiper: true 176 +
176 } 177 }
177 }; 178 };
178 179
179 -  
180 // 顶部的分类列表 180 // 顶部的分类列表
181 let curIndex = 0;// 当前tab顺序 181 let curIndex = 0;// 当前tab顺序
182 182
183 let indexTmp = 0; 183 let indexTmp = 0;
184 184
185 - if (result[0] && result[0].data) { 185 + if (result[0] && result[0].data && result[0].data) {
186 186
187 indexTmp = 0; 187 indexTmp = 0;
188 188
@@ -219,7 +219,7 @@ const getArticle = (param) => { @@ -219,7 +219,7 @@ const getArticle = (param) => {
219 219
220 } 220 }
221 221
222 - if (result[1].data.list.adlist) { 222 + if (result[1].data.list.adlist && result[1].data) {
223 223
224 let swp = []; 224 let swp = [];
225 225
@@ -235,11 +235,9 @@ const getArticle = (param) => { @@ -235,11 +235,9 @@ const getArticle = (param) => {
235 235
236 resu.guang.swiper = swp; 236 resu.guang.swiper = swp;
237 237
238 - // console.log(resu);  
239 -  
240 } 238 }
241 239
242 - if (result[1].data.list.artList) { 240 + if (result[1].data.list.artList && result[1].data) {
243 241
244 let inf = []; 242 let inf = [];
245 243
@@ -253,76 +251,17 @@ const getArticle = (param) => { @@ -253,76 +251,17 @@ const getArticle = (param) => {
253 251
254 } 252 }
255 253
256 - return resu;  
257 - });  
258 -  
259 -};  
260 -  
261 -/**  
262 - * 逛切换  
263 - * @param params  
264 - */  
265 -const getArticleGroup = (param) => {  
266 -  
267 - let page = param.page ? param.page : 1;  
268 -  
269 - Object.assign(param, { page: page });  
270 -  
271 - return api.all([  
272 - _category(),  
273 - _article(param)  
274 - ]).then(result => {  
275 -  
276 - let type = param.type;  
277 -  
278 - let resu = {  
279 - guang: {  
280 -  
281 - }  
282 - };  
283 -  
284 - if (result[0] && result[0].data) {  
285 -  
286 - let cateList = result[0].data;  
287 -  
288 - let build = [];  
289 -  
290 - let inf = [];  
291 -  
292 - cateList.forEach(val => {  
293 - build.push({  
294 - typeId: val.id,  
295 - type: val.name,  
296 - focus: (val.id == type)  
297 - });  
298 -  
299 - inf.push({  
300 - show: (val.id == type),  
301 - typeId: type,  
302 - info: []  
303 - });  
304 -  
305 -  
306 -  
307 - resu.guang.navs = build;  
308 -  
309 - resu.guang.infos = inf;  
310 -  
311 - });  
312 -  
313 - }  
314 - 254 + // console.log(resu);
315 255
316 return resu; 256 return resu;
  257 +
317 }); 258 });
318 259
319 }; 260 };
320 261
321 -  
322 module.exports = { 262 module.exports = {
323 getAuthor: _getAuthor, 263 getAuthor: _getAuthor,
324 getArticleList: _getArticleList, 264 getArticleList: _getArticleList,
325 getPageData: _getPageData, 265 getPageData: _getPageData,
326 - getArticle,  
327 - getArticleGroup 266 + getArticle
328 }; 267 };
@@ -16,14 +16,14 @@ @@ -16,14 +16,14 @@
16 {{#if ../swiper}} 16 {{#if ../swiper}}
17 <div class="swiper-container swiper-cont-{{typeId}}"> 17 <div class="swiper-container swiper-cont-{{typeId}}">
18 <div class="swiper-wrapper swiper-wrap-{{typeId}}"> 18 <div class="swiper-wrapper swiper-wrap-{{typeId}}">
19 - {{# swiper}} 19 + {{# ../swiper}}
20 <div class="swiper-slide"> 20 <div class="swiper-slide">
21 <a href="{{url}}"> 21 <a href="{{url}}">
22 <img class="swiper-lazy" data-src="{{img}}"> 22 <img class="swiper-lazy" data-src="{{img}}">
23 </a> 23 </a>
24 <div class="swiper-lazy-preloader"></div> 24 <div class="swiper-lazy-preloader"></div>
25 </div> 25 </div>
26 - {{/ swiper}} 26 + {{/ ../swiper}}
27 </div> 27 </div>
28 <div class="swiper-pagination swiper-pagi-{{typeId}}"></div> 28 <div class="swiper-pagination swiper-pagi-{{typeId}}"></div>
29 </div> 29 </div>
@@ -49,6 +49,8 @@ info.initInfosEvt($infoList); @@ -49,6 +49,8 @@ info.initInfosEvt($infoList);
49 end: false 49 end: false
50 }; 50 };
51 }); 51 });
  52 +
  53 + console.log(state);
52 }()); 54 }());
53 $nav.bind('contextmenu', function(e) { 55 $nav.bind('contextmenu', function(e) {
54 return false; 56 return false;