Authored by biao

Merge branch 'feature/index' into develop

@@ -14,3 +14,9 @@ exports.boysIndex = (req, res) => { @@ -14,3 +14,9 @@ exports.boysIndex = (req, res) => {
14 res.render('boys', data); 14 res.render('boys', data);
15 }); 15 });
16 }; 16 };
  17 +
  18 +exports.getbrandFloorDataAjax = (req, res) => {
  19 + channelModel.getbrandFloorDataAjax('boys').then(data => {
  20 + res.json(data);
  21 + });
  22 +};
@@ -9,6 +9,8 @@ const _ = require('lodash'); @@ -9,6 +9,8 @@ const _ = require('lodash');
9 9
10 const ServiceAPI = require(`${global.library}/api`).ServiceAPI; 10 const ServiceAPI = require(`${global.library}/api`).ServiceAPI;
11 const sign = require(`${global.library}/sign`); 11 const sign = require(`${global.library}/sign`);
  12 +const helpers = require(`${global.library}/helpers`);
  13 +
12 14
13 const serviceApi = new ServiceAPI(); 15 const serviceApi = new ServiceAPI();
14 16
@@ -137,6 +139,30 @@ const getNewReportFloorData = args => { @@ -137,6 +139,30 @@ const getNewReportFloorData = args => {
137 return floorDatas; 139 return floorDatas;
138 }; 140 };
139 141
  142 +// 优选品牌
  143 +const getPreBrandTopData = args => {
  144 + let item = args[0].data;
  145 +
  146 + const data = {
  147 + preferenceBrands: {
  148 + name: '优选品牌',
  149 + imgBrand: [],
  150 + brandUrl: helpers.urlFormat('getbrandFloorDataAjax')
  151 + }
  152 + };
  153 +
  154 + _.forEach(item, (topData) => {
  155 + let o = {};
  156 +
  157 + o.href = topData.url;
  158 + o.img = topData.src;
  159 +
  160 + data.preferenceBrands.imgBrand.push(o);
  161 + });
  162 +
  163 + return data;
  164 +};
  165 +
