Authored by 郝肖肖

tab 接口数据

@@ -12,32 +12,46 @@ const plusstarModel = require(`${mRoot}/plusstar`); @@ -12,32 +12,46 @@ const plusstarModel = require(`${mRoot}/plusstar`);
12 /** 12 /**
13 * 潮流优选首页 13 * 潮流优选首页
14 */ 14 */
15 -let index = (req, res) => {  
16 - let data = [  
17 - {  
18 - 'bgColor': '',  
19 - 'src': 'http://img12.static.yhbimg.com/yhb-img01/2016/04/18/06/02f043ae44ccf0e49fdddd7db39649a889.jpg?imageView2/{mode}/w/{width}/h/{height}',  
20 - 'title': '11111',  
21 - 'url': 'http://cdn.yoho.cn/huodong/0418SALEGIRL/index.html?title=IN季精选&share_id=832'  
22 - }, {  
23 - 'bgColor': '',  
24 - 'src': 'http://img12.static.yhbimg.com/yhb-img01/2016/04/18/06/02f043ae44ccf0e49fdddd7db39649a889.jpg?imageView2/{mode}/w/{width}/h/{height}',  
25 - 'title': '2222',  
26 - 'url': 'http://cdn.yoho.cn/huodong/0418SALEGIRL/index.html?title=IN季精选&share_id=832'  
27 - }, {  
28 - 'bgColor': '',  
29 - 'src': 'http://img12.static.yhbimg.com/yhb-img01/2016/04/18/06/02f043ae44ccf0e49fdddd7db39649a889.jpg?imageView2/{mode}/w/{width}/h/{height}',  
30 - 'title': '33333',  
31 - 'url': 'http://cdn.yoho.cn/huodong/0418SALEGIRL/index.html?title=IN季精选&share_id=832'  
32 - }  
33 - ];  
34 - res.render('plusstar/index', {  
35 - page: 'plusstar-index',  
36 - data: data,  
37 - title: '潮流优选'  
38 - }); 15 +exports.index = (req, res, next) => {
  16 + plusstarModel.getAllChannels({}).then(result => {
  17 + res.render('plusstar/index', {
  18 + page: 'plusstar-index',
  19 + result: result,
  20 + title: '潮流优选'
  21 + });
  22 + }).catch(next);
39 }; 23 };
40 24
41 -module.exports = {  
42 - index 25 +/**
  26 + * 潮流优选首页-资源位
  27 + */
  28 +exports.resources = (req, res, next) => {
  29 + let code = req.query.code || '';
  30 +
  31 + // let data = [{
  32 + // 'bgColor': '',
  33 + // 'src': 'http://img12.static.yhbimg.com/yhb-img01/2016/04/18/06/02f043ae44ccf0e49fdddd7db39649a889.jpg?imageView2/{mode}/w/{width}/h/{height}',
  34 + // 'title': '11111',
  35 + // 'url': 'http://cdn.yoho.cn/huodong/0418SALEGIRL/index.html?title=IN季精选&share_id=832'
  36 + // }, {
  37 + // 'bgColor': '',
  38 + // 'src': 'http://img12.static.yhbimg.com/yhb-img01/2016/04/18/06/02f043ae44ccf0e49fdddd7db39649a889.jpg?imageView2/{mode}/w/{width}/h/{height}',
  39 + // 'title': '2222',
  40 + // 'url': 'http://cdn.yoho.cn/huodong/0418SALEGIRL/index.html?title=IN季精选&share_id=832'
  41 + // }, {
  42 + // 'bgColor': '',
  43 + // 'src': 'http://img12.static.yhbimg.com/yhb-img01/2016/04/18/06/02f043ae44ccf0e49fdddd7db39649a889.jpg?imageView2/{mode}/w/{width}/h/{height}',
  44 + // 'title': '33333',
  45 + // 'url': 'http://cdn.yoho.cn/huodong/0418SALEGIRL/index.html?title=IN季精选&share_id=832'
  46 + // }
  47 + // ];
  48 + plusstarModel.getResources({
  49 + content_code: code
  50 + }).then(result => {
  51 + res.render('plusstar/index', {
  52 + page: 'plusstar-index',
  53 + result: result,
  54 + title: '潮流优选'
  55 + });
  56 + }).catch(next);
43 }; 57 };
1 'use strict'; 1 'use strict';
2 const api = global.yoho.API; 2 const api = global.yoho.API;
  3 +const serviceAPI = global.yoho.ServiceAPI;
3 const camelCase = global.yoho.camelCase; 4 const camelCase = global.yoho.camelCase;
4 const _ = require('lodash'); 5 const _ = require('lodash');
  6 +const logger = global.yoho.logger;
  7 +const helpers = global.yoho.helpers;
