Authored by 514335620@qq.com

sale 页面部分模板

@@ -9,8 +9,60 @@ @@ -9,8 +9,60 @@
9 // const mRoot = '../models'; 9 // const mRoot = '../models';
10 10
11 // 商品促销model 11 // 商品促销model
12 -// const detail = require(`${mRoot}/detail`); 12 +// const sale = require(`${mRoot}/sale`);
  13 +var fakeData;
13 14
14 exports.index = (req, res) => { 15 exports.index = (req, res) => {
15 - res.render('sale/index', {}); 16 +
  17 + fakeData = {
  18 + devEnv: true,
  19 + module: 'product',
  20 + page: 'sale',
  21 + slide: {
  22 + list: [
  23 + {
  24 + bannerHeight: 200,
  25 + href: 'http://www.yoho.cn',
  26 + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/830/h/327'
  27 + },
  28 + {
  29 + bannerHeight: 200,
  30 + href: 'http://www.yoho.cn',
  31 + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/830/h/327'
  32 + },
  33 + {
  34 + bannerHeight: 200,
  35 + href: 'http://www.yoho.cn',
  36 + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/830/h/327'
  37 + }
  38 + ]
  39 + },
  40 +
  41 + recommandImg: [
  42 + {
  43 + jumpUrl: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/250/h/80',
  44 + sourceUrl: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/250/h/80'
  45 + },
  46 + {
  47 + jumpUrl: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/250/h/80',
  48 + sourceUrl: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/250/h/80'
  49 + },
  50 + {
  51 + jumpUrl: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/250/h/80',
  52 + sourceUrl: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/250/h/80'
  53 + }
  54 + ],
  55 +
  56 + specialSale: {
  57 + brandSale: {
  58 + big: [{
  59 +
  60 + }]
  61 + }
  62 + }
  63 +
  64 +
  65 +
  66 + };
  67 + res.render('sale/index', fakeData);
16 }; 68 };
1 <div class="sale-arena-page yoho-page"> 1 <div class="sale-arena-page yoho-page">
2 - <p>coding here</p> 2 + <p>coding here arena</p>
3 </div> 3 </div>
1 <div class="sale-page yoho-page"> 1 <div class="sale-page yoho-page">
2 - <p>coding here</p> 2 + {{! 头部banner}}
  3 +
  4 + {{log this}}
  5 +
  6 + {{# slide}}
  7 + {{> common/slide-banner}}
  8 + {{/ slide}}
  9 +
  10 + {{! banner底部图片}}
  11 + {{#each recommandImg}}
  12 + <img href="{{jumpUrl}}" src="{{sourceUrl}}">
  13 + </img>
  14 + {{/each}}
  15 +
  16 + {{! 折扣专场}}
  17 + {{# specialSale}}
  18 + {{> sale/brand-sale}}
  19 + {{/ specialSale}}
  20 +
  21 +
  22 + {{! 类别楼层遍历}}
  23 + {{# category}}
  24 + {{> sale/sale-box}}
  25 + {{/ category}}
  26 +
  27 +
  28 + <p>coding here index</p>
3 </div> 29 </div>
  1 +<div class="activity-entry clearfix">
  2 + {{#activityEnter}}
  3 + <a class="entry-item pull-left {{#if @first}}first{{/if}} {{#if @last}}last{{/if}}" href="{{link}}">
  4 + <span class="icon pull-left {{icon}}"></span>
  5 + <div class="entry-text">
  6 + <span class="title">{{title}}</span>
  7 + <p class="desc">{{desc}}</p>
  8 + </div>
  9 + </a>
  10 + {{/activityEnter}}
  11 +</div>
  1 +<div class="brand-sale">
  2 + <div class="floor-title">
  3 + 折扣专场 SALE
  4 + </div>
  5 +
  6 + {{#brandSale}}
  7 + <div class="sale-group-big clearfix">
  8 + {{#big}}
  9 + <a class="item pull-left" href="{{link}}">
  10 + <div class="pic">
  11 + <img src="{{img}}">
  12 + <div class="time">{{time}}</div>
  13 + </div>
  14 + <div class="detail">
  15 + <img class="brand pull-left" src="{{brand}}">
  16 + <div class="text">
  17 + <div class="discount">
  18 + <span class="num">{{discount}}</span> Off
  19 + </div>
  20 + <div class="title">
  21 + {{title}}
  22 + </div>
  23 + </div>
  24 + </div>
  25 + </a>
  26 + {{/big}}
  27 + </div>
  28 + <div class="sale-group clearfix">
  29 + {{#normal}}
  30 + <a class="item pull-left" href="{{link}}">
  31 + <img class="pic" src="{{img}}">
  32 + <div class="detail">
  33 + <div class="title">{{title}}</div>
  34 + <div class="time">{{time}}</div>
  35 + </div>
  36 + </a>
  37 + {{/normal}}
  38 + </div>
  39 + {{/brandSale}}
  40 +
  41 +</div>
  1 +<div class="sale-list-banner" style="height: {{bannerHeight}}px;">
  2 + <ul style="height: {{bannerHeight}}px;">
  3 + {{# list}}
  4 + <li class="banner-img" style="background:url({{img}}) no-repeat top center;"></li>
  5 + {{/ list}}
  6 + </ul>
  7 +</div>
  1 +<div class="home-page">
  2 + {{#sale-category}}
  3 + <div class="floor-header clearfix">
  4 + <h2 class="floor-title">{{title}}</h2>
  5 + </div>
  6 + <ul class="sale-nav">
  7 + {{#navItem}}
  8 + <li class="{{#vip}}green{{/vip}} {{#incompleteSize}}yellow{{/incompleteSize}} {{#newDiscount}}red{{/newDiscount}} {{#if @first}}active first{{/if}} {{#if @last}}last{{/if}}" data-url='{{url}}'>aa</li>
  9 + {{/navItem}}
  10 + </ul>
  11 + <div class="commodity-list">
  12 + <ul class="clearfix">
  13 + {{#each saleImage}}
  14 + <li class="commodity-item">
  15 + <a href="{{href}}" target= "_blank"><div class="commodity-img">
  16 + <img class="lazy" data-original="{{img}}"/></div>
  17 + <div class="commodity-content {{#if @last}}hide{{/if}}">
  18 + <p class="commodity-name">{{name}}</p>
  19 + <p class="commodity-price">
  20 + <span class="origin">¥{{originPrice}}</span>
  21 + <span>¥{{price}}</span>
  22 + {{#vip}}<span class="vip-tag">VIP</span><strong>更优惠</strong>{{/vip}}
  23 + </p>
  24 + </div>
  25 + </a>
  26 + </li>
  27 + {{/each}}
  28 + </ul>
  29 + </div>
  30 + {{/sale-category}}
  31 +</div>
@@ -9,12 +9,12 @@ module.exports = app => { @@ -9,12 +9,12 @@ module.exports = app => {
9 // 公共服务 9 // 公共服务
10 10
11 // 专题活动等活动页面 11 // 专题活动等活动页面
12 - app.use(require('./apps/activity')); 12 + // app.use(require('./apps/activity'));
13 13
14 // 业务模块 14 // 业务模块
15 // app.use('/', require('./apps/index')); 15 // app.use('/', require('./apps/index'));
16 app.use('/product', require('./apps/product')); 16 app.use('/product', require('./apps/product'));
17 17
18 // 频道页 18 // 频道页
19 - app.use('/', require('./apps/channel')); 19 + // app.use('/', require('./apps/channel'));
20 }; 20 };
  1 +##公共头部模拟数据
  2 +
  3 +
  4 +```javascript
  5 +var sale = {
  6 + saleBanner:[
  7 + {
  8 + bannerHeight: 200,
  9 + link:'http://www.yoho.cn',
  10 + img:'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/830/h/327',
  11 + },
  12 + ],
  13 +
  14 +}
  15 +```
  1 +<div id="slider" class="slide-container {{#if pagination}}slide-thumb-container{{/if}}">
  2 + <div class="slide-wrapper">
  3 + <ul>
  4 + {{# list}}
  5 + <li style="{{#if bgColor}}background:{{bgColor}}{{/if}}">
  6 + <a href="{{href}}" target= "_blank">
  7 + {{#if @first}}
  8 + <img src="{{img}}">
  9 + {{^}}
  10 + <img class="lazy" data-original="{{img}}" alt="">
  11 + {{/if}}
  12 + </a>
  13 + {{# tips}}
  14 + <div class="slide-tips">
  15 + <div class="g-mark"></div>
  16 + <p>{{.}}</p>
  17 + </div>
  18 + {{/ tips}}
  19 + </li>
  20 + {{/ list}}
  21 + </ul>
  22 + </div>
  23 +
  24 + {{#if pagination}}
  25 + <div class="thumb-pagination">
  26 + <ul class="clearfix">
  27 + {{# pagination}}
  28 + <li>
  29 + <a href="{{href}}" target="_blank"></a>
  30 + <img src="{{img}}" alt="">
  31 + </li>
  32 + {{/ pagination}}
  33 + </ul>
  34 + </div>
  35 + {{/if}}
  36 +</div>
  37 +<div class="slide-container-placeholder {{#if pagination}}slide-thumb-container-placeholder{{/if}}"></div>
  1 +/**
  2 + * 首页banner轮播
  3 + * @author: liuyue(yue.liu@yoho.cn)
  4 + * @date: 2015/12/04
  5 + */
  6 +
  7 +var $ = require('yoho-jquery'),
  8 + lazyLoad = require('yoho-jquery-lazyload');
  9 +
  10 +(function() {
  11 + var Slider = function(element, options) {
  12 + this.$element = $(element);
  13 + this.options = $.extend({}, $.fn.slider.defaults, options);
  14 + this.bigItem = this.$element.find('.slide-wrapper').find('li');
  15 + this.smallItem = null;
  16 + this.len = this.bigItem.size();
  17 + this.index = 0;
  18 + this.timer = null;
  19 + this.init();
  20 + };
  21 +
  22 + Slider.prototype = {
  23 + init: function() {
  24 + if (!this.$element) {
  25 + return;
  26 + }
  27 +
  28 + if (this.len <= 1) {
  29 + lazyLoad(this.$element.find('img.lazy'));
  30 + return;
  31 + }
  32 + if (this.options.pagination) {
  33 + this.smallItem = $(this.options.pagination).find('li');
  34 + } else {
  35 + this._createPage();
  36 + }
  37 +
  38 + if (this.options.orient) {
  39 + this._createOrient();
  40 + }
  41 + this._slideShow();
  42 + this._bindEvent();
  43 + this._autoplay();
  44 + },
  45 + _createOrient: function() {
  46 +
  47 + var orientHtml = '<div class="slide-switch">' +
  48 + '<a class="prev" href="javascript:;"><span class="iconfont">&#xe60c;</span></a>' +
  49 + '<a class="next" href="javascript:;"><span class="iconfont">&#xe60b;</span></a>' +
  50 + '</div>';
  51 +
  52 + if (this.$element.find('.slide-switch').length > 0) {
  53 + return;
  54 + }
  55 +
  56 + this.$element.append(orientHtml);
  57 + },
  58 + _createPage: function() {
  59 + var pageHtml = '<div class="slide-pagination"><div class="slide-pagination-inner">' +
  60 + '<div class="slide-shade"></div><div class="slide-pagination-last">',
  61 + i = 0;
  62 +
  63 + if (this.len <= 1) {
  64 + return;
  65 + }
  66 + for (i = 0; i < this.len; i++) {
  67 + pageHtml += '<span></span>';
  68 + }
  69 + pageHtml += '</div></div></div>';
  70 + this.$element.append($(pageHtml));
  71 + this.smallItem = this.$element.find('.slide-pagination-inner span');
  72 + },
  73 + _bindEvent: function() {
  74 + var that = this;
  75 +
  76 + this.$element.find('.slide-switch').on('click', '.next', function() {
  77 + that._nextSlide();
  78 + clearInterval(that.timer);
  79 + that.timer = setInterval(function() {
  80 + that._nextSlide();
  81 + }, that.options.time);
  82 + }).on('click', '.prev', function() {
  83 + that._prevSlide();
  84 + clearInterval(that.timer);
  85 + that.timer = setInterval(function() {
  86 + that._nextSlide();
  87 + }, that.options.time);
  88 + });
  89 +
  90 + this.smallItem.on('mouseenter', function() {
  91 + that.index = $(this).index();
  92 + clearInterval(that.timer);
  93 + that._slideShow();
  94 + }).on('mouseleave', function() {
  95 + that._autoplay();
  96 + });
  97 +
  98 + this.$element.on('mouseenter', function() {
  99 + $(this).find('.slide-switch').addClass('show');
  100 + }).on('mouseleave', function() {
  101 + $(this).find('.slide-switch').removeClass('show');
  102 + });
  103 + },
  104 + _nextSlide: function() {
  105 + if (this.index === this.len - 1) {
  106 + this.index = 0;
  107 + } else {
  108 + this.index++;
  109 + }
  110 + this._slideShow();
  111 + },
  112 + _prevSlide: function() {
  113 + if (this.index === 0) {
  114 + this.index = this.len - 1;
  115 + } else {
  116 + this.index--;
  117 + }
  118 + this._slideShow();
  119 + },
  120 + _slideShow: function() {
  121 + var $img = this.bigItem.eq(this.index).find('img.lazy');
  122 +
  123 + // 未加载图片的及时显示
  124 + if ($img.attr('src') !== $img.data('original')) {
  125 + lazyLoad($img, {
  126 + event: 'sporty'
  127 + });
  128 + $img.trigger('sporty');
  129 + }
  130 +
  131 + this.smallItem.eq(this.index).addClass('focus').siblings().removeClass('focus');
  132 + this.bigItem.eq(this.index).show().stop().animate({
  133 + opacity: 1
  134 + }, function() {
  135 +
  136 + // 修正IE下切换时文字会重叠的问题
  137 + $(this).find('.slide-tips > p').removeClass('hide');
  138 + }).siblings().stop().animate({
  139 + opacity: 0
  140 + }, function() {
  141 + $(this).hide().find('.slide-tips > p').addClass('hide');
  142 + });
  143 + },
  144 + _autoplay: function() {
  145 + var that = this;
  146 +
  147 + clearInterval(this.timer);
  148 + this.timer = setInterval(function() {
  149 + that._nextSlide();
  150 + }, this.options.time);
  151 + }
  152 + };
  153 + $.fn.slider = function(option) {
  154 + return this.each(function() {
  155 + var $this = $(this),
  156 + data = $this.data('Slider'),
  157 + options = typeof option === 'object' && option;
  158 +
  159 + if (!data) {
  160 + $this.data('Slider', (data = new Slider(this, options)));
  161 + }
  162 + if (typeof option === 'string') {
  163 + data[option]();
  164 + }
  165 + });
  166 + };
  167 + $.fn.slider.Constructor = Slider;
  168 + $.fn.slider.defaults = {
  169 + time: 5000,
  170 + orient: true, // 左右切换箭头的显示
  171 + pagination: null
  172 + };
  173 +}());
  1 +require('../header');
  2 +require('../index/slider');
  3 +
  4 +
  5 +$('#slider').slider();
@@ -218,9 +218,9 @@ a { @@ -218,9 +218,9 @@ a {
218 left: 0; 218 left: 0;
219 } 219 }
220 220
221 -@define-mixin ellipsis {  
222 - overflow: hidden;  
223 - text-overflow: ellipsis; 221 +@define-mixin ellipsis {
  222 + overflow: hidden;
  223 + text-overflow: ellipsis;
224 white-space: nowrap; 224 white-space: nowrap;
225 } 225 }
226 226
@@ -231,3 +231,6 @@ a { @@ -231,3 +231,6 @@ a {
231 @import "common/index"; 231 @import "common/index";
232 232
233 /* 模块 */ 233 /* 模块 */
  234 +
  235 +/* product */
  236 +@import "product/index";
  1 +.sale-page {
  2 + .sale-list-banner {
  3 + width: 100%;
  4 + position: relative;
  5 +
  6 + ul {
  7 + overflow: hidden;
  8 + width: 100%;
  9 + position: relative;
  10 + z-index: 1;
  11 +
  12 + li {
  13 + width: 100%;
  14 + height: 100%;
  15 + display: block;
  16 + position: absolute;
  17 + top: 0;
  18 + left: 0;
  19 + }
  20 + }
  21 + }
  22 +
  23 +}