Authored by biao

Merge branch 'feature/index' into develop

... ... @@ -14,3 +14,9 @@ exports.boysIndex = (req, res) => {
res.render('boys', data);
});
};
exports.getbrandFloorDataAjax = (req, res) => {
channelModel.getbrandFloorDataAjax('boys').then(data => {
res.json(data);
});
};
... ...
... ... @@ -9,6 +9,8 @@ const _ = require('lodash');
const ServiceAPI = require(`${global.library}/api`).ServiceAPI;
const sign = require(`${global.library}/sign`);
const helpers = require(`${global.library}/helpers`);
const serviceApi = new ServiceAPI();
... ... @@ -137,6 +139,30 @@ const getNewReportFloorData = args => {
return floorDatas;
};
// 优选品牌
const getPreBrandTopData = args => {
let item = args[0].data;
const data = {
preferenceBrands: {
name: '优选品牌',
imgBrand: [],
brandUrl: helpers.urlFormat('getbrandFloorDataAjax')
}
};
_.forEach(item, (topData) => {
let o = {};
o.href = topData.url;
o.img = topData.src;
data.preferenceBrands.imgBrand.push(o);
});
return data;
};
// 热门品类
const getHotGoodsFloorData = (args) => {
let item = args[0];
... ... @@ -266,8 +292,8 @@ const getSingleHotFloorData = args => {
const requestContent = type => {
let data = sign.apiSign({
/* eslint-disable */
client_type: 'web',
/* eslint-disable */
client_type: 'web',
/* eslint-enable */
content_code: channelMap[type || 'boys'].code,
gender: channelMap[type || 'boys'].gender,
... ... @@ -283,6 +309,7 @@ const floorMap = {
hot: getHotGoodsFloorData,
最新速报: getNewReportFloorData,
人气单品: getSingleHotFloorData,
优选品牌: getPreBrandTopData,
ad: getadbannerData
};
... ... @@ -335,3 +362,31 @@ exports.getContent = type => {
}
});
};
// 优选品牌楼层floorData-ajax
exports.getbrandFloorDataAjax = type => {
return requestContent(type).then(res => {
if (res.code === 200) {
let contentData = res.data.list;
let data = {
logoBrand: [],
moreBrand: ''
};
_.forEach(contentData[6].data, (floorData) => {
let o = {};
o.href = floorData.url;
o.img = helpers.image(floorData.src, 185, 86, 2);
data.logoBrand.push(o);
});
data.moreBrand = contentData[7].data[0].url;
return data;
}
});
};
... ...
... ... @@ -6,7 +6,7 @@
'use strict';
const router = require('express').Router(); // eslint-disable-line
const router = require('express').Router(); // eslint-disable-line
const cRoot = './controllers';
// Your controller here
... ... @@ -14,4 +14,6 @@ const channelController = require(`${cRoot}/index`);
router.get('/boys', channelController.boysIndex);
router.get('/getbrandFloorDataAjax', channelController.getbrandFloorDataAjax);
module.exports = router;
... ...
... ... @@ -42,7 +42,7 @@
{{! 优选品牌}}
{{# preferenceBrands}}
<div class="preference-brand">
{{> index/floor-header}}
{{> floor-header}}
<div class="img-brand">
<ul class="img-list imgopacity clearfix">
{{# imgBrand}}
... ... @@ -68,7 +68,7 @@
{{! 单品/广告}}
{{# singlehot}}
{{> index/boy-singlehot}}
{{> boy-singlehot}}
{{/ singlehot}}
{{! 广告}}
... ... @@ -80,13 +80,13 @@
{{! 品类推荐}}
{{# recommend}}
{{> index/boy-recommend}}
{{> boy-recommend}}
{{/ recommend}}
{{! 新品上架}}
{{# newArrivls}}
{{> index/commodity}}
{{> commodity}}
{{/ newArrivls}}
{{/ channel}}
</div>
... ...
{{# tplrecommend}}
<div class="tpl-recommend clearfix">
{{> index/floor-header}}
{{> floor-header}}
<div class="tpl-body clearfix">
<div class="tpl-nav">
<div class="tpl-keywords">
... ...
<div class="singlehot clearfix">
{{> index/floor-header}}
{{> floor-header}}
<ul class="g-list imgopacity">
{{#each imgHot}}
{{#each imgHot}}
{{#if @last}}
<li><a class="impo{{@index}}" href="{{href}}" target= "_blank"><img class="lazy" src="{{image img 378 248}}"/></a></li>
{{^}}
... ...
<div class="floor-header clearfix">
<h2 class="floor-title">{{name}}</h2>
<ul class="header-navs">
<li data-classify="s">
<a target="_blank" href="">sss</a>
</li>
</ul>
</div>
/**
* index controller
* @author: 赵彪<bill.zhao@yoho.cn>
* @date: 2016/05/03
*/
'use strict';
const headerModel = require('../../../doraemon/models/header');
exports.index = (req, res) => {
headerModel.requestHeaderData()
.then(response => {
let data = headerModel.setHeaderData(response.data, 'boys');
data.module = 'index';
data.page = 'index';
data.footerTop = true;
res.render('index', data);
})
.catch(() => {
res.render('index', {devEnv: true, pageErr: true});
});
};
/**
* sub app index
* @author: yyqing<yanqing.yang@yoho.cn>
* @date: 2016/05/03
*/
var express = require('express'),
path = require('path'),
hbs = require('express-handlebars');
var app = express();
// set view engin
var doraemon = path.join(__dirname, '../../doraemon/views'); // parent view root
app.set('views', path.join(__dirname, 'views/action'));
app.engine('.hbs', hbs({
extname: '.hbs',
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: ['./views/partial', `${doraemon}/partial`],
helpers: 'helpers'
}));
// router
app.use(require('./router'));
module.exports = app;
/**
* router of sub app index
* @author: yyqing<yanqing.yang@yoho.cn>
* @date: 2016/05/03
*/
'use strict';
const express = require('express');
const router = express.Router(); // eslint-disable-line
const cRoot = './controllers';
const homeController = require(`${cRoot}/index`);
// Your controller here
router.get('/', homeController.index);
module.exports = router;
<div class="yoho-page center-content">
<p>body</p>
</div>
... ... @@ -11,6 +11,7 @@ const isTest = process.env.NODE_ENV === 'test';
module.exports = {
port: 6002,
siteUrl: 'http://localhost:6002/',
domains: {
api: 'http://192.168.102.205:8080/gateway/',
service: 'http://testservice.yoho.cn:28077/',
... ...
<div class="floor-header clearfix">
<h2 class="floor-title">{{name}}</h2>
{{#if navs}}
<ul class="header-navs">
{{# navs}}
<li data-classify="{{id}}">
<a target="_blank" href="{{href}}">{{name}}</a>
</li>
{{/ navs}}
</ul>
{{/if}}
</div>