5 8
6 /** 9 /**
7 - * 获取分享页面列表数据  
8 - * @param {[int]} uid 用户id  
9 - * @param {[int]} activityId 活动id 10 + * 获取潮流优选tab
10 * @return {[array]} 11 * @return {[array]}
11 */ 12 */
12 -const index = (params) => { 13 +const getAllChannels = (params) => {
13 params = params || {}; 14 params = params || {};
14 15
15 return api.get('', Object.assign({ 16 return api.get('', Object.assign({
16 - method: 'wap.invite.index'  
17 - }, params)).then((result) => {  
18 - return Object.assign(camelCase(result)); 17 + method: 'app.blk.getAllChannels'
  18 + }, params)).then(result => {
  19 + let data = {channel: []};
  20 +
  21 + if (result.code !== 200) {
  22 + return data;
  23 + }
  24 +
  25 + _.forEach(result.data, (res, index) => {
  26 + data.channel.push({
  27 + id: res.channel_id,
  28 + mame: res.channel_name,
  29 + code: res.content_code,
  30 + focus: index === 0 ? true : false
  31 + });
  32 + });
  33 +
  34 + return data;
19 }); 35 });
20 }; 36 };
21 37
  38 +/**
  39 + * 获取资源位数据
  40 + * @param {[string]} content_code
  41 + * @return {[array]}
  42 + */
  43 +const getResources = (params) => {
  44 + params = params || {};
  45 +
  46 + return serviceAPI.get(
  47 + 'operations/api/v5/resource/get',
  48 + Object.assign(params)
  49 + ).then(result => {
  50 + let data = {};
  51 + let list = {};
  52 +
  53 + if (result.code !== 200) {
  54 + return data2;
  55 + }
  56 +
  57 + _.forEach(result.data, (res, index) => {
  58 + list = {};
  59 + switch (res.template_name) {
  60 + case 'focus':
  61 + list = {
  62 + data: res.data
  63 + };
  64 +
  65 + if (res.focus_type == 1) {
  66 + data.focus1 = list;
  67 + } else {
  68 + data.focus2 = list;
  69 + }
  70 +
  71 + break;
  72 + case 'title_image':
  73 + if (typeof data[res.template_name] === 'undefined') {
  74 + data[res.template_name] = [];
  75 + }
  76 +
  77 +
  78 + list = {
  79 + title: res.data.title,
  80 + moreUrl: res.data.more_url,
  81 + moreName: res.data.more_name,
  82 + image: res.data.image
  83 + };
  84 +
  85 + data.title_image.push(list);
  86 + break;
  87 + case 'titleFloor':
  88 + list = {
  89 + title: res.data.title.more_name,
  90 + more_url: res.data.more_url,
  91 + more_name: res.data.more_name,
  92 + data: res.data.image
  93 + };
  94 + data[res.template_name].push(list);
  95 + break;
  96 + case 'recommend_content_five':
  97 + break;
  98 + case 'goods':
  99 + break;
  100 + }
  101 + });
  102 +
  103 + // console.log(data, '=data===');
  104 + return data2;
  105 +});
  106 +};
  107 +
22 module.exports = { 108 module.exports = {
23 - index 109 + getAllChannels,
  110 + getResources
24 }; 111 };
@@ -24,5 +24,6 @@ router.get('/star/collocation/list', star.collocationList); // 星潮教室星æ @@ -24,5 +24,6 @@ router.get('/star/collocation/list', star.collocationList); // 星潮教室星æ
24 router.post('/star/setFavorite', star.setFavorite); // 收藏文章 24 router.post('/star/setFavorite', star.setFavorite); // 收藏文章
25 25
26 router.get('/plusstar', plusstar.index); // 潮流优选 26 router.get('/plusstar', plusstar.index); // 潮流优选
  27 +router.get('/plusstar/resources', plusstar.resources); // 潮流优选首页-资源位
27 28
28 module.exports = router; 29 module.exports = router;
1 <div class='plusstar-page'> 1 <div class='plusstar-page'>
2 -  
3 - <div class="tab-nav">  
4 - <ul>  
5 - <li class='focus'>  
6 - <span>MEN男士</span>  
7 - </li>  
8 - <li>  
9 - <span>WOMEN女士</span>  
10 - </li>  
11 - <li>  
12 - <span>LIFESTYLE生活</span>  
13 - </li>  
14 - </ul>  
15 - </div> 2 + {{#if result.channel}}
  3 + <div class="tab-nav">
  4 + <ul>
  5 + {{#each result.channel}}
  6 + <li class='{{#if focus}} focus {{/if}}' data-code='{{code}}'>
  7 + <span>{{mame}}</span>
  8 + </li>
  9 + {{/each}}
  10 + </ul>
  11 + </div>
  12 + {{/if}}
16 <!--/tab-nav--> 13 <!--/tab-nav-->
17 14
18 <div class="resources"> 15 <div class="resources">
@@ -18,8 +18,11 @@ module.exports = { @@ -18,8 +18,11 @@ module.exports = {
18 // api: 'http://devapi.yoho.cn:58078/', 18 // api: 'http://devapi.yoho.cn:58078/',
19 // service: 'http://devservice.yoho.cn:58077/' 19 // service: 'http://devservice.yoho.cn:58077/'
20 20
21 - api: 'http://testapi.yoho.cn:28078/',  
22 - service: 'http://testservice.yoho.cn:28077/' 21 + // api: 'http://testapi.yoho.cn:28078/',
  22 + // service: 'http://testservice.yoho.cn:28077/'
  23 +
  24 + api: 'http://dev-api.yohops.com:9999/',
  25 + service: 'http://dev-service.yohops.com:9999/'
23 }, 26 },
24 subDomains: { 27 subDomains: {
25 host: '.m.yohobuy.com', 28 host: '.m.yohobuy.com',