Authored by biao

update

... ... @@ -5,9 +5,9 @@
*/
'use strict';
const library = '../../../library';
const _ = require('lodash');
// const _ = require('lodash');
const outletModel = require('../models/outlet');
const helpers = require(`${library}/helpers`);
// const helpers = require(`${library}/helpers`);
const log = require(`${library}/logger`);
const renderData = {
... ... @@ -15,18 +15,14 @@ const renderData = {
page: 'home'
};
const outletLogger = (err, res) => {
log.error('奥莱页面渲染错误:' + JSON.stringify(err));
res.send('error');
};
// const outletLogger = (err, res) => {
// log.error('奥莱页面渲染错误:' + JSON.stringify(err));
// res.send('error');
// };
const getNavData = (req, res) => {
outletModel.getNavData().then(result => {
console.log(result)
res.render('outlet', Object.assign({}, renderData, result));
})
}
exports.index = (req, res) => {
getNavData(req, res)
}
\ No newline at end of file
outletModel.getContent().then(result => {
res.render('outlet', Object.assign({}, renderData, result));
});
};
... ...
... ... @@ -6,19 +6,54 @@
'use strict';
const library = '../../../library';
const utils = '../../../utils';
const _ = require('lodash');
// const _ = require('lodash');
const ServiceAPI = require(`${library}/api`).ServiceAPI;
const sign = require(`${library}/sign`);
const camelCase = require(`${library}/camel-case`);
// const camelCase = require(`${library}/camel-case`);
const resourcesProcess = require(`${utils}/resources-process`);
const log = require(`${library}/logger`);
const api = new ServiceAPI();
exports.getNavData = () => {
return api.get('3b8b45b8d87c8e44.json').then( result => {
if(result && result.code === 200){
const getOutletResource = () => {
const params = {
content_code: 'c19ffa03f053f4cac3690b22c8da26b7',
limit: 25,
debug: 'XYZ'
};
return api.get('operations/api/v5/resource/home', sign.apiSign(params)).then(result => {
if (result && result.code === 200) {
return resourcesProcess(result.data.list);
} else {
log.error('奥莱资源位接口返回状态码 不是 200');
return result;
}
});
};
const getNavData = () => {
return api.get('3b8b45b8d87c8e44.json').then(result => {
if (result && result.code === 200) {
return result.data;
}else{
return result
} else {
log.error('奥莱资源位接口返回状态码 不是 200');
return result;
}
});
}
};
exports.getContent = () => {
let floorsData = {};
return Promise.all([getNavData(), getOutletResource()]).then(data => {
floorsData.nav = data[0];
floorsData.content = data[1];
console.log(floorsData.content);
return floorsData;
});
};
... ...
... ... @@ -11,6 +11,7 @@ const cRoot = './controllers';
const outlet = require(cRoot);
const router = express.Router(); // eslint-disable-line
router.get('/index',outlet.index)
router.get('/index', outlet.index);
module.exports = router;
... ...
{{> outlet/nav }}
{{> outlet/countdown }}
\ No newline at end of file
{{> outlet/resource }}
... ...
{{# nav}}
<nav class="outlet-nav">
<ul>
{{#each nav}}
<li><a href="{{url}}">{{name}}</a></li>
{{/each}}
</ul>
</nav>
\ No newline at end of file
</nav>
{{/nav}}
... ...
{{#content}}
{{! 头部banner}}
{{#if focus}}
{{> resources/banner-top}}
{{/if}}
{{! 图标入口}}
{{#if appIconList}}
{{> resources/icons-enter}}
{{/if}}
{{! 中间banner}}
{{#if singleImage}}
{{> resources/banner}}
{{/if}}
{{! 两个小图}}
{{#if smallPic}}
{{> resources/thumb-row}}
{{/if}}
{{! 两个小图}}
{{#if nl2R}}
{{> resources/left-right}}
{{/if}}
{{! 热门品类}}
{{#if recommendContentFive}}
{{> resources/hot-category}}
{{/if}}
{{! 热门品牌}}
{{#if appHotBrands}}
{{> resources/hot-brands-list}}
{{/if}}
{{! 潮人搭配}}
{{#if trendsetterCollocation}}
{{> resources/trendsetter-collocation}}
{{/if}}
{{! 潮流时装/经典裤裙/时尚靴履/潮人配饰/潮流上装}}
{{#if recommendContentOne}}
{{> resources/goods-category}}
{{/if}}
{{! 新入住品牌/品味生活/创意生活}}
{{#if recommendContentTwo}}
{{> resources/creative-life}}
{{/if}}
{{! PLUS}}
{{#if singleNameImage}}
{{> resources/plus-star}}
{{/if}}
{{/content}}
... ...
... ... @@ -14,7 +14,8 @@ module.exports = {
siteUrl: '//m.yohobuy.com',
domains: {
api: 'http://testapi.yoho.cn:28078/', // http://192.168.102.205:8080/gateway
service: 'http://testservice.yoho.cn:28077/'
//service: 'http://testservice.yoho.cn:28077/'
service: 'http://devservice.yoho.cn:58077/'
},
useOneapm: false,
useCache: false,
... ...
<div id="thumb-row">
{{# data}}
{{# left}}
<a href="{{url}}">
<div class="thumb-row-box left-thumb-row-box" style="background-image:url({{image src 275 160}})"></div>
</a>
{{/ left}}
{{# right}}
<a href="{{url}}">
<div class="thumb-row-box right-thumb-row-box" style="background-image:url({{image src 275 160}})"></div>
</a>
{{/ right}}
{{/ data}}
</div>
... ...
... ... @@ -49,7 +49,8 @@
"winston": "^2.2.0",
"winston-daily-rotate-file": "^1.0.1",
"yoho-connect-memcached": "^1.0.3",
"yoho-express-session": "^1.0.3"
"yoho-express-session": "^1.0.3",
"yoho-iscroll": "0.0.1"
},
"devDependencies": {
"autoprefixer": "^6.3.6",
... ...
var $ = require("yoho-jquery"),
IScroll = require("yoho-iscroll"),
var $ = require('yoho-jquery'),
IScroll = require('yoho-iscroll'),
lazyLoad = require('yoho-jquery-lazyload'),
Countdown = require('./countdown').Countdown;
lazyLoad($('img.lazy'));
// nav 滚动
function initNavScroll() {
var $navBox = $(".outlet-nav"),
$lis = $navBox.find("li"),
var $navBox = $('.outlet-nav'),
$lis = $navBox.find('li'),
iScroll;
iScroll = new IScroll($navBox[0], {
scrollX: true,
scrollY: false,
scrollY: false
});
$navBox.on("click", "li", function() {
$navBox.on('click', 'li', function() {
var $this = $(this);
var i = $this.index();
$lis.eq(i).addClass("active").siblings().removeClass("active");
$lis.eq(i).addClass('active').siblings().removeClass('active');
scroll($this[0]);
});
function scroll(ele) {
var offset = -($navBox.find("ul").width() - 20) / 2;
var offset = -($navBox.find('ul').width() - 20) / 2;
setTimeout(function() {
iScroll.scrollToElement(ele, 400, offset)
iScroll.scrollToElement(ele, 400, offset);
}, 1);
}
//scroll($navBox.find(".active")[0]);
// scroll($navBox.find(".active")[0]);
}
function initCountDown(){
$('#demo1 .cd').each(function(index,node) {
function initCountDown() {
$('#demo1 .cd').each(function(index, node) {
Countdown({
el: node,
callback:function(){
alert(1)
callback: function() {
alert(1);
}
});
});
... ... @@ -42,7 +46,7 @@ function initCountDown(){
el: '#demo4 .cd'
});
cd.notify(0, function() {
alert(1)
alert(1);
});
Countdown({
... ... @@ -53,4 +57,4 @@ function initCountDown(){
}
initNavScroll();
initCountDown();
\ No newline at end of file
initCountDown();
... ...
... ... @@ -13,4 +13,8 @@
background-position: center;
margin: 0 14.4px;
}
.left-thumb-row-box {
height: 260px;
}
}
... ...
@import "outlet-nav";
\ No newline at end of file
@import "nav";
@import "left-right";
... ...
.left-right-thumb {
background-color: #f0f0f0;
text-align: center;
padding: 32px 0 0;
.left-thumb-row-box {
height: 260px;
}
}
... ...
... ... @@ -12,9 +12,13 @@ module.exports = (list) => {
list = list || [];
list = camelCase(list);
console.log(list);
_.forEach(list, (floor) => {
floor[_.camelCase(floor.templateName)] = true;
// console.log(floor);
// 特殊资源位处理
// PLUS
if (floor.singleNameImage && floor.data) {
... ... @@ -32,8 +36,16 @@ module.exports = (list) => {
}
}
if (floor.NL2R && floor.data) {
// floor.data.NL2R.left = floor.data.left;
// floor.data.NL2R.right = floor.data.right;
// console.log(floor.data);
}
formatData.push(floor);
});
// console.log(formatData);
return formatData;
};
... ...