Showing
7 changed files
with
188 additions
and
32 deletions
static/js/guang/info.js
0 → 100644
1 | +/** | ||
2 | + * 资讯相关API | ||
3 | + * @author: xuqi<qi.xu@yoho.cn> | ||
4 | + * @date: 2015/10/10 | ||
5 | + */ | ||
6 | + | ||
7 | +var $ = require('yoho.zepto'), | ||
8 | + ellipsis = require('mlellipsis'), | ||
9 | + lazyLoad = require('yoho.lazyload'); | ||
10 | + | ||
11 | +var api = require('../api'); | ||
12 | + | ||
13 | +ellipsis.init(); | ||
14 | + | ||
15 | +/** | ||
16 | + * 初始化资讯列表事件绑定 | ||
17 | + * @params $container 逛资讯列表容器 | ||
18 | + */ | ||
19 | +function initInfosEvt($container) { | ||
20 | + $container.delegate('.like-btn', 'touchstart', function(e) { | ||
21 | + var $likeBtn = $(e.currentTarget), | ||
22 | + $info = $likeBtn.closest('.guang-info'); | ||
23 | + | ||
24 | + $.ajax({ | ||
25 | + type: 'GET', | ||
26 | + url: '/guang/info/prise', //TODO:cancelPrise | ||
27 | + data: { | ||
28 | + id: $info.data('id') | ||
29 | + } | ||
30 | + }).then(function(data) { | ||
31 | + var code = data.code; | ||
32 | + | ||
33 | + if (code === 200) { | ||
34 | + $likeBtn.next('.like-count').text(data.data); | ||
35 | + } else if (code === 400) { | ||
36 | + api.alert('未登录'); | ||
37 | + } | ||
38 | + }, function() { | ||
39 | + api.alert('网络断开连接了~'); | ||
40 | + }); | ||
41 | + }); | ||
42 | +} | ||
43 | + | ||
44 | +/** | ||
45 | + * 设置指定资讯项的Lazyload和文字截取 | ||
46 | + * @params $infos 资讯项 | ||
47 | + */ | ||
48 | +function setLazyLoadAndMellipsis($infos) { | ||
49 | + lazyLoad($infos.find('img.lazy')); | ||
50 | + | ||
51 | + $infos.each(function() { | ||
52 | + var $this = $(this); | ||
53 | + | ||
54 | + $this.find('.info-title')[0].mlellipsis(2); | ||
55 | + $this.find('.info-text')[0].mlellipsis(2); | ||
56 | + }); | ||
57 | +} | ||
58 | + | ||
59 | +exports.initInfosEvt = initInfosEvt; | ||
60 | +exports.setLazyLoadAndMellipsis = setLazyLoadAndMellipsis; |
1 | +/** | ||
2 | + * PLUS+STAR | ||
3 | + * @author: xuqi<qi.xu@yoho.cn> | ||
4 | + * @date: 2015/10/10 | ||
5 | + */ | ||
6 | + | ||
7 | +var $ = require('yoho.zepto'), | ||
8 | + ellipsis = require('mlellipsis'), | ||
9 | + lazyLoad = require('yoho.lazyload'); | ||
10 | + | ||
11 | +var $intro = $('#intro'), | ||
12 | + $imt = $('#intro-more-txt'), | ||
13 | + $infosContainer = $('#related-infos-container'); | ||
14 | + | ||
15 | +var infoApi = require('./info'); | ||
16 | + | ||
17 | +var mIntro, aIntro; | ||
18 | + | ||
19 | +ellipsis.init(); | ||
20 | + | ||
21 | +//Init LazyLoad | ||
22 | +lazyLoad($('img.lazy')); | ||
23 | + | ||
24 | +//文字介绍文字截取 | ||
25 | +$intro[0].mlellipsis(3); | ||
26 | + | ||
27 | +//获取截取文字和完整文字 | ||
28 | +setTimeout(function() { | ||
29 | + mIntro = $intro.text(); | ||
30 | + aIntro = $intro.attr('title'); | ||
31 | +}); | ||
32 | + | ||
33 | +infoApi.initInfosEvt($infosContainer); | ||
34 | +infoApi.setLazyLoadAndMellipsis($infosContainer.find('.guang-info')); | ||
35 | + | ||
36 | +//文字介绍收起与展开 | ||
37 | +$('#more-intro').bind('touchstart', function() { | ||
38 | + var $this = $(this); | ||
39 | + | ||
40 | + $this.toggleClass('spread'); | ||
41 | + | ||
42 | + if ($this.hasClass('spread')) { | ||
43 | + | ||
44 | + //显示 | ||
45 | + $intro.text(aIntro); | ||
46 | + $imt.text('收起'); | ||
47 | + } else { | ||
48 | + | ||
49 | + //隐藏 | ||
50 | + $intro.text(mIntro); | ||
51 | + $imt.text('more'); | ||
52 | + } | ||
53 | +}); | ||
54 | + | ||
55 | +//品牌收藏 | ||
56 | +$('#brand-like').bind('touchstart', function(e) { | ||
57 | + e.preventDefault(); | ||
58 | +}); |
@@ -17,7 +17,9 @@ | @@ -17,7 +17,9 @@ | ||
17 | "main": "index.js", | 17 | "main": "index.js", |
18 | "dependencies": { | 18 | "dependencies": { |
19 | "yoho.zepto": "1.1.60", | 19 | "yoho.zepto": "1.1.60", |
20 | - "yoho.jquery": "1.8.3" | 20 | + "yoho.jquery": "1.8.3", |
21 | + "yoho.lazyload": "1.1.0", | ||
22 | + "mlellipsis": "0.0.6" | ||
21 | }, | 23 | }, |
22 | "devDependencies": { | 24 | "devDependencies": { |
23 | "expect.js": "0.3.1" | 25 | "expect.js": "0.3.1" |
1 | .ps-detail-page { | 1 | .ps-detail-page { |
2 | + background-color: #f0f0f0; | ||
3 | + | ||
2 | .ps-block { | 4 | .ps-block { |
3 | margin-bottom: 30rem / $pxConvertRem; | 5 | margin-bottom: 30rem / $pxConvertRem; |
4 | border-bottom: 1px solid #e0e0e0; | 6 | border-bottom: 1px solid #e0e0e0; |
@@ -63,38 +65,42 @@ | @@ -63,38 +65,42 @@ | ||
63 | color: #f00; | 65 | color: #f00; |
64 | } | 66 | } |
65 | } | 67 | } |
68 | + } | ||
69 | + | ||
70 | + .intro { | ||
71 | + margin-top: 49rem / $pxConvertRem; | ||
72 | + font-size: 24rem / $pxConvertRem; | ||
73 | + color: #444; | ||
74 | + line-height: 150%; | ||
75 | + } | ||
66 | 76 | ||
67 | - .intro { | ||
68 | - margin-top: 49rem / $pxConvertRem; | ||
69 | - font-size: 24rem / $pxConvertRem; | ||
70 | - color: #444; | ||
71 | - line-height: 150%; | 77 | + .more-intro { |
78 | + padding: 30rem / $pxConvertRem 0; | ||
79 | + font-size: 28rem / $pxConvertRem; | ||
80 | + line-height: 104%; | ||
81 | + color: #bbb; | ||
82 | + float: right; | ||
83 | + | ||
84 | + .icon { | ||
85 | + -webkit-transition: -webkit-transform .1s ease-in; | ||
86 | + -moz-transition: -moz-transform .1s ease-in; | ||
87 | + -ms-transition: -ms-transform .1s ease-in; | ||
88 | + -o-transition: -o-transform .1s ease-in; | ||
89 | + transition: transform .1s ease-in; | ||
72 | } | 90 | } |
73 | 91 | ||
74 | - .more-intro { | ||
75 | - padding: 30rem / $pxConvertRem 0; | ||
76 | - font-size: 28rem / $pxConvertRem; | ||
77 | - line-height: 104%; | ||
78 | - color: #bbb; | ||
79 | - text-align: right; | 92 | + &.spread .icon { |
93 | + -webkit-transform: scale(0.83) rotate(-180deg); | ||
94 | + -moz-transform: scale(0.83) rotate(-180deg); | ||
95 | + -ms-transform: scale(0.83) rotate(-180deg); | ||
96 | + -o-transform: scale(0.83) rotate(-180deg); | ||
97 | + transform: scale(0.83) rotate(-180deg); | ||
80 | } | 98 | } |
81 | } | 99 | } |
82 | 100 | ||
83 | .new-arrival { | 101 | .new-arrival { |
84 | padding-left: 0 30rem / $pxConvertRem; | 102 | padding-left: 0 30rem / $pxConvertRem; |
85 | 103 | ||
86 | - .new-arrival-header { | ||
87 | - padding-left: 222rem / $pxConvertRem; | ||
88 | - padding-top: 33rem / $pxConvertRem; | ||
89 | - | ||
90 | - .header-text { | ||
91 | - font-size: 28rem / $pxConvertRem; | ||
92 | - color: #000; | ||
93 | - line-height: 122%; | ||
94 | - font-weight: bold; | ||
95 | - } | ||
96 | - } | ||
97 | - | ||
98 | .new-arrival-content { | 104 | .new-arrival-content { |
99 | padding: 20rem / $pxConvertRem 14rem / $pxConvertRem; | 105 | padding: 20rem / $pxConvertRem 14rem / $pxConvertRem; |
100 | } | 106 | } |
@@ -127,6 +133,18 @@ | @@ -127,6 +133,18 @@ | ||
127 | 133 | ||
128 | } | 134 | } |
129 | 135 | ||
136 | + .new-arrival-header { | ||
137 | + padding-left: 222rem / $pxConvertRem; | ||
138 | + padding-top: 33rem / $pxConvertRem; | ||
139 | + | ||
140 | + .header-text { | ||
141 | + font-size: 28rem / $pxConvertRem; | ||
142 | + color: #000; | ||
143 | + line-height: 122%; | ||
144 | + font-weight: bold; | ||
145 | + } | ||
146 | + } | ||
147 | + | ||
130 | 148 | ||
131 | .related-info-title { | 149 | .related-info-title { |
132 | margin: 0 29rem / $pxConvertRem; | 150 | margin: 0 29rem / $pxConvertRem; |
@@ -47,4 +47,23 @@ a { | @@ -47,4 +47,23 @@ a { | ||
47 | color: #000; | 47 | color: #000; |
48 | } | 48 | } |
49 | 49 | ||
50 | -@import "layout/header", "layout/footer", "passport/index", "guang/index"; | ||
50 | +@font-face { | ||
51 | + font-family: "iconfont"; | ||
52 | + src: font-url('iconfont.eot'); /* IE9*/ | ||
53 | + src: font-url('iconfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ | ||
54 | + font-url('iconfont.woff') format('woff'), /* chrome、firefox */ | ||
55 | + font-url('iconfont.ttf') format('truetype'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/ | ||
56 | + font-url('iconfont.svg#iconfont') format('svg'); /* iOS 4.1- */ | ||
57 | +} | ||
58 | + | ||
59 | +.iconfont { | ||
60 | + font-family: "iconfont" !important; | ||
61 | + font-size: 16px; | ||
62 | + font-style: normal; | ||
63 | + text-decoration: none; | ||
64 | + -webkit-font-smoothing: antialiased; | ||
65 | + -webkit-text-stroke-width: 0.2px; | ||
66 | + -moz-osx-font-smoothing: grayscale; | ||
67 | +} | ||
68 | + | ||
69 | +@import "layout/header", "layout/footer", "good", "passport/index", "guang/index"; |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | <div class="header brand-info ps-block" data-id="{{id}}"> | 4 | <div class="header brand-info ps-block" data-id="{{id}}"> |
5 | <img class="banner lazy" data-original="{{banner}}"> | 5 | <img class="banner lazy" data-original="{{banner}}"> |
6 | <img class="logo lazy" data-original="{{logo}}"> | 6 | <img class="logo lazy" data-original="{{logo}}"> |
7 | - <div class="header-content"> | 7 | + <div class="header-content clearfix"> |
8 | <p class="name-islike-container"> | 8 | <p class="name-islike-container"> |
9 | <span class="name">{{name}}</span> | 9 | <span class="name">{{name}}</span> |
10 | <a id="brand-like" class="brand-islike iconfont {{# isLike}}like{{/ isLike}}" href="{{likeUrl}}"> | 10 | <a id="brand-like" class="brand-islike iconfont {{# isLike}}like{{/ isLike}}" href="{{likeUrl}}"> |
@@ -14,11 +14,10 @@ | @@ -14,11 +14,10 @@ | ||
14 | <p id="intro" class="intro"> | 14 | <p id="intro" class="intro"> |
15 | {{intro}} | 15 | {{intro}} |
16 | </p> | 16 | </p> |
17 | - <div id="more-intro" class="more-intro"> | ||
18 | - <span class="more-intro-text more">more</span> | ||
19 | - <span class="more-intro-icon more iconfont down"></span> | ||
20 | - <span class="more-intro-icon more iconfont up hide"></span> | ||
21 | - </div> | 17 | + <span id="more-intro" class="more-intro"> |
18 | + <span id="intro-more-txt">more</span> | ||
19 | + <i class="icon iconfont"></i> | ||
20 | + </span> | ||
22 | </div> | 21 | </div> |
23 | </div> | 22 | </div> |
24 | {{# newArrival}} | 23 | {{# newArrival}} |
-
Please register or login to post a comment