140 // 热门品类 166 // 热门品类
141 const getHotGoodsFloorData = (args) => { 167 const getHotGoodsFloorData = (args) => {
142 let item = args[0]; 168 let item = args[0];
@@ -266,8 +292,8 @@ const getSingleHotFloorData = args => { @@ -266,8 +292,8 @@ const getSingleHotFloorData = args => {
266 const requestContent = type => { 292 const requestContent = type => {
267 293
268 let data = sign.apiSign({ 294 let data = sign.apiSign({
269 - /* eslint-disable */  
270 - client_type: 'web', 295 + /* eslint-disable */
  296 + client_type: 'web',
271 /* eslint-enable */ 297 /* eslint-enable */
272 content_code: channelMap[type || 'boys'].code, 298 content_code: channelMap[type || 'boys'].code,
273 gender: channelMap[type || 'boys'].gender, 299 gender: channelMap[type || 'boys'].gender,
@@ -283,6 +309,7 @@ const floorMap = { @@ -283,6 +309,7 @@ const floorMap = {
283 hot: getHotGoodsFloorData, 309 hot: getHotGoodsFloorData,
284 最新速报: getNewReportFloorData, 310 最新速报: getNewReportFloorData,
285 人气单品: getSingleHotFloorData, 311 人气单品: getSingleHotFloorData,
  312 + 优选品牌: getPreBrandTopData,
286 ad: getadbannerData 313 ad: getadbannerData
287 }; 314 };
288 315
@@ -335,3 +362,31 @@ exports.getContent = type => { @@ -335,3 +362,31 @@ exports.getContent = type => {
335 } 362 }
336 }); 363 });
337 }; 364 };
  365 +
  366 +
  367 +// 优选品牌楼层floorData-ajax
  368 +exports.getbrandFloorDataAjax = type => {
  369 + return requestContent(type).then(res => {
  370 + if (res.code === 200) {
  371 + let contentData = res.data.list;
  372 +
  373 + let data = {
  374 + logoBrand: [],
  375 + moreBrand: ''
  376 + };
  377 +
  378 + _.forEach(contentData[6].data, (floorData) => {
  379 + let o = {};
  380 +
  381 + o.href = floorData.url;
  382 + o.img = helpers.image(floorData.src, 185, 86, 2);
  383 +
  384 + data.logoBrand.push(o);
  385 + });
  386 +
  387 + data.moreBrand = contentData[7].data[0].url;
  388 +
  389 + return data;
  390 + }
  391 + });
  392 +};
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 6
7 'use strict'; 7 'use strict';
8 8
9 -const router = require('express').Router(); // eslint-disable-line 9 +const router = require('express').Router(); // eslint-disable-line
10 const cRoot = './controllers'; 10 const cRoot = './controllers';
11 11
12 // Your controller here 12 // Your controller here
@@ -14,4 +14,6 @@ const channelController = require(`${cRoot}/index`); @@ -14,4 +14,6 @@ const channelController = require(`${cRoot}/index`);
14 14
15 router.get('/boys', channelController.boysIndex); 15 router.get('/boys', channelController.boysIndex);
16 16
  17 +router.get('/getbrandFloorDataAjax', channelController.getbrandFloorDataAjax);
  18 +
17 module.exports = router; 19 module.exports = router;
@@ -42,7 +42,7 @@ @@ -42,7 +42,7 @@
42 {{! 优选品牌}} 42 {{! 优选品牌}}
43 {{# preferenceBrands}} 43 {{# preferenceBrands}}
44 <div class="preference-brand"> 44 <div class="preference-brand">
45 - {{> index/floor-header}} 45 + {{> floor-header}}
46 <div class="img-brand"> 46 <div class="img-brand">
47 <ul class="img-list imgopacity clearfix"> 47 <ul class="img-list imgopacity clearfix">
48 {{# imgBrand}} 48 {{# imgBrand}}
@@ -68,7 +68,7 @@ @@ -68,7 +68,7 @@
68 68
69 {{! 单品/广告}} 69 {{! 单品/广告}}
70 {{# singlehot}} 70 {{# singlehot}}
71 - {{> index/boy-singlehot}} 71 + {{> boy-singlehot}}
72 {{/ singlehot}} 72 {{/ singlehot}}
73 73
74 {{! 广告}} 74 {{! 广告}}
@@ -80,13 +80,13 @@ @@ -80,13 +80,13 @@
80 80
81 {{! 品类推荐}} 81 {{! 品类推荐}}
82 {{# recommend}} 82 {{# recommend}}
83 - {{> index/boy-recommend}} 83 + {{> boy-recommend}}
84 {{/ recommend}} 84 {{/ recommend}}
85 85
86 86
87 {{! 新品上架}} 87 {{! 新品上架}}
88 {{# newArrivls}} 88 {{# newArrivls}}
89 - {{> index/commodity}} 89 + {{> commodity}}
90 {{/ newArrivls}} 90 {{/ newArrivls}}
91 {{/ channel}} 91 {{/ channel}}
92 </div> 92 </div>
1 {{# tplrecommend}} 1 {{# tplrecommend}}
2 <div class="tpl-recommend clearfix"> 2 <div class="tpl-recommend clearfix">
3 - {{> index/floor-header}} 3 + {{> floor-header}}
4 <div class="tpl-body clearfix"> 4 <div class="tpl-body clearfix">
5 <div class="tpl-nav"> 5 <div class="tpl-nav">
6 <div class="tpl-keywords"> 6 <div class="tpl-keywords">
1 <div class="singlehot clearfix"> 1 <div class="singlehot clearfix">
2 - {{> index/floor-header}} 2 + {{> floor-header}}
3 <ul class="g-list imgopacity"> 3 <ul class="g-list imgopacity">
4 - {{#each imgHot}} 4 + {{#each imgHot}}
5 {{#if @last}} 5 {{#if @last}}
6 <li><a class="impo{{@index}}" href="{{href}}" target= "_blank"><img class="lazy" src="{{image img 378 248}}"/></a></li> 6 <li><a class="impo{{@index}}" href="{{href}}" target= "_blank"><img class="lazy" src="{{image img 378 248}}"/></a></li>
7 {{^}} 7 {{^}}
1 -<div class="floor-header clearfix">  
2 - <h2 class="floor-title">{{name}}</h2>  
3 -  
4 - <ul class="header-navs">  
5 -  
6 - <li data-classify="s">  
7 - <a target="_blank" href="">sss</a>  
8 - </li>  
9 -  
10 - </ul>  
11 -  
12 -</div>  
1 -/**  
2 - * index controller  
3 - * @author: 赵彪<bill.zhao@yoho.cn>  
4 - * @date: 2016/05/03  
5 - */  
6 -  
7 -'use strict';  
8 -  
9 -const headerModel = require('../../../doraemon/models/header');  
10 -  
11 -exports.index = (req, res) => {  
12 - headerModel.requestHeaderData()  
13 - .then(response => {  
14 - let data = headerModel.setHeaderData(response.data, 'boys');  
15 -  
16 - data.module = 'index';  
17 - data.page = 'index';  
18 - data.footerTop = true;  
19 -  
20 - res.render('index', data);  
21 - })  
22 - .catch(() => {  
23 - res.render('index', {devEnv: true, pageErr: true});  
24 - });  
25 -};  
1 -/**  
2 - * sub app index  
3 - * @author: yyqing<yanqing.yang@yoho.cn>  
4 - * @date: 2016/05/03  
5 - */  
6 -  
7 -var express = require('express'),  
8 - path = require('path'),  
9 - hbs = require('express-handlebars');  
10 -  
11 -var app = express();  
12 -  
13 -// set view engin  
14 -var doraemon = path.join(__dirname, '../../doraemon/views'); // parent view root  
15 -  
16 -app.set('views', path.join(__dirname, 'views/action'));  
17 -app.engine('.hbs', hbs({  
18 - extname: '.hbs',  
19 - defaultLayout: 'layout',  
20 - layoutsDir: doraemon,  
21 - partialsDir: ['./views/partial', `${doraemon}/partial`],  
22 - helpers: 'helpers'  
23 -}));  
24 -  
25 -// router  
26 -app.use(require('./router'));  
27 -  
28 -module.exports = app;  
1 -/**  
2 - * router of sub app index  
3 - * @author: yyqing<yanqing.yang@yoho.cn>  
4 - * @date: 2016/05/03  
5 - */  
6 -  
7 -'use strict';  
8 -  
9 -const express = require('express');  
10 -const router = express.Router(); // eslint-disable-line  
11 -const cRoot = './controllers';  
12 -  
13 -const homeController = require(`${cRoot}/index`);  
14 -  
15 -// Your controller here  
16 -router.get('/', homeController.index);  
17 -  
18 -module.exports = router;  
1 -<div class="yoho-page center-content">  
2 - <p>body</p>  
3 -</div>  
@@ -11,6 +11,7 @@ const isTest = process.env.NODE_ENV === 'test'; @@ -11,6 +11,7 @@ const isTest = process.env.NODE_ENV === 'test';
11 11
12 module.exports = { 12 module.exports = {
13 port: 6002, 13 port: 6002,
  14 + siteUrl: 'http://localhost:6002/',
14 domains: { 15 domains: {
15 api: 'http://192.168.102.205:8080/gateway/', 16 api: 'http://192.168.102.205:8080/gateway/',
16 service: 'http://testservice.yoho.cn:28077/', 17 service: 'http://testservice.yoho.cn:28077/',
1 -<div class="floor-header clearfix">  
2 - <h2 class="floor-title">{{name}}</h2>  
3 - {{#if navs}}  
4 - <ul class="header-navs">  
5 - {{# navs}}  
6 - <li data-classify="{{id}}">  
7 - <a target="_blank" href="{{href}}">{{name}}</a>  
8 - </li>  
9 - {{/ navs}}  
10 - </ul>  
11 - {{/if}}  
12 -</div>  
1 -require('../common');