Merge branch 'feature/sale' of http://git.dev.yoho.cn/web/yohobuy-node into feature/sale
the commit.
Showing
14 changed files
with
1560 additions
and
23 deletions
@@ -583,7 +583,152 @@ exports.outletBanner = () => { | @@ -583,7 +583,152 @@ exports.outletBanner = () => { | ||
583 | ], | 583 | ], |
584 | 584 | ||
585 | hotBrands: { | 585 | hotBrands: { |
586 | + name: '热门品牌', | ||
586 | brandUrl: 'www.baidu.com' | 587 | brandUrl: 'www.baidu.com' |
588 | + }, | ||
589 | + | ||
590 | + brandList: { | ||
591 | + logoBrand: [{ | ||
592 | + href: 'www.baidu.com', | ||
593 | + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/50/h/50' | ||
594 | + }, | ||
595 | + { | ||
596 | + href: 'www.baidu.com', | ||
597 | + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/50/h/50' | ||
598 | + }, | ||
599 | + { | ||
600 | + href: 'www.baidu.com', | ||
601 | + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/50/h/50' | ||
602 | + }, | ||
603 | + { | ||
604 | + href: 'www.baidu.com', | ||
605 | + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/50/h/50' | ||
606 | + }, | ||
607 | + { | ||
608 | + href: 'www.baidu.com', | ||
609 | + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/50/h/50' | ||
610 | + }, | ||
611 | + { | ||
612 | + href: 'www.baidu.com', | ||
613 | + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/50/h/50' | ||
614 | + }, | ||
615 | + { | ||
616 | + href: 'www.baidu.com', | ||
617 | + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/50/h/50' | ||
618 | + }, | ||
619 | + { | ||
620 | + href: 'www.baidu.com', | ||
621 | + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/50/h/50' | ||
622 | + }, | ||
623 | + { | ||
624 | + href: 'www.baidu.com', | ||
625 | + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/50/h/50' | ||
626 | + }, | ||
627 | + { | ||
628 | + href: 'www.baidu.com', | ||
629 | + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/50/h/50' | ||
630 | + }] | ||
631 | + }, | ||
632 | + | ||
633 | + recommend: { | ||
634 | + tplrecommend: { | ||
635 | + name: '热门品类', | ||
636 | + keyword: [{ | ||
637 | + name: 'T-SHIRTS', | ||
638 | + herf: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/180/h/75', | ||
639 | + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/180/h/75' | ||
640 | + }, | ||
641 | + { | ||
642 | + name: 'T-SHIRTS', | ||
643 | + herf: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/180/h/75', | ||
644 | + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/180/h/75' | ||
645 | + | ||
646 | + }, | ||
647 | + { | ||
648 | + name: 'T-SHIRTS', | ||
649 | + herf: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/180/h/75', | ||
650 | + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/180/h/75' | ||
651 | + }], | ||
652 | + | ||
653 | + category: [{ | ||
654 | + href: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/380/h/500', | ||
655 | + name: '衬衣' | ||
656 | + }, | ||
657 | + { | ||
658 | + href: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/50/h/50', | ||
659 | + name: '衬衣' | ||
660 | + }, { | ||
661 | + href: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/50/h/50', | ||
662 | + name: '衬衣' | ||
663 | + }, { | ||
664 | + href: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/50/h/50', | ||
665 | + name: '衬衣' | ||
666 | + }, { | ||
667 | + href: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/50/h/50', | ||
668 | + name: '衬衣' | ||
669 | + }, { | ||
670 | + href: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/50/h/50', | ||
671 | + name: '衬衣' | ||
672 | + }, { | ||
673 | + href: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/50/h/50', | ||
674 | + name: '衬衣' | ||
675 | + }, { | ||
676 | + href: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/50/h/50', | ||
677 | + name: '衬衣' | ||
678 | + }, { | ||
679 | + href: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/50/h/50', | ||
680 | + name: '衬衣' | ||
681 | + }, { | ||
682 | + href: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/50/h/50', | ||
683 | + name: '衬衣' | ||
684 | + }, { | ||
685 | + href: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/50/h/50', | ||
686 | + name: '衬衣' | ||
687 | + }, { | ||
688 | + href: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/50/h/50', | ||
689 | + name: '衬衣' | ||
690 | + }, { | ||
691 | + href: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/50/h/50', | ||
692 | + name: '衬衣' | ||
693 | + }], | ||
694 | + | ||
695 | + brands: [{ | ||
696 | + href: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/380/h/500', | ||
697 | + name: '衬衣', | ||
698 | + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/380/h/500' | ||
699 | + }], | ||
700 | + | ||
701 | + types: [{ | ||
702 | + href: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/180/h/250', | ||
703 | + name: '衬衣', | ||
704 | + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/180/h/250' | ||
705 | + }, | ||
706 | + { | ||
707 | + href: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/180/h/250', | ||
708 | + name: '衬衣', | ||
709 | + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/180/h/250' | ||
710 | + }, | ||
711 | + { | ||
712 | + href: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/180/h/250', | ||
713 | + name: '衬衣', | ||
714 | + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/180/h/250' | ||
715 | + }, | ||
716 | + { | ||
717 | + href: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/180/h/250', | ||
718 | + name: '衬衣', | ||
719 | + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/180/h/250' | ||
720 | + }, | ||
721 | + { | ||
722 | + href: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/180/h/250', | ||
723 | + name: '衬衣', | ||
724 | + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/180/h/250' | ||
725 | + }, | ||
726 | + { | ||
727 | + href: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/180/h/250', | ||
728 | + name: '衬衣', | ||
729 | + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/180/h/250' | ||
730 | + }] | ||
731 | + } | ||
587 | } | 732 | } |
588 | }; | 733 | }; |
589 | }; | 734 | }; |
@@ -34,6 +34,14 @@ | @@ -34,6 +34,14 @@ | ||
34 | 34 | ||
35 | {{!热门品牌}} | 35 | {{!热门品牌}} |
36 | {{# hotBrands}} | 36 | {{# hotBrands}} |
37 | - {{> brand/hot-brand}} | 37 | + {{> index/floor-header}} |
38 | + <div class="logo-brand " data-url="{{brandUrl}}"> | ||
39 | + </div> | ||
38 | {{/hotBrands}} | 40 | {{/hotBrands}} |
41 | + | ||
42 | + {{! 热门品类}} | ||
43 | + {{# recommend}} | ||
44 | + {{> index/outlets-recommend}} | ||
45 | + {{/ recommend}} | ||
46 | + | ||
39 | </div> | 47 | </div> |
1 | +{{# tplrecommend}} | ||
2 | +<div class="tpl-recommend clearfix"> | ||
3 | + {{> index/floor-header}} | ||
4 | + <div class="tpl-body clearfix"> | ||
5 | + <div class="tpl-nav"> | ||
6 | + <div class="tpl-keywords"> | ||
7 | + {{#each keyword}} | ||
8 | + <a class="keywords{{@index}}" title="{{name}}" href="{{href}}" target= "_blank"><img src="{{img}}"/></a> | ||
9 | + {{/each}} | ||
10 | + </div> | ||
11 | + <div class="tpl-category clearfix"> | ||
12 | + {{#each category}} | ||
13 | + <a href="{{href}}" target= "_blank">{{name}}</a> | ||
14 | + {{/each}} | ||
15 | + </div> | ||
16 | + </div> | ||
17 | + <div class="tpl-brands imgopacity clearfix"> | ||
18 | + {{#each brands}} | ||
19 | + <a title="{{name}}" href="{{href}}" target= "_blank"><img src="{{img}}"/></a> | ||
20 | + {{/each}} | ||
21 | + </div> | ||
22 | + <div class="tpl-types imgopacity clearfix"> | ||
23 | + <ul> | ||
24 | + {{#each types}} | ||
25 | + <li><a title="{{name}}" href="{{href}}" target= "_blank"><img src="{{img}}"/></a></li> | ||
26 | + {{/each}} | ||
27 | + </ul> | ||
28 | + </div> | ||
29 | + </div> | ||
30 | +</div> | ||
31 | +{{/ tplrecommend}} |
public/js/common/accordion.js
0 → 100644
1 | +var Slide = require('./yohoui/YH.slide'); | ||
2 | +var $ = require('yoho.jquery'); | ||
3 | + | ||
4 | +var $contain = $('.slide-accordion'); | ||
5 | +var $item = $contain.find('li'); | ||
6 | + | ||
7 | +var $width = $item.width(); | ||
8 | +var $spn = parseInt($('.home-page').width()) === 1150 ? (120 + 5) : (102 + 5); | ||
9 | +var slide; | ||
10 | + | ||
11 | +function switchfun(to) { | ||
12 | + $item.each(function(index) { | ||
13 | + $(this).css('zIndex', index); | ||
14 | + if (index <= to) { | ||
15 | + $(this).stop().animate({ | ||
16 | + left: index * $spn | ||
17 | + }, 400); | ||
18 | + } else { | ||
19 | + $(this).stop().animate({ | ||
20 | + left: (to) * $spn + $width + $spn * (index - to - 1) | ||
21 | + }, 400); | ||
22 | + } | ||
23 | + }); | ||
24 | +} | ||
25 | + | ||
26 | +switchfun(0); | ||
27 | + | ||
28 | +slide = new Slide({ | ||
29 | + length: 5, | ||
30 | + loop: false, | ||
31 | + auto: false, | ||
32 | + timeout: 2, | ||
33 | + index: 0 | ||
34 | +}); | ||
35 | + | ||
36 | +slide.on('change', function(data) { | ||
37 | + switchfun(data.to); | ||
38 | +}); | ||
39 | + | ||
40 | +$item.mouseover(function() { | ||
41 | + slide.go($(this).index()); | ||
42 | +}); | ||
43 | + | ||
44 | +slide.init(); |
public/js/common/dialog.js
0 → 100644
1 | +/** | ||
2 | + * 弹框公共组件 | ||
3 | + * @author: xuqi<qi.xu@yoho.cn> | ||
4 | + * @date: 2016/2/24 | ||
5 | + */ | ||
6 | + | ||
7 | +var $ = require('yoho.jquery'), | ||
8 | + Handlebars = require('yoho.handlebars'); | ||
9 | + | ||
10 | +var defaultOptions = { | ||
11 | + mask: true, | ||
12 | + closeIcon: true | ||
13 | +}; | ||
14 | + | ||
15 | +var tpl = | ||
16 | + '<div class="yoho-dialog {{className}} hide">' + | ||
17 | + '{{#if closeIcon}}' + | ||
18 | + '<span class="close">' + | ||
19 | + '<i class="iconfont"></i>' + | ||
20 | + '</span>' + | ||
21 | + '{{/if}}' + | ||
22 | + '<div class="content">' + | ||
23 | + '{{{content}}}' + | ||
24 | + '</div>' + | ||
25 | + '<div class="btns">' + | ||
26 | + '{{# btns}}' + | ||
27 | + '<span {{#if id}}id="dialog-{{id}}"{{/if}} class="btn{{#each btnClass}} {{.}}{{/each}}">' + | ||
28 | + '{{name}}' + | ||
29 | + '</span>' + | ||
30 | + '{{/ btns}}' + | ||
31 | + '</div>' + | ||
32 | + '</div>'; | ||
33 | + | ||
34 | +var tplFn = Handlebars.compile(tpl); | ||
35 | + | ||
36 | +// 背景蒙版 | ||
37 | +function createMask() { | ||
38 | + if ($('.body-mask').length === 0) { | ||
39 | + $('body').append('<div class="body-mask hide"></div>'); | ||
40 | + } | ||
41 | + | ||
42 | + return $('.body-mask').css({ | ||
43 | + height: $(document).height(), | ||
44 | + width: $(document).width() | ||
45 | + }); | ||
46 | +} | ||
47 | + | ||
48 | +function createDialog(data) { | ||
49 | + $('body').append(tplFn(data)); | ||
50 | + | ||
51 | + return $('.yoho-dialog'); | ||
52 | +} | ||
53 | + | ||
54 | +function Dialog(options) { | ||
55 | + var opt = $.extend({}, defaultOptions, options); | ||
56 | + var that = this, | ||
57 | + i; | ||
58 | + | ||
59 | + // 实现继承时,只返回实例,不生成html | ||
60 | + if (opt.inherit) { | ||
61 | + return this; | ||
62 | + } | ||
63 | + | ||
64 | + if (opt.mask) { | ||
65 | + that.$mask = createMask(); | ||
66 | + } | ||
67 | + that.$el = createDialog(opt); | ||
68 | + | ||
69 | + // 绑定x关闭事件 | ||
70 | + that.$el.find('.close').click(function() { | ||
71 | + that.close(); | ||
72 | + }); | ||
73 | + | ||
74 | + function bindBtnEvt(index) { | ||
75 | + that.$el.find('#dialog-' + opt.btns[index].id).on('click', function() { | ||
76 | + opt.btns[index].cb && opt.btns[index].cb(); | ||
77 | + }); | ||
78 | + } | ||
79 | + | ||
80 | + // 绑定按钮事件 | ||
81 | + if (opt.btns) { | ||
82 | + for (i = 0; i < opt.btns.length; i++) { | ||
83 | + bindBtnEvt(i); | ||
84 | + } | ||
85 | + } | ||
86 | +} | ||
87 | + | ||
88 | +Dialog.prototype.close = function() { | ||
89 | + this.$mask && this.$mask.addClass('hide'); | ||
90 | + this.$el.remove(); | ||
91 | +}; | ||
92 | + | ||
93 | +Dialog.prototype.show = function() { | ||
94 | + this.$mask && this.$mask.removeClass('hide'); | ||
95 | + this.$el.removeClass('hide').css({ | ||
96 | + 'margin-top': -this.$el.height() / 2, | ||
97 | + 'margin-left': -this.$el.width() / 2 | ||
98 | + }); | ||
99 | +}; | ||
100 | + | ||
101 | +exports.Dialog = Dialog; | ||
102 | + | ||
103 | +// Alert | ||
104 | +function Alert(content) { | ||
105 | + var that = this; | ||
106 | + var option = { | ||
107 | + content: content, | ||
108 | + className: 'alert-dialog', | ||
109 | + btns: [ | ||
110 | + { | ||
111 | + id: 'alert-sure', | ||
112 | + btnClass: ['alert-sure'], | ||
113 | + name: '确定', | ||
114 | + cb: function() { | ||
115 | + that.close(); | ||
116 | + } | ||
117 | + } | ||
118 | + ] | ||
119 | + }; | ||
120 | + | ||
121 | + Dialog.call(this, option); | ||
122 | +} | ||
123 | + | ||
124 | +Alert.prototype = new Dialog({ | ||
125 | + inherit: true | ||
126 | +}); | ||
127 | +Alert.prototype.constructor = Alert; | ||
128 | +exports.Alert = Alert; | ||
129 | + | ||
130 | +// Confirm | ||
131 | +function Confirm(opt) { | ||
132 | + var that = this; | ||
133 | + | ||
134 | + var option = { | ||
135 | + content: opt.content, | ||
136 | + className: 'confirm-dialog', | ||
137 | + btns: [ | ||
138 | + { | ||
139 | + id: 'confirm-sure', | ||
140 | + btnClass: ['confirm-sure'], | ||
141 | + name: '确定', | ||
142 | + cb: opt.cb | ||
143 | + }, | ||
144 | + { | ||
145 | + id: 'confirm-cancel', | ||
146 | + btnClass: ['confirm-cancel'], | ||
147 | + name: '取消', | ||
148 | + cb: function() { | ||
149 | + that.close(); | ||
150 | + } | ||
151 | + } | ||
152 | + ] | ||
153 | + }; | ||
154 | + | ||
155 | + Dialog.call(this, option); | ||
156 | +} | ||
157 | + | ||
158 | +Confirm.prototype = new Dialog({ | ||
159 | + inherit: true | ||
160 | +}); | ||
161 | +Confirm.prototype.constructor = Confirm; | ||
162 | +exports.Confirm = Confirm; |
@@ -83,7 +83,6 @@ var $ = require('yoho-jquery'), | @@ -83,7 +83,6 @@ var $ = require('yoho-jquery'), | ||
83 | return; | 83 | return; |
84 | } | 84 | } |
85 | 85 | ||
86 | - that._createHelper(); | ||
87 | brandHtml = '\{{#brandList logoBrand}}' + | 86 | brandHtml = '\{{#brandList logoBrand}}' + |
88 | '<a href="\{{href}}" target="_blank"><img class="lazy" data-original="\{{img}}" alt=""></a>' + | 87 | '<a href="\{{href}}" target="_blank"><img class="lazy" data-original="\{{img}}" alt=""></a>' + |
89 | '\{{/brandList}}'; | 88 | '\{{/brandList}}'; |
public/js/common/new-arrivls.js
0 → 100644
1 | +var $ = require('yoho.jquery'), | ||
2 | + lazyload = require('yoho.lazyload'); | ||
3 | +var Handlebars = require('yoho.handlebars'); | ||
4 | + | ||
5 | +function InfiniteLoad(options) { | ||
6 | + var defaults = { | ||
7 | + index: 0, | ||
8 | + isload: true, // 是否正在加载 | ||
9 | + isrun: true, // 判断是否执行 | ||
10 | + offset: { | ||
11 | + height: null, | ||
12 | + width: null | ||
13 | + } | ||
14 | + }; | ||
15 | + | ||
16 | + this.registerEvent = { | ||
17 | + before: [], | ||
18 | + change: [], | ||
19 | + after: [] | ||
20 | + }; | ||
21 | + | ||
22 | + this.options = $.extend(true, {}, defaults, options); | ||
23 | + | ||
24 | + return this; | ||
25 | +} | ||
26 | + | ||
27 | +InfiniteLoad.prototype.on = function(name, callback) { | ||
28 | + var g = this; | ||
29 | + var _e = g.registerEvent[name]; | ||
30 | + | ||
31 | + if (_e) { | ||
32 | + _e.push(callback); | ||
33 | + } | ||
34 | + return _e; | ||
35 | +}; | ||
36 | + | ||
37 | +InfiniteLoad.prototype.exect = function(key, params) { | ||
38 | + var g = this; | ||
39 | + var e; | ||
40 | + | ||
41 | + if (g.registerEvent[key] && g.registerEvent[key].length > 0) { | ||
42 | + for (e in g.registerEvent[key]) { | ||
43 | + if (g.registerEvent[key].hasOwnProperty(e)) { | ||
44 | + g.registerEvent[key][e](params); | ||
45 | + } | ||
46 | + } | ||
47 | + } | ||
48 | +}; | ||
49 | + | ||
50 | +InfiniteLoad.prototype.init = function() { | ||
51 | + var g = this; | ||
52 | + var p = this.options; | ||
53 | + | ||
54 | + function __loadMore() { | ||
55 | + | ||
56 | + if (p.isrun && p.isload && g.__directionCalculation()) { | ||
57 | + p.isload = false; | ||
58 | + p.index++; | ||
59 | + g.exect('after', p); | ||
60 | + } | ||
61 | + | ||
62 | + g.exect('change', p); | ||
63 | + } | ||
64 | + | ||
65 | + g.exect('before', p); | ||
66 | + | ||
67 | + $(window).scroll(__loadMore); | ||
68 | +}; | ||
69 | + | ||
70 | +InfiniteLoad.prototype.emit = function() { | ||
71 | + var p = this.options; | ||
72 | + | ||
73 | + p.isload = true; | ||
74 | +}; | ||
75 | + | ||
76 | +InfiniteLoad.prototype.stop = function() { | ||
77 | + var p = this.options; | ||
78 | + | ||
79 | + p.isrun = false; | ||
80 | + p.isload = false; | ||
81 | +}; | ||
82 | + | ||
83 | +InfiniteLoad.prototype.__directionCalculation = function() { | ||
84 | + var p = this.options; | ||
85 | + | ||
86 | + if (p.offset.height && p.offset.height() > 0 && $(window).scrollTop() + $(window).height() >= p.offset.height()) { | ||
87 | + return true; | ||
88 | + } | ||
89 | + return false; | ||
90 | +}; | ||
91 | + | ||
92 | +module.exports = function(data) { | ||
93 | + var $container = $('#newarrivals .goods-container'); | ||
94 | + var $load = $('.loading a'); | ||
95 | + var load = new InfiniteLoad({ | ||
96 | + index: 1, | ||
97 | + isload: false, | ||
98 | + offset: { | ||
99 | + height: function() { | ||
100 | + return parseFloat($container.offset().top) + parseFloat($container.height()) - 200; | ||
101 | + } | ||
102 | + } | ||
103 | + }); | ||
104 | + var loadAjax; | ||
105 | + var url = data.url, | ||
106 | + count = data.count, | ||
107 | + rows = data.rows; | ||
108 | + | ||
109 | + data.pageIndex = 0; | ||
110 | + | ||
111 | + delete data.url; | ||
112 | + delete data.count; | ||
113 | + delete data.rows; | ||
114 | + | ||
115 | + loadAjax = function(url, data, count) { | ||
116 | + | ||
117 | + var options = { | ||
118 | + type: 'POST', | ||
119 | + url: url, | ||
120 | + success: function(result) { | ||
121 | + var code = result.code; | ||
122 | + var myTemplate, len, pos; | ||
123 | + | ||
124 | + if (code === 200) { | ||
125 | + len = result.goods.length % count; | ||
126 | + pos = result.goods.length - len - 1; | ||
127 | + | ||
128 | + result.goods.splice(pos, len); | ||
129 | + | ||
130 | + myTemplate = Handlebars.compile(load.tpl); | ||
131 | + | ||
132 | + $container.append(myTemplate(result.goods)); | ||
133 | + data.pageIndex = data.pageIndex + result.goods.length; | ||
134 | + | ||
135 | + // 懒加载插件貌似有点问题,图片先直接展示 | ||
136 | + lazyload($container.find('img.lazy')); | ||
137 | + | ||
138 | + load.emit(); | ||
139 | + } else { | ||
140 | + | ||
141 | + load.stop(); | ||
142 | + $load.html('查看更多'); | ||
143 | + } | ||
144 | + }, | ||
145 | + error: function() { | ||
146 | + | ||
147 | + load.stop(); | ||
148 | + $load.html('网络断开连接了~'); | ||
149 | + } | ||
150 | + }; | ||
151 | + | ||
152 | + options.data = data; | ||
153 | + $.ajax(options); | ||
154 | + }; | ||
155 | + | ||
156 | + | ||
157 | + load.on('after', function(p) { | ||
158 | + | ||
159 | + data.pageCount = count * rows[1]; | ||
160 | + | ||
161 | + loadAjax(url, data); | ||
162 | + }); | ||
163 | + | ||
164 | + load.on('before', function(p) { | ||
165 | + | ||
166 | + | ||
167 | + load.tpl = '{{#each this}}'; | ||
168 | + load.tpl += '<div class="good-info imgopacity" data-skn="{{skn}}">'; | ||
169 | + load.tpl += ' <div class="tag-container clearfix">'; | ||
170 | + load.tpl += ' {{# tags}}'; | ||
171 | + load.tpl += ' {{# isNew}}'; | ||
172 | + load.tpl += ' <span class="good-tag new-tag">NEW</span>'; | ||
173 | + load.tpl += ' {{/ isNew}}'; | ||
174 | + load.tpl += ' {{# isReNew}}'; | ||
175 | + load.tpl += ' <span class="good-tag renew-tag">再到着</span>'; | ||
176 | + load.tpl += ' {{/ isReNew}}'; | ||
177 | + load.tpl += ' {{# isSale}}'; | ||
178 | + load.tpl += ' <span class="good-tag sale-tag">SALE</span>'; | ||
179 | + load.tpl += ' {{/ isSale}}'; | ||
180 | + load.tpl += ' {{# isNewFestival}}'; | ||
181 | + load.tpl += ' <span class="good-tag new-festival-tag">新品节</span>'; | ||
182 | + load.tpl += ' {{/ isNewFestival}}'; | ||
183 | + load.tpl += ' {{# isLimit}}'; | ||
184 | + load.tpl += ' <span class="good-tag limit-tag">限量商品</span>'; | ||
185 | + load.tpl += ' {{/ isLimit}}'; | ||
186 | + load.tpl += ' {{# isYearEndPromotion}}'; | ||
187 | + load.tpl += ' <span class="good-tag yep-tag">年终大促</span>'; | ||
188 | + load.tpl += ' {{/ isYearEndPromotion}}'; | ||
189 | + load.tpl += ' {{# isYearMidPromotion}}'; | ||
190 | + load.tpl += ' <span class="good-tag ymp-tag">年中热促</span>'; | ||
191 | + load.tpl += ' {{/ isYearMidPromotion}}'; | ||
192 | + load.tpl += ' {{/ tags}}'; | ||
193 | + load.tpl += ' </div>'; | ||
194 | + load.tpl += ' <div class="good-detail-img">'; | ||
195 | + load.tpl += ' <a class="good-thumb" href="{{url}}" target= "_blank">'; | ||
196 | + load.tpl += ' <img class="lazy" data-original="{{thumb}}">'; | ||
197 | + load.tpl += ' </a>'; | ||
198 | + load.tpl += ' {{# isFew}}'; | ||
199 | + load.tpl += ' <p class="few-tag">即将售罄</p>'; | ||
200 | + load.tpl += ' {{/ isFew}}'; | ||
201 | + | ||
202 | + load.tpl += ' {{#if showColBtn}}'; | ||
203 | + load.tpl += ' <span class="col-btn iconfont{{#if coled}} coled{{/if}}"></span>'; | ||
204 | + load.tpl += ' {{/if}}'; | ||
205 | + load.tpl += ' </div>'; | ||
206 | + load.tpl += ' <div class="good-detail-text">'; | ||
207 | + load.tpl += ' <a href="{{url}}" target= "_blank">{{name}}</a>'; | ||
208 | + load.tpl += ' <p class="price">'; | ||
209 | + load.tpl += ' <span class="sale-price{{#unless marketPrice}}prime-cost{{/unless}}">'; | ||
210 | + load.tpl += ' ¥{{salePrice}}'; | ||
211 | + load.tpl += ' </span>'; | ||
212 | + load.tpl += ' {{# marketPrice}}'; | ||
213 | + load.tpl += ' <span class="market-price">¥{{.}}</span>'; | ||
214 | + load.tpl += ' {{/ marketPrice}}'; | ||
215 | + load.tpl += ' </p>'; | ||
216 | + load.tpl += ' </div>'; | ||
217 | + load.tpl += '</div>'; | ||
218 | + load.tpl += '{{/each}}'; | ||
219 | + | ||
220 | + | ||
221 | + data.pageCount = count * rows[0]; | ||
222 | + | ||
223 | + loadAjax(url, data, data.count); | ||
224 | + | ||
225 | + // load.emit(); | ||
226 | + }); | ||
227 | + | ||
228 | + load.init(); | ||
229 | + | ||
230 | +}; |
public/js/common/share.js
0 → 100644
1 | +/** | ||
2 | + * 分享 | ||
3 | + * @author: xuqi<qi.xu@yoho.cn> | ||
4 | + * @date: 2016/3/1 | ||
5 | + */ | ||
6 | + | ||
7 | +var $ = require('yoho.jquery'); | ||
8 | + | ||
9 | +function shareBase(options) { | ||
10 | + var openUrl = ''; | ||
11 | + var defOption = { | ||
12 | + title: '', | ||
13 | + url: window.location.href, | ||
14 | + weixinUrl: '', | ||
15 | + image: '', | ||
16 | + desc: '', | ||
17 | + channel: '' | ||
18 | + }; | ||
19 | + var shareChannels = ['weibo', 'tweibo', 'qzone', 'renren', 'qq', 'douban', 'weixin']; | ||
20 | + var sharebox; | ||
21 | + var shareCon = '<em><i></i></em>'; | ||
22 | + | ||
23 | + defOption = $.extend(defOption, options); | ||
24 | + | ||
25 | + if ($.inArray(defOption.channel, shareChannels) === -1) { | ||
26 | + alert('不存在的分享平台!'); | ||
27 | + return false; | ||
28 | + } | ||
29 | + | ||
30 | + switch (defOption.channel) { | ||
31 | + case 'weibo': | ||
32 | + openUrl = 'http://service.weibo.com/share/share.php?url=' + defOption.url + '&title=' + | ||
33 | + defOption.title + '&appkey=3739328910&searchPic=true&pic=' + defOption.image; | ||
34 | + break; | ||
35 | + case 'tweibo': | ||
36 | + openUrl = 'http://share.v.t.qq.com/index.php?c=share&a=index&url=' + defOption.url + '&title=' + | ||
37 | + defOption.title + '&appkey=c0af9c29e0900813028c2ccb42021792&pic=' + defOption.image; | ||
38 | + break; | ||
39 | + case 'qzone': | ||
40 | + openUrl = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=' + defOption.url + '&title=' + | ||
41 | + defOption.title + '&desc=&summary=' + defOption.desc + '&site=YOHO!有货&pics=' + defOption.image; | ||
42 | + break; | ||
43 | + case 'renren': | ||
44 | + openUrl = 'http://widget.renren.com/dialog/share?resourceUrl=' + defOption.url + '&srcUrl=' + | ||
45 | + defOption.url + '&desc=' + defOption.desc + '&title=' + defOption.title + '&description=' + | ||
46 | + defOption.desc + '&pic=' + defOption.image; | ||
47 | + break; | ||
48 | + case 'qq': | ||
49 | + openUrl = 'http://connect.qq.com/widget/shareqq/index.html?url=' + defOption.url + '&desc=' + | ||
50 | + defOption.desc + '&title=' + defOption.title.replace('%', '') + '&desc=&summary=' + | ||
51 | + defOption.desc + '&site=YOHO!有货&pics=' + defOption.image; | ||
52 | + break; | ||
53 | + case 'weixin': | ||
54 | + openUrl = 'http://s.jiathis.com/qrcode.php?url=' + defOption.weixinUrl + '&desc=' + | ||
55 | + defOption.desc + '&title=' + defOption.title + '&description=' + | ||
56 | + defOption.desc + '&pic=' + defOption.image; | ||
57 | + break; | ||
58 | + case 'douban': | ||
59 | + openUrl = 'http://www.douban.com/share/service?href=' + defOption.url + '&text=' + | ||
60 | + defOption.desc + '&image=' + defOption.image + '&title=' + defOption.title + '&comment='; | ||
61 | + break; | ||
62 | + } | ||
63 | + | ||
64 | + if (defOption.channel === 'weixin') { | ||
65 | + if (!defOption.self) { | ||
66 | + return; | ||
67 | + } | ||
68 | + | ||
69 | + sharebox = defOption.self.closest('.share-to').find('.weixin-share-box'); | ||
70 | + | ||
71 | + if (sharebox.length > 0) { | ||
72 | + shareCon += '<div class="con"><h2>分享到微信朋友圈</h2><p class="pic">' + | ||
73 | + '<img src="' + openUrl + '" /></p><p class="w">打开微信,点击底部得“发现”,使用<br/>“扫一扫“即可将网页分享到我的朋友圈。</p>' + | ||
74 | + '<a href="javascript:void(0)" class="close">x</a></div>'; | ||
75 | + sharebox.find('div').length > 0 ? sharebox.show() : sharebox.html(shareCon).show(); | ||
76 | + | ||
77 | + sharebox.find('.close').click(function() { | ||
78 | + $(this).closest('.weixin-share-box').hide(); | ||
79 | + }); | ||
80 | + } | ||
81 | + } else { | ||
82 | + window.open(encodeURI(openUrl)); | ||
83 | + } | ||
84 | +} | ||
85 | + | ||
86 | +function share(channel, self) { | ||
87 | + var title = document.title.replace(/(^\s*)|(\s*$)/g, ''); | ||
88 | + var desc = $('#share-desc').val(); | ||
89 | + var image = $('#share-img').val(); | ||
90 | + var weixinUrl = $('#weixin-url').val(); | ||
91 | + | ||
92 | + | ||
93 | + if (channel === 'weibo' || channel === 'tqq') { | ||
94 | + shareBase({ | ||
95 | + channel: channel, | ||
96 | + title: title, | ||
97 | + image: image | ||
98 | + }); | ||
99 | + } else { | ||
100 | + shareBase({ | ||
101 | + channel: channel, | ||
102 | + title: title, | ||
103 | + desc: desc, | ||
104 | + image: image, | ||
105 | + self: self, | ||
106 | + weixinUrl: weixinUrl | ||
107 | + }); | ||
108 | + } | ||
109 | +} | ||
110 | + | ||
111 | +$('.share-wrapper').on('click', 'i', function() { | ||
112 | + var $el = $(this), | ||
113 | + type = $el.data('type'); | ||
114 | + | ||
115 | + if (type === 'weixin') { | ||
116 | + share(type, $el); | ||
117 | + } else { | ||
118 | + share(type); | ||
119 | + } | ||
120 | +}); |
public/js/common/slider2.js
0 → 100644
1 | +/** | ||
2 | + * (品牌优选)图片幻灯片插件 | ||
3 | + * @author: wangqing(robin.wang@yoho.cn) | ||
4 | + * @date: 205/7/2 | ||
5 | + */ | ||
6 | +var $ = require('yoho-jquery'); | ||
7 | + | ||
8 | +(function() { | ||
9 | + $.fn.slider2 = function(options) { | ||
10 | + function autoplay(index, limit, toright) { | ||
11 | + if (toright === true) { | ||
12 | + $('.next').trigger('click'); | ||
13 | + if (index === (limit - 3)) { | ||
14 | + autoplayrecycle(--index, limit, false); | ||
15 | + } else { | ||
16 | + autoplayrecycle(++index, limit, true); | ||
17 | + } | ||
18 | + } else { | ||
19 | + $('.prev').trigger('click'); | ||
20 | + if (index === 0) { | ||
21 | + autoplayrecycle(++index, limit, true); | ||
22 | + } else { | ||
23 | + autoplayrecycle(--index, limit, false); | ||
24 | + } | ||
25 | + } | ||
26 | + } | ||
27 | + | ||
28 | + function autoplayrecycle(index, limit, toright) { | ||
29 | + window.setTimeout(autoplay, $.fn.slider2.defaults.delaytime, index, limit, toright); | ||
30 | + } | ||
31 | + | ||
32 | + function changePic(index, width, callback) { | ||
33 | + var offersetleft = -(index * width); | ||
34 | + | ||
35 | + $('.img-list') | ||
36 | + .animate({ | ||
37 | + 'margin-left': offersetleft + 'px' | ||
38 | + }, 'slow', callback); | ||
39 | + | ||
40 | + } | ||
41 | + $.fn.slider2.defaults = { | ||
42 | + index: 0, | ||
43 | + shownum: 3, | ||
44 | + autoplay: false, | ||
45 | + delaytime: 3000 | ||
46 | + }; | ||
47 | + return this.each(function() { | ||
48 | + var opts = $.extend({}, $.fn.slider2.defaults, options); | ||
49 | + var mr = parseInt($('.img-item').css('margin-right')); | ||
50 | + var $banneritems = $('.img-item'); | ||
51 | + var bannerarr = []; | ||
52 | + var _width = $banneritems.outerWidth() + mr, | ||
53 | + _size = $banneritems.length, | ||
54 | + j = 0; | ||
55 | + | ||
56 | + if (_size <= 3) { | ||
57 | + $(this).find('.img-brand-switch').hide(); | ||
58 | + return; | ||
59 | + } | ||
60 | + for (j = 0; j < $banneritems.length; j++) { | ||
61 | + bannerarr.push($banneritems[j]); | ||
62 | + } | ||
63 | + _size = bannerarr.length; | ||
64 | + $(this).find('.img-list').css({ | ||
65 | + width: (_width * _size) | ||
66 | + }); | ||
67 | + $(this).find('.next').on('click', function(e) { | ||
68 | + var i = 0, | ||
69 | + _obj = null; | ||
70 | + | ||
71 | + e.preventDefault(); | ||
72 | + | ||
73 | + changePic(3, _width, function() { | ||
74 | + for (i = 0; i < 3; i++) { | ||
75 | + _obj = bannerarr.shift(); | ||
76 | + | ||
77 | + $('.img-item').parent().append(_obj.outerHTML); | ||
78 | + bannerarr.push(_obj); | ||
79 | + } | ||
80 | + $('.img-item').first().remove(); | ||
81 | + $('.img-item').first().remove(); | ||
82 | + $('.img-item').first().remove(); | ||
83 | + $('.img-list').css({ | ||
84 | + 'margin-left': '0' | ||
85 | + }); | ||
86 | + }); | ||
87 | + }); | ||
88 | + $(this).find('.prev').on('click', function(e) { | ||
89 | + var i = 0, | ||
90 | + _obj = null, | ||
91 | + offersetleft = ''; | ||
92 | + | ||
93 | + e.preventDefault(); | ||
94 | + for (i = 0; i < 3; i++) { | ||
95 | + _obj = bannerarr.pop(); | ||
96 | + | ||
97 | + $('.img-item').parent().prepend(_obj.outerHTML); | ||
98 | + bannerarr.unshift(_obj); | ||
99 | + } | ||
100 | + offersetleft = 3 * _width; | ||
101 | + $('.img-item').last().remove(); | ||
102 | + $('.img-item').last().remove(); | ||
103 | + $('.img-item').last().remove(); | ||
104 | + $('.img-list').css({ | ||
105 | + 'margin-left': -offersetleft + 'px' | ||
106 | + }); | ||
107 | + changePic(0, _width); | ||
108 | + }); | ||
109 | + if (opts.autoplay === true) { | ||
110 | + autoplayrecycle(opts.index, _size, true); | ||
111 | + } | ||
112 | + }); | ||
113 | + | ||
114 | + }; | ||
115 | + | ||
116 | +}()); |
public/js/common/yohoui/YH.base.js
0 → 100644
1 | +var assembly; | ||
2 | +var classtype = { | ||
3 | + '[object Array]': 'array', | ||
4 | + '[object Boolean]': 'boolean', | ||
5 | + '[object Date]': 'date', | ||
6 | + '[object Function]': 'function', | ||
7 | + '[object Number]': 'number', | ||
8 | + '[object Object]': 'object', | ||
9 | + '[object RegExp]': 'regexp', | ||
10 | + '[object String]': 'string' | ||
11 | +}; | ||
12 | +var me = { | ||
13 | + __Index: 0, | ||
14 | + list: [], | ||
15 | + get: function(id) { | ||
16 | + return id === undefined ? this.list : this.list[id]; | ||
17 | + }, | ||
18 | + fn: function() { }, | ||
19 | + inherit: function(childClass, parentClass) { | ||
20 | + var Constructor = me.fn; | ||
21 | + | ||
22 | + Constructor.prototype = parentClass.prototype; | ||
23 | + childClass.prototype = new Constructor(); | ||
24 | + | ||
25 | + childClass.prototype.constructor = childClass; | ||
26 | + childClass.superclass = parentClass.prototype; | ||
27 | + | ||
28 | + if (childClass.prototype.constructor === Object.prototype.constructor) { | ||
29 | + childClass.prototype.constructor = parentClass; | ||
30 | + } | ||
31 | + }, | ||
32 | + extend: function(obj, newProperties) { | ||
33 | + var key; | ||
34 | + | ||
35 | + for (key in newProperties) { | ||
36 | + if (newProperties.hasOwnProperty(key)) { | ||
37 | + obj[key] = newProperties[key]; | ||
38 | + } | ||
39 | + } | ||
40 | + return obj; | ||
41 | + }, | ||
42 | + copy: function(TargetClass, obj, newProperties) { | ||
43 | + var value, o, key; | ||
44 | + | ||
45 | + if (typeof obj !== 'object') { | ||
46 | + return obj; | ||
47 | + } | ||
48 | + value = obj.valueOf(); | ||
49 | + if (obj !== value) { | ||
50 | + return new obj.constructor(value); | ||
51 | + } | ||
52 | + if (obj instanceof obj.constructor && obj.constructor !== Object) { | ||
53 | + if (TargetClass) { | ||
54 | + o = new TargetClass(); | ||
55 | + } else { | ||
56 | + o = me.clone(obj.constructor.prototype); | ||
57 | + } | ||
58 | + | ||
59 | + for (key in obj) { | ||
60 | + if (TargetClass || obj.hasOwnProperty(key)) { | ||
61 | + o[key] = obj[key]; | ||
62 | + } | ||
63 | + } | ||
64 | + } else { | ||
65 | + o = {}; | ||
66 | + for (key in obj) { | ||
67 | + if (o.hasOwnProperty(key)) { | ||
68 | + o[key] = obj[key]; | ||
69 | + } | ||
70 | + } | ||
71 | + } | ||
72 | + if (newProperties) { | ||
73 | + for (key in newProperties) { | ||
74 | + if (o.hasOwnProperty(key)) { | ||
75 | + o[key] = newProperties[key]; | ||
76 | + } | ||
77 | + } | ||
78 | + } | ||
79 | + | ||
80 | + return o; | ||
81 | + }, | ||
82 | + clone: function(obj) { | ||
83 | + me.__cloneFunc.prototype = obj; | ||
84 | + return new me.__cloneFunc(); | ||
85 | + }, | ||
86 | + __cloneFunc: function() { | ||
87 | + }, | ||
88 | + delegate: function(func, scope) { | ||
89 | + var args; | ||
90 | + | ||
91 | + scope = scope || window; | ||
92 | + | ||
93 | + if (arguments.length > 2) { | ||
94 | + args = Array.prototype.slice.call(arguments, 2); | ||
95 | + | ||
96 | + return function() { | ||
97 | + return func.apply(scope, args); | ||
98 | + }; | ||
99 | + } else { | ||
100 | + return function() { | ||
101 | + return func.call(scope); | ||
102 | + }; | ||
103 | + } | ||
104 | + }, | ||
105 | + dom: function($select, classCss) { | ||
106 | + var wrap = $select; | ||
107 | + var name, DOM = { | ||
108 | + wrap: wrap | ||
109 | + }, | ||
110 | + els = wrap[0].getElementsByTagName('*'), | ||
111 | + elsLen = els.length; | ||
112 | + var i; | ||
113 | + | ||
114 | + for (i = 0; i < elsLen; i++) { | ||
115 | + name = els[i].className; | ||
116 | + if (name.indexOf(classCss) > -1) { | ||
117 | + name = name.split(classCss)[1]; | ||
118 | + } | ||
119 | + if (name) { | ||
120 | + DOM[name] = wrap.find(els[i]); | ||
121 | + } | ||
122 | + } | ||
123 | + return DOM; | ||
124 | + }, | ||
125 | + | ||
126 | + // 模板引擎 | ||
127 | + template: function() { | ||
128 | + var result, key, reg, i; | ||
129 | + var args = arguments; | ||
130 | + | ||
131 | + if (args.length > 0) { | ||
132 | + if (me.isString(args[0])) { | ||
133 | + result = args[0]; | ||
134 | + if (args.length === 2 && me.isObject(args[1])) { | ||
135 | + for (key in args[1]) { | ||
136 | + if (args[1][key] !== undefined) { | ||
137 | + reg = new RegExp('({' + key + '})', 'g'); | ||
138 | + | ||
139 | + result = result.replace(reg, args[1][key]); | ||
140 | + } | ||
141 | + } | ||
142 | + } else { | ||
143 | + for (i = 1; i < args.length; i++) { | ||
144 | + if (args[i] !== undefined) { | ||
145 | + reg = new RegExp('({[' + (i - 1) + ']})', 'g'); | ||
146 | + | ||
147 | + result = result.replace(reg, args[i]); | ||
148 | + } | ||
149 | + } | ||
150 | + } | ||
151 | + } | ||
152 | + } | ||
153 | + return result; | ||
154 | + }, | ||
155 | + __type: function(obj) { | ||
156 | + return obj == null ? String(obj) : classtype[Object.prototype.toString.call(obj)] || 'object'; | ||
157 | + }, | ||
158 | + isObject: function(obj) { | ||
159 | + return this.isFunction(obj) || !!(obj && 'object' === typeof obj); | ||
160 | + }, | ||
161 | + isFunction: function(obj) { | ||
162 | + return this.__type(obj) === 'function'; | ||
163 | + }, | ||
164 | + isArray: Array.isArray || function(obj) { | ||
165 | + return this.__type(obj) === 'array'; | ||
166 | + }, | ||
167 | + isNum: function(obj) { | ||
168 | + return !isNaN(parseFloat(obj)) && isFinite(obj); | ||
169 | + }, | ||
170 | + isString: function(obj) { | ||
171 | + return this.__type(obj) === 'string'; | ||
172 | + }, | ||
173 | + each: function(data, callback, args) { | ||
174 | + var i, len; | ||
175 | + | ||
176 | + if (me.isArray(data)) { | ||
177 | + for (i = 0, len = data.length; i < len; i++) { | ||
178 | + if (callback.call(data[i], i, data[i], args) === false) { | ||
179 | + break; | ||
180 | + } | ||
181 | + } | ||
182 | + } else { | ||
183 | + | ||
184 | + for (i in data) { | ||
185 | + if (callback.call(data[i], i, data[i], args) === false) { | ||
186 | + break; | ||
187 | + } | ||
188 | + } | ||
189 | + } | ||
190 | + }, | ||
191 | + funManager: { | ||
192 | + __loadList: {}, | ||
193 | + __loadFun: function(item, callback, win) { | ||
194 | + | ||
195 | + if (item.methord && me.isFunction(item.methord())) { | ||
196 | + win = win || window; | ||
197 | + item.methord()(item, function() { | ||
198 | + callback(); | ||
199 | + }, win); | ||
200 | + } | ||
201 | + }, | ||
202 | + load: function(fns, statechange, win, __index) { | ||
203 | + __index = __index || 0; | ||
204 | + | ||
205 | + if (fns[__index]) { | ||
206 | + me.funManager.__loadFun(fns[__index], function() { | ||
207 | + me.funManager.load(fns, statechange, win, __index + 1); | ||
208 | + }, win); | ||
209 | + } | ||
210 | + statechange(__index, win); | ||
211 | + }, | ||
212 | + get: function(id) { | ||
213 | + return this.__loadList[id]; | ||
214 | + } | ||
215 | + }, | ||
216 | + log: function(msg) { | ||
217 | + var console = window.console || { | ||
218 | + log: function() { } | ||
219 | + }; | ||
220 | + | ||
221 | + console.log(msg); | ||
222 | + }, | ||
223 | + Event: { | ||
224 | + mousewheel: function(e) { | ||
225 | + var _eoe = e.originalEvent; | ||
226 | + var _de = _eoe.detail ? _eoe.detail * -1 : _eoe.wheelDelta / 40; | ||
227 | + var _direction = _de < 0 ? -1 : 1; | ||
228 | + | ||
229 | + return { | ||
230 | + direction: _direction, | ||
231 | + unit: _de | ||
232 | + }; | ||
233 | + }, | ||
234 | + __: function(_e, el, event, handle) { | ||
235 | + var key; | ||
236 | + | ||
237 | + for (key in _e) { | ||
238 | + if (window[_e[key].validator]) { | ||
239 | + el[_e[key].validator](_e[key].prefix + event, handle, false); | ||
240 | + break; | ||
241 | + } | ||
242 | + } | ||
243 | + }, | ||
244 | + add: function(el, event, handle) { | ||
245 | + var _e = [ | ||
246 | + { | ||
247 | + validator: 'addEventListener', | ||
248 | + prefix: '' | ||
249 | + }, | ||
250 | + { | ||
251 | + validator: 'attachEvent', | ||
252 | + prefix: 'on' | ||
253 | + } | ||
254 | + ]; | ||
255 | + | ||
256 | + this.__(_e, el, event, handle); | ||
257 | + }, | ||
258 | + remove: function(el, event, handle) { | ||
259 | + var _e = [ | ||
260 | + { | ||
261 | + validator: 'removeEventListener', | ||
262 | + prefix: '' | ||
263 | + }, | ||
264 | + { | ||
265 | + validator: 'detachEvent', | ||
266 | + prefix: 'on' | ||
267 | + } | ||
268 | + ]; | ||
269 | + | ||
270 | + this.__(_e, el, event, handle); | ||
271 | + } | ||
272 | + }, | ||
273 | + getUid: function(_name) { | ||
274 | + return me.template('me-{0}{1}-{2}', _name, new Date().getTime(), me.__Index++); | ||
275 | + }, | ||
276 | + Browser: { | ||
277 | + isTouch: function() { | ||
278 | + var msGesture = window.navigator && window.navigator.msPointerEnabled && window.MSGesture; | ||
279 | + | ||
280 | + return (('ontouchstart' in window) || msGesture || window.DocumentTouch) ? true : false; | ||
281 | + }, | ||
282 | + Prefix: function() { | ||
283 | + var i; | ||
284 | + | ||
285 | + var props = ['perspectiveProperty', 'WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective']; | ||
286 | + var obj = document.createElement('div'); | ||
287 | + | ||
288 | + for (i in props) { | ||
289 | + if (obj.style[props[i]] !== undefined) { | ||
290 | + return me.template('-{0}-', props[i].replace('Perspective', '').toLowerCase()); | ||
291 | + } | ||
292 | + } | ||
293 | + }, | ||
294 | + parseURL: function(url) { | ||
295 | + var a = document.createElement('a'); | ||
296 | + var ret, seg, len, i, s; | ||
297 | + | ||
298 | + a.href = url; | ||
299 | + return { | ||
300 | + source: url, | ||
301 | + protocol: a.protocol.replace(':', ''), | ||
302 | + host: a.hostname, | ||
303 | + port: a.port, | ||
304 | + query: a.search, | ||
305 | + params: (function() { | ||
306 | + ret = {}, | ||
307 | + seg = a.search.replace(/^\?/, '').split('&'), | ||
308 | + len = seg.length, i = 0, s; | ||
309 | + | ||
310 | + for (; i < len; i++) { | ||
311 | + if (!seg[i]) { | ||
312 | + continue; | ||
313 | + } | ||
314 | + s = seg[i].split('='); | ||
315 | + ret[s[0]] = s[1]; | ||
316 | + } | ||
317 | + return ret; | ||
318 | + })(), | ||
319 | + file: (a.pathname.match(/\/([^\/?#]+)$/i) || [null, ''])[1], | ||
320 | + hash: a.hash.replace('#', ''), | ||
321 | + path: a.pathname.replace(/^([^\/])/, '/$1'), | ||
322 | + relative: (a.href.match(/tps?:\/\/[^\/]+(.+)/) || [null, ''])[1], | ||
323 | + segments: a.pathname.replace(/^\//, '').split('/') | ||
324 | + }; | ||
325 | + } | ||
326 | + }, | ||
327 | + Array: { | ||
328 | + indexOf: function(array, val) { | ||
329 | + var i; | ||
330 | + | ||
331 | + for (i = 0; i < array.length; i++) { | ||
332 | + if (this[i] === val) { | ||
333 | + return i; | ||
334 | + } | ||
335 | + } | ||
336 | + return -1; | ||
337 | + }, | ||
338 | + remove: function(array, val) { | ||
339 | + var index = this.indexOf(array, val); | ||
340 | + | ||
341 | + if (index > -1) { | ||
342 | + array.splice(index, 1); | ||
343 | + } | ||
344 | + return array; | ||
345 | + } | ||
346 | + } | ||
347 | +}; | ||
348 | + | ||
349 | +assembly = function(options) { | ||
350 | + this.initialized = false; | ||
351 | + this.registerEvent = { | ||
352 | + before: [], | ||
353 | + change: [], | ||
354 | + after: [] | ||
355 | + }; | ||
356 | + this.options = options; | ||
357 | + | ||
358 | + this.init(options); | ||
359 | +}; | ||
360 | + | ||
361 | +assembly.output = function() { | ||
362 | + me.log(me.list); | ||
363 | +}; | ||
364 | +assembly.prototype.oninit = me.fn; | ||
365 | + | ||
366 | +assembly.prototype.init = function(cfg) { | ||
367 | + this.initialized = true; | ||
368 | + | ||
369 | + // function _getClassName(_constructor, _constr) { | ||
370 | + // var _constr = _constr || ""; | ||
371 | + // if (_constructor.superclass) { | ||
372 | + // var args = /(\w+)\.superclass/.exec(_constructor.arguments.callee); | ||
373 | + // if (args != null) { | ||
374 | + // _constr += args[1] + "-"; | ||
375 | + // // return _getClassName(_constructor.superclass.constructor, _constr); | ||
376 | + // } | ||
377 | + // } | ||
378 | + // return _constr; | ||
379 | + // } | ||
380 | + this.__Uid = me.getUid('me'); | ||
381 | + this.oninit(cfg); | ||
382 | + me.list[this.__Uid] = this; | ||
383 | +}; | ||
384 | +assembly.prototype.destory = function() { | ||
385 | + this.initialized = false; | ||
386 | + delete me.list[this.__Uid]; | ||
387 | +}; | ||
388 | +assembly.prototype.getUid = function() { | ||
389 | + return this.__Uid; | ||
390 | +}; | ||
391 | +assembly.prototype.getOptions = function() { | ||
392 | + return this.options; | ||
393 | +}; | ||
394 | +assembly.prototype.config = function() { | ||
395 | + if (arguments.length > 0) { | ||
396 | + if (typeof (arguments[0]) === 'string') { | ||
397 | + if (arguments.length > 1) { | ||
398 | + this.options[arguments[0]] = arguments[1]; | ||
399 | + } else { | ||
400 | + return this.options[name]; | ||
401 | + } | ||
402 | + } | ||
403 | + } else { | ||
404 | + return this.options; | ||
405 | + } | ||
406 | +}; | ||
407 | +assembly.prototype.on = function(name, callback) { | ||
408 | + var __self = this; | ||
409 | + var _e = __self.registerEvent[name]; | ||
410 | + | ||
411 | + if (_e) { | ||
412 | + _e.push(callback); | ||
413 | + } | ||
414 | + return _e; | ||
415 | +}; | ||
416 | +assembly.prototype.off = function(name, callback) { | ||
417 | + var __self = this; | ||
418 | + var _e = __self.registerEvent[name]; | ||
419 | + var e = []; | ||
420 | + | ||
421 | + me.each(_e, function(name, _callback) { | ||
422 | + | ||
423 | + if (_callback === callback) { | ||
424 | + e.push(name); | ||
425 | + } | ||
426 | + }); | ||
427 | + | ||
428 | + me.each(e.reverse(), function(name, _callback) { | ||
429 | + _e.splice(_callback, 1); | ||
430 | + }); | ||
431 | +}; | ||
432 | +me.assembly = assembly; | ||
433 | + | ||
434 | +module.exports = me; |
public/js/common/yohoui/YH.slide.js
0 → 100644
1 | +var me = require('./YH.base'); | ||
2 | + | ||
3 | +var slide = function(options) { | ||
4 | + this.__lastTime = null; | ||
5 | + this.__isStop = false; | ||
6 | + options = me.extend(this.defaults, options); | ||
7 | + slide.superclass.constructor.call(this, options); | ||
8 | +}; | ||
9 | + | ||
10 | +me.inherit(slide, me.assembly); | ||
11 | + | ||
12 | +slide.prototype.oninit = function() { | ||
13 | + var __self = this, | ||
14 | + _o = __self.options; | ||
15 | + | ||
16 | + if (_o.auto) { | ||
17 | + __self.play(); | ||
18 | + } | ||
19 | + __self.go(_o.index); | ||
20 | + return this; | ||
21 | +}; | ||
22 | + | ||
23 | +slide.prototype.go = function(_to, _from) { | ||
24 | + var __self = this, | ||
25 | + _o = __self.options; | ||
26 | + var _direction, _loop, _current, _index, _originalto, o, key, _e; | ||
27 | + | ||
28 | + if (__self.__lastTime) { | ||
29 | + clearTimeout(__self.__lastTime); | ||
30 | + __self.__lastTime = null; | ||
31 | + } | ||
32 | + _from = 'undefined' === typeof _from ? _o.index : _from; | ||
33 | + _direction = _to === _from ? 0 : _to > _from ? 1 : -1; | ||
34 | + _loop = _o.loop, _index = _o.length - 1, _originalto = _to; | ||
35 | + if (_loop) { | ||
36 | + if (_to > _index) { | ||
37 | + _to = _to - _index - 1; | ||
38 | + } else { | ||
39 | + if (0 > _to) { | ||
40 | + _to = _to + _index + 1; | ||
41 | + } else { | ||
42 | + _to = _to; | ||
43 | + } | ||
44 | + } | ||
45 | + } else { | ||
46 | + if (_to > _index) { | ||
47 | + _to = _index; | ||
48 | + } else { | ||
49 | + if (0 > _to) { | ||
50 | + _to = 0; | ||
51 | + } else { | ||
52 | + _to = _to; | ||
53 | + } | ||
54 | + } | ||
55 | + } | ||
56 | + _current = _o.index = _to; | ||
57 | + | ||
58 | + o = { | ||
59 | + from: _from, | ||
60 | + to: _to, | ||
61 | + originalto: _originalto, | ||
62 | + direction: _direction | ||
63 | + }; | ||
64 | + | ||
65 | + for (key in __self.registerEvent) { | ||
66 | + if (__self.registerEvent[key].length > 0) { | ||
67 | + for (_e in __self.registerEvent[key]) { | ||
68 | + if (__self.registerEvent[key].hasOwnProperty(_e)) { | ||
69 | + __self.registerEvent[key][_e](o); | ||
70 | + } | ||
71 | + } | ||
72 | + } | ||
73 | + } | ||
74 | + | ||
75 | + if (_current !== _index || _to) { | ||
76 | + if (!__self.__isStop && _o.auto) { | ||
77 | + __self.play(); | ||
78 | + } | ||
79 | + } else { | ||
80 | + if (__self.__lastTime) { | ||
81 | + clearTimeout(__self.__lastTime); | ||
82 | + } | ||
83 | + } | ||
84 | +}; | ||
85 | + | ||
86 | +slide.prototype.play = function() { | ||
87 | + var __self = this, | ||
88 | + _o = __self.options; | ||
89 | + | ||
90 | + __self.__lastTime = setTimeout(function() { | ||
91 | + __self.next(); | ||
92 | + }, 1000 * _o.timeout); | ||
93 | + return this; | ||
94 | +}; | ||
95 | + | ||
96 | +slide.prototype.next = function() { | ||
97 | + var __self = this, | ||
98 | + _o = __self.options; | ||
99 | + var _from = _o.index; | ||
100 | + var _to = _from + _o.step; | ||
101 | + | ||
102 | + __self.go(_to, _from); | ||
103 | +}; | ||
104 | + | ||
105 | +slide.prototype.prev = function() { | ||
106 | + var __self = this, | ||
107 | + _o = __self.options; | ||
108 | + var _from = _o.index; | ||
109 | + var _to = _from - _o.step; | ||
110 | + | ||
111 | + __self.go(_to, _from); | ||
112 | +}; | ||
113 | + | ||
114 | +slide.prototype.pause = function() { | ||
115 | + var __self = this; | ||
116 | + | ||
117 | + if (__self.__lastTime) { | ||
118 | + clearTimeout(__self.__lastTime); | ||
119 | + } | ||
120 | + __self.__isStop = true; | ||
121 | +}; | ||
122 | + | ||
123 | +slide.prototype.resume = function() { | ||
124 | + var __self = this; | ||
125 | + | ||
126 | + __self.__isStop = false; | ||
127 | + __self.play(); | ||
128 | +}; | ||
129 | + | ||
130 | +slide.prototype.defaults = { | ||
131 | + index: 0, | ||
132 | + timeout: 5, | ||
133 | + step: 1, | ||
134 | + per: 1, | ||
135 | + auto: false, | ||
136 | + loop: false | ||
137 | +}; | ||
138 | + | ||
139 | +module.exports = slide; |
1 | 1 | ||
2 | var $ = require('yoho-jquery'), | 2 | var $ = require('yoho-jquery'), |
3 | - lazyLoad = require('yoho-jquery-lazyload'), | ||
4 | - homePage = $('.home-page').data('page'); | ||
5 | 3 | ||
6 | -lazyLoad($('img.lazy')); | 4 | + // lazyLoad = require('yoho-jquery-lazyload'), |
5 | + homePage = $('.home-page').data('page'), | ||
6 | + brandUrl = $('.logo-brand').data('url'); | ||
7 | 7 | ||
8 | +// lazyLoad($('img.lazy')); | ||
9 | + | ||
10 | +// require('../header'); | ||
8 | require('../common/slider'); | 11 | require('../common/slider'); |
9 | require('../common/slider2'); | 12 | require('../common/slider2'); |
10 | require('../common/logo-brand'); | 13 | require('../common/logo-brand'); |
@@ -19,15 +22,15 @@ if (homePage === 'boys') { | @@ -19,15 +22,15 @@ if (homePage === 'boys') { | ||
19 | $('.slide-container').slider(); | 22 | $('.slide-container').slider(); |
20 | } | 23 | } |
21 | 24 | ||
22 | -// if (homePage === 'boys') { | ||
23 | -// $('.logo-brand').logoBrand({ | ||
24 | -// url: brandUrl | ||
25 | -// }); | ||
26 | -// $('.img-brand').slider2(); | ||
27 | -// } else { | ||
28 | -// $('.logo-brand').logoBrand({ | ||
29 | -// showNum: 10, | ||
30 | -// url: brandUrl | ||
31 | -// }); | ||
32 | -// $('.img-slider-wrapper').slider2(); | ||
33 | -// } | 25 | +if (homePage === 'boys') { |
26 | + $('.logo-brand').logoBrand({ | ||
27 | + url: brandUrl | ||
28 | + }); | ||
29 | + $('.img-brand').slider2(); | ||
30 | +} else { | ||
31 | + $('.logo-brand').logoBrand({ | ||
32 | + showNum: 10, | ||
33 | + url: brandUrl | ||
34 | + }); | ||
35 | + $('.img-slider-wrapper').slider2(); | ||
36 | +} |
1 | .yoho-page { | 1 | .yoho-page { |
2 | - | ||
3 | .floor-header { | 2 | .floor-header { |
4 | position: relative; | 3 | position: relative; |
5 | margin: 80px 0 40px; | 4 | margin: 80px 0 40px; |
@@ -41,3 +40,115 @@ | @@ -41,3 +40,115 @@ | ||
41 | } | 40 | } |
42 | } | 41 | } |
43 | } | 42 | } |
43 | + | ||
44 | +/* | ||
45 | +热门推荐模板样式 | ||
46 | +*/ | ||
47 | +.home-page { | ||
48 | + .tpl-recommend { | ||
49 | + width: 100%; | ||
50 | + position: relative; | ||
51 | + a { | ||
52 | + display: block; | ||
53 | + img { | ||
54 | + display: block; | ||
55 | + width: 100%; | ||
56 | + height: 100%; | ||
57 | + } | ||
58 | + } | ||
59 | + .tpl-body { | ||
60 | + margin-bottom: 8px; | ||
61 | + } | ||
62 | + .tpl-nav { | ||
63 | + float: left; | ||
64 | + overflow: hidden; | ||
65 | + .tpl-keywords { | ||
66 | + margin-bottom: 8px; | ||
67 | + } | ||
68 | + | ||
69 | + .tpl-category { | ||
70 | + padding: 10px 0; | ||
71 | + background-color: #f8f8f8; | ||
72 | + overflow: hidden; | ||
73 | + | ||
74 | + a { | ||
75 | + float: left; | ||
76 | + width: 50%; | ||
77 | + text-align: center; | ||
78 | + color: #000; | ||
79 | + overflow: hidden; | ||
80 | + } | ||
81 | + } | ||
82 | + } | ||
83 | + .tpl-brands { | ||
84 | + float: left; | ||
85 | + overflow: hidden; | ||
86 | + margin-left: 8px; | ||
87 | + li { | ||
88 | + margin-top: 8px; | ||
89 | + } | ||
90 | + } | ||
91 | + .tpl-types { | ||
92 | + float: left; | ||
93 | + overflow: hidden; | ||
94 | + margin-top: -8px; | ||
95 | + width: 579px; | ||
96 | + | ||
97 | + li { | ||
98 | + float: left; | ||
99 | + margin-left: 8px; | ||
100 | + margin-top: 8px; | ||
101 | + | ||
102 | + a { | ||
103 | + width: 185px; | ||
104 | + height: 248px; | ||
105 | + } | ||
106 | + } | ||
107 | + } | ||
108 | + .tpl-products { | ||
109 | + overflow: hidden; | ||
110 | + margin-left: -10px; | ||
111 | + li { | ||
112 | + float: left; | ||
113 | + margin-left: 10px; | ||
114 | + | ||
115 | + a { | ||
116 | + width: 222px; | ||
117 | + height: 298px; | ||
118 | + } | ||
119 | + } | ||
120 | + } | ||
121 | + | ||
122 | + .tpl-nav { | ||
123 | + width: 185px; | ||
124 | + | ||
125 | + .keywords0, | ||
126 | + .keywords1, | ||
127 | + .keywords2 { | ||
128 | + margin-bottom: 10px; | ||
129 | + height: 76px; | ||
130 | + } | ||
131 | + .keywords2 { | ||
132 | + margin-bottom: 0; | ||
133 | + } | ||
134 | + .tpl-category { | ||
135 | + height: 228px; | ||
136 | + | ||
137 | + a { | ||
138 | + height: 38px; | ||
139 | + line-height: 38px; | ||
140 | + font-size: 14px; | ||
141 | + } | ||
142 | + } | ||
143 | + } | ||
144 | + | ||
145 | + .tpl-brands { | ||
146 | + width: 378px; | ||
147 | + height: 512px; | ||
148 | + | ||
149 | + li a { | ||
150 | + height: 248px; | ||
151 | + } | ||
152 | + } | ||
153 | + } | ||
154 | +} |
-
Please register or login to post a comment