Authored by 张丽霞

奥莱频道页模板

... ... @@ -8,6 +8,9 @@
// const headerModel = require('../../../doraemon/models/header');
// 开发用模拟数据
const outletsSimulation = require('../models/simulation');
/**
* outlets 首页
* @param {[type]} req [description]
... ... @@ -16,6 +19,7 @@
*/
exports.index = (req, res) => {
res.render('outlets/index', {});
// headerModel.requestHeaderData()
// .then(response => {
// response = headerModel.setHeaderData(response.data, 'outlets');
... ... @@ -50,15 +54,24 @@ exports.index = (req, res) => {
*/
exports.channel = (req, res) => {
let channel = {
boys: '',
girls: '',
boys: 'true',
girls: 'true',
kids: '',
lifestyle: ''
};
let response = {};
let response = {
module: 'product',
page: 'outlets',
footerTop: true,
devEnv: true
};
if (!channel[req.params.channel]) {
response.pageErr = true;
}
res.render('outlets/channel', response);
// 假数据输出
res.render('outlets/channel', Object.assign(response, outletsSimulation.outletBanner()));
// res.render('outlets/channel', response);
};
... ...
... ... @@ -554,3 +554,36 @@ exports.other = () => {
}
};
};
/**
* outlets 奥莱
* @return {[type]} [description]
*/
exports.outletBanner = () => {
return {
center: [
{
href: 'www.baidu.com',
img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/700/h/500'
},
{
href: 'www.baidu.com',
img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/700/h/500'
}
],
right: [{
href: 'www.baidu.com',
img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/240/h/103'
},
{
href: 'www.baidu.com',
img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/240/h/103'
}
],
hotBrands: {
brandUrl: 'www.baidu.com'
}
};
};
... ...
<p>outlets channel page</p>
<div class="home-page yoho-page" data-page="girls">
<div class="debris-slider clearfix">
<div class="center-col col">
<ul class="slide-wrapper">
{{# center}}
<li>
<a href="{{href}}" target="_blank">
<img src="{{img}}">
<!-- <img class="lazy" data-original="{{img}}"> -->
</a>
</li>
{{/ center}}
</ul>
<div class="slide-switch">
<a class="prev" href="javascript:;">
<span class="iconfont">&#xe60c;</span>
</a>
<a class="next" href="javascript:;">
<span class="iconfont">&#xe60b;</span>
</a>
</div>
</div>
<div class="right-col col">
{{# right}}
<a href="{{href}}" target="_blank">
<img src="{{img}}">
<!-- <img class="lazy" data-original="{{img}}"> -->
</a>
{{/ right}}
</div>
</div>
{{!热门品牌}}
{{# hotBrands}}
{{> brand/hot-brand}}
{{/hotBrands}}
</div>
\ No newline at end of file
... ...
{{> index/floor-header}}
<div class="preference-brand imgopacity">
<div class="logo-brand " data-url="{{brandUrl}}">
</div>
</div>
\ No newline at end of file
... ...
<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>
\ No newline at end of file
... ...
/**
* 首页优选品牌js
* @author: liuyue(yue.liu@yoho.cn)
* @date: 2015/12/08
*/
var $ = require('yoho-jquery'),
Handlebars = require('yoho-handlebars'),
lazyLoad = require('yoho-jquery-lazyload');
(function() {
var LogoBrand = function(element, options) {
this.$element = $(element);
this.options = $.extend({}, $.fn.logoBrand.defaults, options);
this.init();
};
LogoBrand.prototype = {
init: function() {
this.$element.addClass('logos-' + this.options.showNum);
this._sendRequest();
},
_createHelper: function() {
var showNum = this.options.showNum;
Handlebars.registerHelper('brandList', function(items, options) {
var out = '<ul>',
i = 0,
item = null,
fillNum = 0;
// 不是每页显示个数的倍数,填充数据
if (items.length % showNum !== 0) {
fillNum = showNum - (items.length % showNum);
for (i = 0; i < fillNum; i++) {
items.push({
href: 'javascript:;',
img: ''
});
}
}
for (i = 0; i < items.length; i++) {
item = options.fn(items[i]);
if (i % showNum === 5 || i === 5) {
// 插入切换按钮的位置
out = out + '<li class="logo-brand-switch" data-page="' + Math.floor(i / showNum) + '">' +
'<a class="prev iconfont" href="javascript:;">&#xe60f;</a>' +
'<a class="next iconfont" href="javascript:;">&#xe60e;</a></li>' +
'<li data-page="' + Math.floor(i / showNum) + '">' + item + '</li>';
} else if (i !== 0 && i % showNum === 0) {
// 插入more的位置,more占的是下一页第一个brand的位置,所以page是i/17
out = out + '<li class="brand-more" data-page="' + Math.floor(i / (showNum + 1)) + '">' +
'<a href="javascript:;" target="_blank">MORE ></a></li>' +
'<li data-page="' + Math.floor(i / showNum) + '">' + item + '</li>';
} else {
out = out + '<li data-page="' + Math.floor(i / showNum) + '">' + item + '</li>';
}
}
// 加上最后一个more, more占的是下一页第一个brand的位置,这里已经循环不到brand,所以加在末尾
return out + '<li class="brand-more" data-page="' + Math.floor(i / (showNum + 1)) + '">' +
'<a href="javascript:;" target="_blank">MORE ></a></li></ul>';
});
},
_sendRequest: function() {
var that = this;
$.ajax({
type: 'GET',
url: that.options.url,
dataType: 'json',
success: function(data) {
var brandTpl,
brandHtml;
if (!data || data.length === 0) {
return;
}
that._createHelper();
brandHtml = '\{{#brandList logoBrand}}' +
'<a href="\{{href}}" target="_blank"><img class="lazy" data-original="\{{img}}" alt=""></a>' +
'\{{/brandList}}';
brandTpl = Handlebars.compile(brandHtml);
that.$element.html(brandTpl(data));
that.$element.find('.brand-more a').attr('href', data.moreBrand);
lazyLoad(that.$element.find('img.lazy'));
that._bindEvent();
}
});
},
_brandShow: function(hidePage, showPage) {
var that = this;
lazyLoad($('li[data-page=' + showPage + ']').find('img.lazy').trigger('appear'));
that.$element.find('li[data-page=' + hidePage + ']').find('img').fadeOut('normal', function() {
that.$element.find('li').hide();
that.$element.find('li[data-page=' + showPage + ']').show().find('img').fadeIn();
});
},
_bindEvent: function() {
var that = this;
that.$element.on('click', '.next', function() {
var page = $(this).parent().data('page'),
nextPage = 0,
totalPage = Math.ceil(that.$element.find('li').size() / (that.options.showNum + 2)) - 1;
if (page === totalPage) {
nextPage = 0;
} else {
nextPage = page + 1;
}
that._brandShow(page, nextPage);
});
that.$element.on('click', '.prev', function() {
var page = $(this).parent().data('page'),
prevPage = 0,
totalPage = Math.ceil(that.$element.find('li').size() / (that.options.showNum + 2)) - 1;
if (page === 0) {
prevPage = totalPage;
} else {
prevPage = page - 1;
}
that._brandShow(page, prevPage);
});
}
};
$.fn.logoBrand = function(option) {
return this.each(function() {
var $this = $(this),
data = $this.data('LogoBrand'),
options = typeof option === 'object' && option;
if (!data) {
$this.data('LogoBrand', (data = new LogoBrand(this, options)));
}
if (typeof option === 'string') {
data[option]();
}
});
};
$.fn.logoBrand.Constructor = LogoBrand;
$.fn.logoBrand.defaults = {
showNum: 16,
url: '/boys/getBrand'
};
}());
... ...
var $ = require('yoho-jquery'),
lazyLoad = require('yoho-jquery-lazyload'),
homePage = $('.home-page').data('page');
lazyLoad($('img.lazy'));
require('../common/slider');
require('../common/slider2');
require('../common/logo-brand');
if (homePage === 'boys') {
$('.slide-container').slider({
pagination: '.thumb-pagination'
});
} else {
$('.center-col').slider();
$('.slide-container').slider();
}
// if (homePage === 'boys') {
// $('.logo-brand').logoBrand({
// url: brandUrl
// });
// $('.img-brand').slider2();
// } else {
// $('.logo-brand').logoBrand({
// showNum: 10,
// url: brandUrl
// });
// $('.img-slider-wrapper').slider2();
// }
... ...
... ... @@ -4,7 +4,7 @@ var $ = require('yoho-jquery'),
var product = require('./product');
require('../header');
require('../index/slider');
require('../common/slider');
product.init();
lazyLoad($('img.lazy'));
... ...
... ... @@ -229,6 +229,7 @@ a {
@import "footer";
@import "404";
@import "common/index";
@import "plugin/slider";
/* 模块 */
@import "product/index";
... ...
.slider {
position: relative;
height: 327px;
width: 100%;
overflow: hidden;
img {
max-width: 100%;
max-height: 100%;
}
}
.slide-pagination {
position: absolute;
left: 0;
right: 0;
bottom: 12px;
text-align: center;
}
.slide-pagination-inner {
display: inline-block;
position: relative;
padding: 7px;
vertical-align: middle;
}
.slide-shade {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
background: #000;
opacity: 0.3;
border-radius: 13px;
}
.slide-pagination-last span {
display: block;
float: left;
position: relative;
margin: 0 7px;
width: 12px;
height: 12px;
background: #fff;
cursor: pointer;
opacity: 0.6;
border-radius: 6px;
z-index: 2;
&.focus {
opacity: 1;
}
}
.slide-switch {
display: none;
&.show {
display: block;
}
a {
display: block;
position: absolute;
top: 50%;
margin: -30px 0 0;
width: 60px;
height: 60px;
line-height: 56px;
text-align: center;
z-index: 2;
background: #fff;
opacity: 0.55;
&:hover {
opacity: 0.9;
}
.iconfont {
font-size: 32px;
color: #59585a;
}
}
.prev {
left: 0;
}
.next {
right: 0;
}
}
... ...
... ... @@ -11,6 +11,7 @@
@import "shop-entry";
@import "detail";
@import "sale/_index.css";
@import "outlets/_index.css";
.product-page {
/* 分页 */
... ...
.home-page {
width: 1150px;
margin: 10px auto 0;
.slide-container {
position: absolute;
left: 0;
right: 0;
height: 450px;
}
.slide-thumb-container {
height: 510px;
}
.slide-wrapper {
position: relative;
height: 450px;
overflow: hidden;
ul {
position: relative;
height: 100%;
}
&:hover .slide-switch.show {
display: block;
}
li {
display: none;
position: absolute;
top: 0;
right: 0;
width: 100%;
height: 100%;
a {
display: block;
height: 100%;
width: 1150px;
margin: 0 auto;
}
&:first-child {
display: block;
}
img {
width: 100%;
height: 100%;
}
}
}
.slide-container-placeholder {
height: 450px;
width: 100%;
}
.slide-thumb-container-placeholder {
height: 510px;
}
.slide-switch {
display: block;
a {
position: absolute;
top: 50%;
margin: -30px 0 0;
width: 60px;
height: 60px;
line-height: 56px;
text-align: center;
z-index: 2;
background: #fff;
opacity: 0.55;
&.prev {
left: 50%;
margin-left: -575px;
}
&.next {
right: 50%;
margin-right: -575px;
}
&:hover {
opacity: 0.9;
}
.iconfont {
font-size: 32px;
color: #59585a;
}
}
}
.thumb-pagination {
width: 1148px;
margin: 6px auto 0;
padding-left: 2px;
li {
position: relative;
float: left;
margin-left: 6px;
width: 138px;
height: 54px;
&:first-child {
margin: 0;
}
&.focus a {
opacity: 0;
}
a {
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
background: #000;
opacity: 0.3;
}
img {
width: 100%;
height: 100%;
}
}
}
/*
大banner圆点
*/
.slide-pagination {
font-size: 0;
.slide-shade {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
background: #000;
opacity: 0.3;
border-radius: 13px;
}
span {
position: relative;
display: inline-block;
margin: 0 7px;
width: 12px;
height: 12px;
background: #fff;
cursor: pointer;
opacity: 0.6;
border-radius: 6px;
z-index: 2;
&.focus {
opacity: 1;
}
}
}
.debris-slider {
height: 510px;
width: 100%;
.col {
float: left;
a {
display: block;
}
}
.right-col a {
margin-bottom: 10px;
&:last-child {
margin-bottom: 0;
}
}
.right-col img {
height: 100%;
width: 100%;
}
.center-col {
position: relative;
width: 700px;
height: 100%;
margin-right: 10px;
font-size: 0;
&:hover {
.slide-switch.show {
display: block;
}
}
.slide-wrapper {
height: 100%;
li a {
width: 100%;
}
}
.slide-switch {
a.prev {
left: 0;
margin-left: 0;
}
a.next {
right: 0;
margin-right: 0;
}
}
img {
max-width: 100%;
max-height: 100%;
}
}
.right-col a {
width: 280px;
height: 120px;
}
.right-col a:first-child {
height: 380px;
margin-bottom: 11px;
}
}
.new-report {
img {
display: block;
width: 100%;
height: 100%;
}
.report-list {
float: left;
width: 868px;
}
li {
float: left;
margin: 0 8px 8px 0;
width: 185px;
height: 248px;
overflow: hidden;
&:first-child {
margin-right: 7px;
width: 282px;
height: 504px;
}
}
.last-item {
float: left;
width: 282px;
height: 504px;
overflow: hidden;
}
}
/*
优选品牌
*/
.preference-brand {
overflow: hidden;
}
.preference-brand-list {
margin-top: 8px;
width: 1158px;
}
.preference-brand-item {
float: left;
margin-right: 8px;
margin-bottom: 8px;
a {
display: table-cell;
width: 185px;
height: 86px;
text-align: center;
vertical-align: middle;
}
img {
display: block;
max-width: 100%;
max-height: 100%;
margin: 0 auto;
}
}
.preference-more {
float: left;
width: 185px;
height: 86px;
line-height: 100px;
text-align: center;
color: black;
font-size: 16px;
}
.img-slider-wrapper {
position: relative;
width: 100%;
height: 558px;
background: #8ae6e0;
overflow: hidden;
.img-brand-switch {
display: block;
a {
position: absolute;
top: 50%;
font-size: 36px;
color: #fff;
&.next {
right: 30px;
}
&.prev {
left: 30px;
}
}
}
}
.img-container-landscape {
box-sizing: border-box;
margin: 86px auto 0;
width: 982px;
height: 433px;
overflow: hidden;
.img-list {
width: 1000px;
height: 100%;
}
.img-item {
float: left;
box-sizing: border-box;
width: 320px;
height: 100%;
margin-right: 10px;
img {
width: 100%;
height: 100%;
}
}
}
.img-brand {
position: relative;
width: 100%;
height: 175px;
overflow: hidden;
&:hover {
.img-brand-switch {
display: block;
}
}
ul {
width: 1158px;
}
li {
float: left;
margin: 0 8px 0 0;
width: 378px;
height: 175px;
line-height: 175px;
overflow: hidden;
font-size: 0;
text-align: center;
img {
max-width: 100%;
max-height: 100%;
vertical-align: middle;
}
}
.img-brand-switch {
display: none;
a {
position: absolute;
top: 50%;
margin: -20px 0 0;
width: 40px;
height: 40px;
line-height: 40px;
text-align: center;
z-index: 2;
background: #fff;
opacity: 0.55;
&.prev {
left: 0;
}
&.next {
right: 0;
}
&:hover {
opacity: 0.9;
}
}
}
}
.logo-brand {
width: 100%;
height: 282px;
overflow: hidden;
&.logos-10 {
height: 188px;
}
ul {
width: 1158px;
}
li {
float: left;
margin: 8px 8px 0 0;
width: 185px;
height: 86px;
line-height: 86px;
font-size: 0;
text-align: center;
img {
max-width: 100%;
max-height: 100%;
vertical-align: middle;
}
}
.logo-brand-switch {
position: relative;
background: resolve('index/logo-brand-line.png') no-repeat center center;
line-height: normal;
.iconfont {
position: absolute;
left: 50%;
font-size: 32px;
&.prev {
top: 10px;
margin-left: -48px;
}
&.next {
bottom: 12px;
margin-left: 20px;
}
}
}
.brand-more {
font-size: 16px;
&:hover {
text-decoration: underline;
}
}
}
.categorys-list {
ul {
width: 1158px;
}
li {
float: left;
margin: 0 8px 8px 0;
width: 185px;
height: 248px;
&.cate-item0 {
width: 185px;
height: 504px;
}
&.cate-item1 {
width: 377px;
height: 504px;
}
img {
display: block;
width: 100%;
height: 100%;
}
}
}
}
/*
@import "index-pliffy";
@import "min-index";
@import "brand";
*/
... ...