Authored by 姜枫

merge from master

@@ -233,7 +233,9 @@ const listDynamicData = (req, res) => { @@ -233,7 +233,9 @@ const listDynamicData = (req, res) => {
233 type = req.query.type; 233 type = req.query.type;
234 234
235 if (req.user.uid) { 235 if (req.user.uid) {
236 - other.uid = req.user.uid || req.query.uid; 236 + other.uid = req.user.uid;
  237 + } else if (req.query.uid) {
  238 + other.uid = req.query.uid;
237 } 239 }
238 240
239 if (query) { 241 if (query) {
@@ -41,12 +41,22 @@ const _pageArticleContent = (articleContent, isApp, gender, isWeixin, isqq, isWe @@ -41,12 +41,22 @@ const _pageArticleContent = (articleContent, isApp, gender, isWeixin, isqq, isWe
41 joinContentFunc(++i, len); 41 joinContentFunc(++i, len);
42 } else if (art.singleImage && art.singleImage.data && art.singleImage.data.length) { // 单张图 42 } else if (art.singleImage && art.singleImage.data && art.singleImage.data.length) { // 单张图
43 build.bigImage = helpers.image(art.singleImage.data[0].src, 640, 640); 43 build.bigImage = helpers.image(art.singleImage.data[0].src, 640, 640);
  44 +
  45 + // 前三张图片不使用懒加载,下同
  46 + if (i <= 3) {
  47 + build.noLazy = true;
  48 + }
  49 +
44 contents.push(build); 50 contents.push(build);
45 joinContentFunc(++i, len); 51 joinContentFunc(++i, len);
46 52
47 } else if (art.smallPic && art.smallPic.data && art.smallPic.data.length > 1) { 53 } else if (art.smallPic && art.smallPic.data && art.smallPic.data.length > 1) {
48 let imgs = art.smallPic.data; 54 let imgs = art.smallPic.data;
49 55
  56 + if (i <= 3) {
  57 + build.noLazy = true;
  58 + }
  59 +
50 build.smallImage = [{ 60 build.smallImage = [{
51 src: helpers.image(imgs[0].src, 315, 420) 61 src: helpers.image(imgs[0].src, 315, 420)
52 }, { 62 }, {
@@ -43,17 +43,18 @@ const praiseArticle = (req, res, next) => { @@ -43,17 +43,18 @@ const praiseArticle = (req, res, next) => {
43 * 资讯文章收藏 (APP里显示收藏) 43 * 资讯文章收藏 (APP里显示收藏)
44 */ 44 */
45 const collectArticle = (req, res, next) => { 45 const collectArticle = (req, res, next) => {
  46 + let allowOrigin = _.get(req, 'headers.origin', null) ?
  47 + req.headers.origin : req.protocol + '://' + req.headers.host;
  48 +
  49 + res.setHeader('Access-Control-Allow-Origin', allowOrigin);
  50 + res.setHeader('Access-Control-Allow-Credentials', 'true');
  51 +
46 let result = { 52 let result = {
47 code: 400, 53 code: 400,
48 message: '您未登录,无法收藏或者取消收藏。请先登录!', 54 message: '您未登录,无法收藏或者取消收藏。请先登录!',
49 data: '' 55 data: ''
50 }; 56 };
51 57
52 - /* 判断是不是AJAX请求 */  
53 - if (!req.xhr) {  
54 - res.json(result);  
55 - return;  
56 - }  
57 58
58 /* 判断参数是否有效 */ 59 /* 判断参数是否有效 */
59 /* 判断用户是否登录 */ 60 /* 判断用户是否登录 */
@@ -61,6 +62,12 @@ const collectArticle = (req, res, next) => { @@ -61,6 +62,12 @@ const collectArticle = (req, res, next) => {
61 opt = req.body.opt || 'ok', 62 opt = req.body.opt || 'ok',
62 uid = req.body.uid; 63 uid = req.body.uid;
63 64
  65 + /* 判断是不是登录成功 */
  66 + if (!uid) {
  67 + res.json(result);
  68 + return;
  69 + }
  70 +
64 if (!stringProcess.isNumeric(id) || !stringProcess.isNumeric(uid)) { 71 if (!stringProcess.isNumeric(id) || !stringProcess.isNumeric(uid)) {
65 res.json(result); 72 res.json(result);
66 return; 73 return;
@@ -66,7 +66,7 @@ const getArticleList = (gender, sortId, uid, udid, page, tag, authorId, limit, u @@ -66,7 +66,7 @@ const getArticleList = (gender, sortId, uid, udid, page, tag, authorId, limit, u
66 sort_id: sortId, 66 sort_id: sortId,
67 tag: tag, 67 tag: tag,
68 author_id: authorId, 68 author_id: authorId,
69 - limit: 20 69 + limit: 4
70 }; 70 };
71 71
72 return serviceAPI.get('guang/api/v2/article/getList', param, { 72 return serviceAPI.get('guang/api/v2/article/getList', param, {
@@ -143,7 +143,8 @@ const _article = (param) => { @@ -143,7 +143,8 @@ const _article = (param) => {
143 uid: param.uid, 143 uid: param.uid,
144 udid: param.udid, 144 udid: param.udid,
145 sort_id: 0, 145 sort_id: 0,
146 - tag: param.tag ? param.tag : null 146 + tag: param.tag ? param.tag : null,
  147 + limit: 4
147 148
148 // author_id: param.authorId ? param.authorId : null, 149 // author_id: param.authorId ? param.authorId : null,
149 // limit: param.limit ? param.limit : null 150 // limit: param.limit ? param.limit : null
@@ -19,13 +19,15 @@ @@ -19,13 +19,15 @@
19 {{# ../swiper}} 19 {{# ../swiper}}
20 <div class="swiper-slide"> 20 <div class="swiper-slide">
21 <a href="{{url}}"> 21 <a href="{{url}}">
  22 + {{#if @first}}
  23 + <img src="{{image2 img width=200 height=100 q=60}}">
  24 + {{^}}
22 <img class="swiper-lazy" data-src="{{image2 img width=200 height=100 q=60}}"> 25 <img class="swiper-lazy" data-src="{{image2 img width=200 height=100 q=60}}">
  26 + {{/if}}
23 </a> 27 </a>
24 - <div class="swiper-lazy-preloader"></div>  
25 </div> 28 </div>
26 {{/ ../swiper}} 29 {{/ ../swiper}}
27 </div> 30 </div>
28 - <div class="swiper-pagination swiper-pagi-{{typeId}}"></div>  
29 </div> 31 </div>
30 {{/if}} 32 {{/if}}
31 {{/if}} 33 {{/if}}
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 {{# authorInfo}} 3 {{# authorInfo}}
4 <div id="author-infos" class="editor-header clearfix" data-id={{uid}}> 4 <div id="author-infos" class="editor-header clearfix" data-id={{uid}}>
5 <div class="avatar"> 5 <div class="avatar">
6 - <img src="{{avatar}}?imageView2/2/w/200/h/200/q/70"> 6 + <img src="{{image2 avatar mode=2 q=60}}">
7 </div> 7 </div>
8 <div class="text"> 8 <div class="text">
9 <p class="name">{{name}}</p> 9 <p class="name">{{name}}</p>
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 </div> 24 </div>
25 <span class="no-more status hide">没有更多啦</span> 25 <span class="no-more status hide">没有更多啦</span>
26 </div> 26 </div>
27 - 27 +
28 {{#if tag}} 28 {{#if tag}}
29 <input id="tag" type="hidden" value={{tag}}> 29 <input id="tag" type="hidden" value={{tag}}>
30 {{/if}} 30 {{/if}}
@@ -4,15 +4,17 @@ @@ -4,15 +4,17 @@
4 {{# swiper}} 4 {{# swiper}}
5 <div class="swiper-slide"> 5 <div class="swiper-slide">
6 <a href="{{url}}"> 6 <a href="{{url}}">
7 - <img class="swiper-lazy" data-src="{{img}}"> 7 + {{#if @first}}
  8 + <img src="{{image2 img q=60}}">
  9 + {{^}}
  10 + <img class="swiper-lazy" data-src="{{image2 img q=60}}">
  11 + {{/if}}
8 </a> 12 </a>
9 - <div class="swiper-lazy-preloader"></div>  
10 </div> 13 </div>
11 {{/ swiper}} 14 {{/ swiper}}
12 </div> 15 </div>
13 - <div class="swiper-pagination"></div>  
14 </div> 16 </div>
15 {{/if}} 17 {{/if}}
16 {{# infos}} 18 {{# infos}}
17 {{> index/info}} 19 {{> index/info}}
18 -{{/ infos}}  
  20 +{{/ infos}}
@@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
8 {{# author}} 8 {{# author}}
9 <div class="author" data-id={{id}}> 9 <div class="author" data-id={{id}}>
10 <a class="clearfix" href={{url}}> 10 <a class="clearfix" href={{url}}>
11 - <img class="avatar" src={{avatar}}> 11 + <img class="avatar" src={{image2 avatar mode=2 q=60}}>
12 <span class="name">{{name}}</span> 12 <span class="name">{{name}}</span>
13 <span class="intro">{{intro}}</span> 13 <span class="intro">{{intro}}</span>
14 </a> 14 </a>
@@ -30,15 +30,25 @@ @@ -30,15 +30,25 @@
30 30
31 {{#if bigImage}} 31 {{#if bigImage}}
32 <div class="post-block big-img-block"> 32 <div class="post-block big-img-block">
33 - <img class="lazy" data-original={{bigImage}}> 33 + {{#if noLazy}}
  34 + <img src={{image2 bigImage q=60}}>
  35 + {{else}}
  36 + <img class="lazy" data-original={{image2 bigImage q=60}}>
  37 + {{/if}}
34 </div> 38 </div>
35 {{/if}} 39 {{/if}}
36 40
37 {{#if smallImage}} 41 {{#if smallImage}}
38 <div class="post-block small-img-block clearfix"> 42 <div class="post-block small-img-block clearfix">
  43 + {{#if noLazy}}
  44 + {{# smallImage}}
  45 + <img src={{image2 src q=60}}>
  46 + {{/ smallImage}}
  47 + {{else}}
39 {{# smallImage}} 48 {{# smallImage}}
40 - <img class="lazy" data-original={{src}}> 49 + <img class="lazy" data-original={{image2 src q=60}}>
41 {{/ smallImage}} 50 {{/ smallImage}}
  51 + {{/if}}
42 </div> 52 </div>
43 {{/if}} 53 {{/if}}
44 54
@@ -167,7 +177,7 @@ @@ -167,7 +177,7 @@
167 <img class="lazy {{#if squareThumb}}square{{/if}}" data-original={{thumb}}> 177 <img class="lazy {{#if squareThumb}}square{{/if}}" data-original={{thumb}}>
168 <span class="title">{{title}}</span> 178 <span class="title">{{title}}</span>
169 <span class="publish-time"> 179 <span class="publish-time">
170 - <i class="iconfont">&#xe603;</i> 180 + <i class="iconfont">&#xe603;</i>
171 {{publishTime}} 181 {{publishTime}}
172 </span> 182 </span>
173 </a> 183 </a>
@@ -16,7 +16,6 @@ @@ -16,7 +16,6 @@
16 <a href="{{url}}"> 16 <a href="{{url}}">
17 <img class="swiper-lazy" data-src="{{image src 750 364}}"> 17 <img class="swiper-lazy" data-src="{{image src 750 364}}">
18 </a> 18 </a>
19 - <div class="swiper-lazy-preloader"></div>  
20 </li> 19 </li>
21 {{/if}} 20 {{/if}}
22 {{/each}} 21 {{/each}}
1 <div class="guang-info" data-id="{{id}}"> 1 <div class="guang-info" data-id="{{id}}">
2 {{# author}} 2 {{# author}}
3 <a class="info-author clearfix" href={{url}}> 3 <a class="info-author clearfix" href={{url}}>
4 - <img class="lazy avatar" data-original={{avatar}}> 4 + <img class="lazy avatar" data-original={{image2 avatar mode=2 q=60}}>
5 <span class="name">{{name}}</span> 5 <span class="name">{{name}}</span>
6 </a> 6 </a>
7 {{/ author}} 7 {{/ author}}
@@ -36,7 +36,11 @@ @@ -36,7 +36,11 @@
36 </a> 36 </a>
37 {{/if}} 37 {{/if}}
38 <a href="{{url}}"> 38 <a href="{{url}}">
39 - <img class="lazy" data-original="{{img}}" alt="{{alt}}"> 39 + {{#if @first}}
  40 + <img src="{{image2 img q=60}}" alt="{{alt}}">
  41 + {{^}}
  42 + <img class="lazy" data-original="{{image2 img q=60}}" alt="{{alt}}">
  43 + {{/if}}
40 </a> 44 </a>
41 </div> 45 </div>
42 46
@@ -47,4 +51,4 @@ @@ -47,4 +51,4 @@
47 <p class="info-text">{{text}}</p> 51 <p class="info-text">{{text}}</p>
48 {{> index/tvls}} 52 {{> index/tvls}}
49 </div> 53 </div>
50 -</div>  
  54 +</div>
@@ -9,9 +9,7 @@ @@ -9,9 +9,7 @@
9 <span class="like-count">{{count}}</span> 9 <span class="like-count">{{count}}</span>
10 {{/ like}} 10 {{/ like}}
11 {{# collect}} 11 {{# collect}}
12 - <a href={{url}}>  
13 - <i class="iconfont collect-btn{{#isCollected}} collected{{/isCollected}}">&#xe605;</i>  
14 - </a> 12 + <i class="iconfont collect-btn{{#isCollected}} collected{{/isCollected}}">&#xe605;</i>
15 {{/ collect}} 13 {{/ collect}}
16 {{# share}} 14 {{# share}}
17 <a href="{{.}}" class="iconfont share-btn">&#xe600;</a> 15 <a href="{{.}}" class="iconfont share-btn">&#xe600;</a>
1 <div class="guang-info" data-id="{{id}}"> 1 <div class="guang-info" data-id="{{id}}">
2 {{# author}} 2 {{# author}}
3 <a class="info-author clearfix" href={{url}}> 3 <a class="info-author clearfix" href={{url}}>
4 - <img class="lazy avatar" data-original="{{avatar}}?imageView2/2/w/100/h/100/q/70"> 4 + <img class="lazy avatar" data-original={{image2 avatar mode=2 q=60}}>
5 <span class="name">{{name}}</span> 5 <span class="name">{{name}}</span>
6 </a> 6 </a>
7 {{/ author}} 7 {{/ author}}
@@ -36,7 +36,11 @@ @@ -36,7 +36,11 @@
36 </a> 36 </a>
37 {{/if}} 37 {{/if}}
38 <a href="{{url}}"> 38 <a href="{{url}}">
39 - <img class="lazy" data-original="{{img}}" alt="{{alt}}"> 39 + {{#if @first}}
  40 + <img src="{{image2 img q=60}}" alt="{{alt}}">
  41 + {{^}}
  42 + <img class="lazy" data-original="{{image2 img q=60}}" alt="{{alt}}">
  43 + {{/if}}
40 </a> 44 </a>
41 </div> 45 </div>
42 46
@@ -9,9 +9,7 @@ @@ -9,9 +9,7 @@
9 <span class="like-count">{{count}}</span> 9 <span class="like-count">{{count}}</span>
10 {{/ like}} 10 {{/ like}}
11 {{# collect}} 11 {{# collect}}
12 - <a href={{url}}>  
13 - <i class="iconfont collect-btn{{#isCollected}} collected{{/isCollected}}">&#xe605;</i>  
14 - </a> 12 + <i class="iconfont collect-btn{{#isCollected}} collected{{/isCollected}}">&#xe605;</i>
15 {{/ collect}} 13 {{/ collect}}
16 {{# share}} 14 {{# share}}
17 <a href="{{.}}" class="iconfont share-btn">&#xe600;</a> 15 <a href="{{.}}" class="iconfont share-btn">&#xe600;</a>
@@ -117,6 +117,9 @@ exports.intro = (req, res, next) => { @@ -117,6 +117,9 @@ exports.intro = (req, res, next) => {
117 introModel.getintroIntro({ 117 introModel.getintroIntro({
118 productskn: req.params.productskn 118 productskn: req.params.productskn
119 }, req).then(html => { 119 }, req).then(html => {
  120 + res.set({
  121 + 'Cache-Control': 'max-age=' + 1800
  122 + });
120 res.send(html); 123 res.send(html);
121 }); 124 });
122 125
@@ -86,6 +86,7 @@ let index = (req, res, next) => { @@ -86,6 +86,7 @@ let index = (req, res, next) => {
86 } 86 }
87 res.render('sale/index', Object.assign(params.renderData, { 87 res.render('sale/index', Object.assign(params.renderData, {
88 content: result, 88 content: result,
  89 + localCss: true,
89 floorHeader: { 90 floorHeader: {
90 title: { 91 title: {
91 title: '最新降价' 92 title: '最新降价'
@@ -12,6 +12,9 @@ const cachePage = { @@ -12,6 +12,9 @@ const cachePage = {
12 '/kids': 30 * SECOND, 12 '/kids': 30 * SECOND,
13 '/lifestyle': 30 * SECOND, 13 '/lifestyle': 30 * SECOND,
14 14
  15 + //ajax获取频道页楼层
  16 + '/channel/getResourceContent': 30 * MINUTE,
  17 +
15 // 商品分类 18 // 商品分类
16 '/cate': 5 * MINUTE, 19 '/cate': 5 * MINUTE,
17 20
@@ -21,12 +24,21 @@ const cachePage = { @@ -21,12 +24,21 @@ const cachePage = {
21 24
22 // 商品详情ajax 25 // 商品详情ajax
23 26
  27 + // 店铺推荐
  28 + '/product/detail/preference': 5 * MINUTE,
  29 + '/product/detail/intro/:productskn': 15 * MINUTE,
  30 + // 店铺人气单品
  31 + '/product/new/shop/hotlist': 5 * MINUTE,
  32 + // 店铺简介
  33 + '/product/index/intro' : 15 * MINUTE,
  34 +
24 // 逛 35 // 逛
25 '/guang/': 1 * MINUTE, 36 '/guang/': 1 * MINUTE,
26 '/guang/info/index': 10 * MINUTE, 37 '/guang/info/index': 10 * MINUTE,
27 '/guang/author/index': 1 * MINUTE, 38 '/guang/author/index': 1 * MINUTE,
28 '/guang/tags/index': 1 * MINUTE, 39 '/guang/tags/index': 1 * MINUTE,
29 '/guang/plustar': 1 * MINUTE, 40 '/guang/plustar': 1 * MINUTE,
  41 + '/guang/index/page': 1 * MINUTE,
30 42
31 // '/guang/plustar/brandinfo': 1 * MINUTE, 43 // '/guang/plustar/brandinfo': 1 * MINUTE,
32 '/guang/star': 1 * MINUTE, 44 '/guang/star': 1 * MINUTE,
@@ -40,6 +52,9 @@ const cachePage = { @@ -40,6 +52,9 @@ const cachePage = {
40 '/product/index/index': 1 * MINUTE, 52 '/product/index/index': 1 * MINUTE,
41 '/product/index/brand': 1 * MINUTE, 53 '/product/index/brand': 1 * MINUTE,
42 54
  55 + '/product/search/filter': 1 * MINUTE,
  56 + '/product/search/search': 1 * MINUTE,
  57 +
43 '/product/new': 1 * MINUTE, 58 '/product/new': 1 * MINUTE,
44 59
45 // 秒杀列表 60 // 秒杀列表
1 {{#data}} 1 {{#data}}
2 -{{#if ../discountActivity}}  
3 - {{> common/floor-header-more}}  
4 -{{/if}}  
5 -<ul class="discount-list">  
6 - {{#list}}  
7 - <li>  
8 - <a href="/product/sale/discount/detail?id={{id}}&channel={{@root.channel}}">  
9 - <img class="lazy" data-original="{{image2 cover_url w=640 h=250 q=60}}" />  
10 - <p class="discount-cont">  
11 - <span class="discount-title">{{title}}</span>  
12 - <span class="discount-time {{#if warn_color}}red-color{{/if}}">{{time}}</span>  
13 - </p>  
14 - </a>  
15 - </li>  
16 - {{/list}}  
17 -</ul> 2 + {{#if ../discountActivity}}
  3 + {{> common/floor-header-more}}
  4 + {{/if}}
  5 + <ul class="discount-list">
  6 + {{#list}}
  7 + <li>
  8 + <a href="/product/sale/discount/detail?id={{id}}&channel={{@root.channel}}">
  9 + {{#within @index 3}}
  10 + <img src="{{image2 cover_url w=640 h=250 q=60}}"/>
  11 + {{^}}
  12 + <img class="lazy" data-original="{{image2 cover_url w=640 h=250 q=60}}"/>
  13 + {{/within}}
  14 + <p class="discount-cont">
  15 + <span class="discount-title">{{title}}</span>
  16 + <span class="discount-time {{#if warn_color}}red-color{{/if}}">{{time}}</span>
  17 + </p>
  18 + </a>
  19 + </li>
  20 + {{/list}}
  21 + </ul>
18 {{/data}} 22 {{/data}}
@@ -101,6 +101,7 @@ @@ -101,6 +101,7 @@
101 "yoho-jquery-qrcode": "^0.14.0", 101 "yoho-jquery-qrcode": "^0.14.0",
102 "yoho-mlellipsis": "0.0.3", 102 "yoho-mlellipsis": "0.0.3",
103 "yoho-qs": "^1.0.1", 103 "yoho-qs": "^1.0.1",
104 - "yoho-swiper": "^3.3.1" 104 + "yoho-swiper": "^3.3.1",
  105 + "yoho-swiper2": "0.0.5"
105 } 106 }
106 } 107 }
@@ -210,7 +210,7 @@ Filter.prototype = { @@ -210,7 +210,7 @@ Filter.prototype = {
210 return data; 210 return data;
211 } 211 }
212 return data.filter(function(item) { 212 return data.filter(function(item) {
213 - regex = new RegExp('^' + key, 'i'); 213 + regex = new RegExp(key, 'i');
214 return regex.test(item[that.__feild__]); 214 return regex.test(item[that.__feild__]);
215 }); 215 });
216 }, 216 },
@@ -3,8 +3,7 @@ @@ -3,8 +3,7 @@
3 * @author: xuqi<qi.xu@yoho.cn> 3 * @author: xuqi<qi.xu@yoho.cn>
4 * @date: 2015/10/21 4 * @date: 2015/10/21
5 */ 5 */
6 -var $ = require('yoho-jquery'),  
7 - Hammer = require('yoho-hammer'); 6 +var $ = require('yoho-jquery');
8 7
9 var $footer = $('#yoho-footer'), 8 var $footer = $('#yoho-footer'),
10 $yohoPage = $('.yoho-page'), 9 $yohoPage = $('.yoho-page'),
@@ -206,10 +205,9 @@ $.extend({ @@ -206,10 +205,9 @@ $.extend({
206 } 205 }
207 206
208 if ($backToTop.length > 0) { 207 if ($backToTop.length > 0) {
209 - backToTopHammer = new Hammer($backToTop[0]);  
210 - backToTopHammer.on('tap', function(e) { 208 + $backToTop.on('touchend touchcancel', function(e) {
211 $(window).scrollTop(0); 209 $(window).scrollTop(0);
212 - e.srcEvent.preventDefault(); 210 + e.preventDefault();
213 return false; 211 return false;
214 }); 212 });
215 } 213 }
1 -module.exports = function(url, opts) {  
2 - if (url) { 1 +module.exports = function (imageUrl, opts) {
  2 + if (imageUrl) {
3 let params = opts.hash; 3 let params = opts.hash;
4 - let urls = url.split('?'); 4 + let urls = imageUrl.split('?');
5 let query = urls[1] || ''; 5 let query = urls[1] || '';
6 let uri = urls[0]; 6 let uri = urls[0];
7 7
@@ -24,12 +24,22 @@ module.exports = function(url, opts) { @@ -24,12 +24,22 @@ module.exports = function(url, opts) {
24 } else { 24 } else {
25 query += '/quality/' + params.q; 25 query += '/quality/' + params.q;
26 } 26 }
  27 + } else if (query.indexOf('imageView/') === 0) {
  28 + if (params.q && query.indexOf('/q/') > 0) {
  29 + query = query.replace(/\/q\/\d+/g, '/q/' + params.q);
  30 + } else {
  31 + query += '/q/' + params.q;
  32 + }
  33 +
  34 + if (params.mode) {
  35 + query = query.replace(/imageView\/\d{1}\//, 'imageView/' + params.mode + '/');
  36 + }
27 } 37 }
28 } else { 38 } else {
29 query = 'imageView2/2/interlace/1/q/' + (params.q || 75); 39 query = 'imageView2/2/interlace/1/q/' + (params.q || 75);
30 } 40 }
31 return uri + '?' + query; 41 return uri + '?' + query;
32 } else { 42 } else {
33 - return url; 43 + return imageUrl;
34 } 44 }
35 }; 45 };
  1 +// 超轻量锤子,业务代码不用动,替换掉重量级的 hammer.js
  2 +const $ = require('yoho-jquery');
  3 +
  4 +const ToyHammer = function(elem) {
  5 + this.elem = elem;
  6 +};
  7 +
  8 +const EVENT_MAPPER = {
  9 + tap: 'touchstart'
  10 +};
  11 +
  12 +ToyHammer.prototype.on = function(event, fn) {
  13 + const mappedEvent = EVENT_MAPPER[event];
  14 +
  15 + if (this.elem && mappedEvent) {
  16 + $(this.elem).on(mappedEvent, function(e) {
  17 + fn({
  18 + srcEvent: e,
  19 + target: e.target
  20 + });
  21 + });
  22 + }
  23 +};
  24 +
  25 +
  26 +module.exports = ToyHammer;
  1 +var lazyLoad = require('yoho-jquery-lazyload');
  2 +
  3 +/**
  4 + * 搭配区块
  5 + *
  6 + * @constructor
  7 + */
  8 +function CollocationBlock() {
  9 + this.elem = $('.collocation-block');
  10 + this.container = this.elem.children('.thumb-container');
  11 + this.elem.find('.prod');
  12 + this.prods = this.elem.find('.prod');
  13 +
  14 + //this.fixedContainer = $('#wrapper')
  15 + // .after(this.container.clone().addClass('fixed-thumb-container fixed-bottom'))
  16 + // .next('.thumb-container');
  17 +
  18 + //lazyLoad(this.fixedContainer.find('.lazy'));
  19 +
  20 + this.container.delegate('.thumb', 'touchend', this._touchHandler.bind(this));
  21 +
  22 + // this.fixedContainer.delegate('.thumb', 'touchend', this._touchHandler.bind(this));
  23 +
  24 + this.thumbs = this.container.find('li');
  25 +
  26 + // this.fixedThumbs = this.fixedContainer.find('li');
  27 +
  28 + // 初始化箭头位置
  29 + this._updateCollocationArrowPos(this.thumbs.filter('.focus'));
  30 +
  31 + var scrollFn = () => {
  32 + var pos = this.container.offset(),
  33 + posFixed = this.fixedContainer.offset();
  34 + var visible = false;
  35 +
  36 +
  37 + if (posFixed.top >= pos.top) {
  38 + visible = false;
  39 + } else {
  40 + visible = true;
  41 + }
  42 +
  43 + if (posFixed.top + this.fixedContainer.height() > $('ul.brand-list').offset().top) {
  44 + visible = false;
  45 + } else if (pos.top < $(window).scrollTop()) {
  46 + visible = true;
  47 + this.fixedContainer.removeClass('fixed-bottom').addClass('fixed-top');
  48 + } else {
  49 + this.fixedContainer.removeClass('fixed-top').addClass('fixed-bottom');
  50 + }
  51 +
  52 + this.fixedContainer.css({
  53 + visibility: visible ? 'visible' : 'hidden'
  54 + });
  55 + };
  56 +
  57 + //$(document).on('scroll', scrollFn);
  58 + //$(document).on('touchmove', scrollFn);
  59 +
  60 +}
  61 +
  62 +CollocationBlock.exists = function() {
  63 + return $('.collocation-block').size() > 0;
  64 +};
  65 +
  66 +$.extend(CollocationBlock.prototype, {
  67 + /**
  68 + * 计算搭配的箭头的位置
  69 + * @param current 当前focus的搭配项
  70 + */
  71 + _updateCollocationArrowPos: function(current) {
  72 + var left = current.offset().left,
  73 + bgPos = -$(window).width() + left + (this.thumbs.width() / 2) + 'px';
  74 +
  75 + this.container.css({
  76 + backgroundPosition: bgPos + ' bottom'
  77 + });
  78 +
  79 + /*
  80 + this.fixedContainer.css({
  81 + backgroundPosition: bgPos + ' bottom'
  82 + });
  83 + */
  84 + },
  85 +
  86 + /**
  87 + * 搭配thumb的touch事件句柄
  88 + *
  89 + * @param e
  90 + * @private
  91 + */
  92 + _touchHandler: function(e) {
  93 + var current = $(e.currentTarget),
  94 + index = current.index();
  95 +
  96 + if (current.hasClass('focus')) {
  97 + return;
  98 + }
  99 +
  100 + this.thumbs.removeClass('focus');
  101 +
  102 + // this.fixedThumbs.removeClass('focus');
  103 +
  104 + current.addClass('focus');
  105 +
  106 + // 更新箭头位置
  107 + this._updateCollocationArrowPos(current);
  108 +
  109 + this.prods.not('.hide').addClass('hide');
  110 + this.curProds = this.prods.eq(index);
  111 + this.curProds.removeClass('hide');
  112 +
  113 + $('body').animate({
  114 + scrollTop: this.elem.offset().top
  115 + }, 400);
  116 + }
  117 +});
  118 +
  119 +
  120 +module.exports = CollocationBlock;
@@ -70,7 +70,7 @@ $nav.on('touchend touchcancel', function(e) { @@ -70,7 +70,7 @@ $nav.on('touchend touchcancel', function(e) {
70 return; 70 return;
71 } 71 }
72 72
73 - 73 + e.preventDefault();
74 index = $this.index(); 74 index = $this.index();
75 75
76 $this.addClass('focus'); 76 $this.addClass('focus');
@@ -5,10 +5,10 @@ @@ -5,10 +5,10 @@
5 */ 5 */
6 6
7 var $ = require('yoho-jquery'), 7 var $ = require('yoho-jquery'),
8 - Hammer = require('yoho-hammer'), 8 + Hammer = require('../common/toy-hammer'),
9 ellipsis = require('yoho-mlellipsis'), 9 ellipsis = require('yoho-mlellipsis'),
10 lazyLoad = require('yoho-jquery-lazyload'), 10 lazyLoad = require('yoho-jquery-lazyload'),
11 - Swiper = require('yoho-swiper'); 11 + Swiper = require('yoho-swiper2');
12 12
13 var tip = require('../plugin/tip'); 13 var tip = require('../plugin/tip');
14 var loading = require('../plugin/loading'); 14 var loading = require('../plugin/loading');
@@ -52,12 +52,15 @@ function initSwiper(typeId) { @@ -52,12 +52,15 @@ function initSwiper(typeId) {
52 if (!typeId) { 52 if (!typeId) {
53 return; 53 return;
54 } 54 }
55 - mySwiper[typeId] = new Swiper('.swiper-cont-' + typeId, {  
56 - lazyLoading: true,  
57 - wrapperClass: 'swiper-wrap-' + typeId,  
58 - pagination: '.swiper-pagi-' + typeId,  
59 - autoplay: 3000  
60 - }); 55 +
  56 + if (!mySwiper[typeId]) {
  57 + mySwiper[typeId] = new Swiper('.swiper-cont-' + typeId, {
  58 + lazyLoading: true,
  59 + wrapperClass: 'swiper-wrap-' + typeId,
  60 + pagination: '.swiper-pagi-' + typeId,
  61 + autoplay: 3000
  62 + });
  63 + }
61 } 64 }
62 65
63 /** 66 /**
@@ -101,12 +104,12 @@ function initInfosEvt($container) { @@ -101,12 +104,12 @@ function initInfosEvt($container) {
101 $info, 104 $info,
102 yhChannel; 105 yhChannel;
103 106
104 - // e.preventDefault(); 107 + e.preventDefault && e.preventDefault();
105 108
106 // 点赞 109 // 点赞
107 $btn = $this.closest('.like-btn'); 110 $btn = $this.closest('.like-btn');
108 if ($btn.length > 0 && !isLoading) { 111 if ($btn.length > 0 && !isLoading) {
109 - // e.preventDefault(); 112 +
110 if ($btn.hasClass('like')) { 113 if ($btn.hasClass('like')) {
111 opt = 'cancel'; 114 opt = 'cancel';
112 } 115 }
@@ -149,7 +152,6 @@ function initInfosEvt($container) { @@ -149,7 +152,6 @@ function initInfosEvt($container) {
149 var uid = getUrlParam('uid'); 152 var uid = getUrlParam('uid');
150 153
151 if (uid) { 154 if (uid) {
152 - e.preventDefault();  
153 if ($btn.hasClass('collected')) { 155 if ($btn.hasClass('collected')) {
154 opt = 'cancel'; 156 opt = 'cancel';
155 } 157 }
@@ -162,13 +164,16 @@ function initInfosEvt($container) { @@ -162,13 +164,16 @@ function initInfosEvt($container) {
162 164
163 $.ajax({ 165 $.ajax({
164 type: 'POST', 166 type: 'POST',
165 - url: '/guang/opt/collectArticle', 167 + url: location.protocol + '//m.yohobuy.com/guang/opt/collectArticle',
166 data: { 168 data: {
167 id: $info.data('id'), 169 id: $info.data('id'),
168 opt: opt, 170 opt: opt,
169 yh_channel: yhChannel, 171 yh_channel: yhChannel,
170 uid: uid 172 uid: uid
171 }, 173 },
  174 + xhrFields: {
  175 + withCredentials: true
  176 + },
172 success: function(data) { 177 success: function(data) {
173 if (data.code && data.code === 200) { 178 if (data.code && data.code === 200) {
174 179
@@ -7,192 +7,125 @@ require('guang/info-index.page.css'); @@ -7,192 +7,125 @@ require('guang/info-index.page.css');
7 7
8 var $ = require('yoho-jquery'), 8 var $ = require('yoho-jquery'),
9 ellipsis = require('yoho-mlellipsis'), 9 ellipsis = require('yoho-mlellipsis'),
10 - lazyLoad = require('yoho-jquery-lazyload'),  
11 - IScroll = require('yoho-iscroll/build/iscroll-probe'); 10 + lazyLoad = require('yoho-jquery-lazyload');
12 11
13 var $authorIntro = $('.author .intro'); 12 var $authorIntro = $('.author .intro');
14 13
15 -var pageInIscroll = false;  
16 -  
17 -var hasCollocationBlock = $('.collocation-block').length > 0 ? true : false;  
18 -  
19 // collocation block variable 14 // collocation block variable
20 -var thumbWidth = 0,  
21 - $fixedThumbContainer = $(''),  
22 - $coBlock, $thumbContainer, $thumbs, $prods,  
23 - scrollToEl,  
24 - myScroll,  
25 - winW = $(window).width(); 15 +var $fixedThumbContainer = $(''),
  16 + $coBlock,
  17 + $thumbContainer = $('.thumb-container');
26 18
27 var $sideNav = $('.side-nav'), 19 var $sideNav = $('.side-nav'),
28 $guangPage = $('.guang-detail-page'), 20 $guangPage = $('.guang-detail-page'),
29 $overlay = $('.overlay'), 21 $overlay = $('.overlay'),
30 $subNav = $('.sub-nav'); 22 $subNav = $('.sub-nav');
31 23
32 -  
33 -scrollToEl = document.querySelector('#wrapper .collocation-block');  
34 -  
35 -  
36 require('../common'); 24 require('../common');
37 require('../plugin/wx-share')(); 25 require('../plugin/wx-share')();
38 require('./detail-dynamic'); 26 require('./detail-dynamic');
39 27
40 -/**  
41 - * 计算搭配的箭头的位置  
42 - * @param $curPos 当前focus的搭配项  
43 - */  
44 -function posCollocationArrow($curCo) {  
45 - var left = $curCo.offset().left,  
46 - bgPos = -winW + left + (thumbWidth / 2) + 'px';  
47 -  
48 - $thumbContainer.css({  
49 - backgroundPosition: bgPos + ' bottom'  
50 - });  
51 -  
52 - if (pageInIscroll) {  
53 - $fixedThumbContainer.css({  
54 - backgroundPosition: bgPos + ' bottom'  
55 - });  
56 - }  
57 -}  
58 -  
59 -// 搭配thumb的touch事件句柄  
60 -function thumbTouchEvt(e) {  
61 - var $curCo = $(e.currentTarget),  
62 - index = $curCo.index(),  
63 - $brother, $brotherCo,  
64 - $curProds;  
65 -  
66 - if ($curCo.hasClass('focus')) {  
67 - return;  
68 - } 28 +var CollactionBlock = require('./collocation-block');
69 29
70 - $thumbs.filter('.focus').removeClass('focus');  
71 -  
72 - if (pageInIscroll) {  
73 - if ($curCo.closest('.fixed-thumb-container').length > 0) {  
74 - $brother = $thumbContainer;  
75 - } else {  
76 - $brother = $fixedThumbContainer;  
77 - }  
78 -  
79 - $brotherCo = $brother.find('.thumb').eq(index);  
80 - $fixedThumbContainer.find('.thumb.focus').removeClass('focus');  
81 - $brotherCo.addClass('focus');  
82 - }  
83 -  
84 - $curCo.addClass('focus');  
85 -  
86 - // 定位arrow  
87 - posCollocationArrow($curCo);  
88 -  
89 - $prods.not('.hide').addClass('hide');  
90 - $curProds = $prods.eq(index);  
91 - $curProds.removeClass('hide');  
92 -  
93 - //  
94 - lazyLoad($curProds.find('.lazy'));  
95 -  
96 - if (pageInIscroll) {  
97 - if (myScroll) {  
98 - myScroll.scrollToElement(scrollToEl, 400);  
99 - }  
100 - } else {  
101 - $('body').animate({  
102 - scrollTop: $coBlock.offset().top  
103 - }, 400);  
104 - }  
105 -  
106 - myScroll && myScroll.refresh();  
107 -} 30 +$('#wrapper').css({
  31 + 'overflow-y': 'scroll'
  32 +});
108 33
109 // 初始化iscroll 34 // 初始化iscroll
110 function initIscroll() { 35 function initIscroll() {
111 - var $scroller = $('#scroller'),  
112 - $yohoHeader = $('.yoho-header');  
113 - 36 + var $yohoHeader = $('.yoho-header');
114 var hH = 0, 37 var hH = 0,
115 winH, tcH, cbH, cbTop, fixedThumbDom; 38 winH, tcH, cbH, cbTop, fixedThumbDom;
116 39
  40 + if (CollactionBlock.exists()) {
  41 + new CollactionBlock();
  42 + }
  43 +
117 // 考虑通用头部的影响:对offset().top以及winH做对应偏移 44 // 考虑通用头部的影响:对offset().top以及winH做对应偏移
118 if ($yohoHeader.length > 0) { 45 if ($yohoHeader.length > 0) {
119 hH = $yohoHeader.outerHeight(); 46 hH = $yohoHeader.outerHeight();
120 } 47 }
121 48
122 - myScroll = new IScroll('#wrapper', {  
123 - probeType: 3,  
124 - mouseWheel: true,  
125 - click: true  
126 - }); 49 + /*
  50 + myScroll = new IScroll('#wrapper', {
  51 + probeType: 3,
  52 + mouseWheel: true,
  53 + click: true
  54 + });
  55 + document.addEventListener('touchmove', function(e) {
  56 + e.preventDefault();
  57 + }, false);
127 58
128 - document.addEventListener('touchmove', function(e) {  
129 - e.preventDefault();  
130 - }, false); 59 + if (!hasCollocationBlock) {
  60 + myScroll.on('scroll', function() {
  61 + $scroller.trigger('scroll');
  62 + });
  63 + return;
  64 + }
  65 +
  66 + */
131 67
132 - if (!hasCollocationBlock) {  
133 - myScroll.on('scroll', function() {  
134 - $scroller.trigger('scroll');  
135 - });  
136 - return;  
137 - }  
138 68
139 winH = $(window).height() - hH; 69 winH = $(window).height() - hH;
140 fixedThumbDom = $fixedThumbContainer[0]; 70 fixedThumbDom = $fixedThumbContainer[0];
141 71
142 - tcH = $thumbContainer.outerHeight();  
143 - cbH = $coBlock.outerHeight();  
144 - cbTop = $coBlock.offset().top - hH; 72 + tcH = $thumbContainer ? $thumbContainer.outerHeight() : 0;
  73 + if ($coBlock) {
  74 + cbH = $coBlock.outerHeight();
  75 + cbTop = $coBlock.offset().top - hH;
  76 + }
145 77
146 - myScroll.on('scroll', function() { 78 + $(window).on('scroll', function() {
147 var sTop = -this.y; 79 var sTop = -this.y;
148 - var classList = fixedThumbDom.className; 80 + var classList = fixedThumbDom && fixedThumbDom.className;
149 81
150 if (sTop <= cbTop - winH + tcH) { 82 if (sTop <= cbTop - winH + tcH) {
151 if (classList.indexOf('fixed-bottom') === -1) { 83 if (classList.indexOf('fixed-bottom') === -1) {
152 $fixedThumbContainer 84 $fixedThumbContainer
153 - .addClass('fixed-bottom')  
154 - .removeClass('hide'); 85 + .addClass('fixed-bottom')
  86 + .removeClass('hide');
155 } 87 }
156 } else if (sTop <= cbTop) { 88 } else if (sTop <= cbTop) {
157 if (classList.indexOf('hide') === -1) { 89 if (classList.indexOf('hide') === -1) {
158 $fixedThumbContainer 90 $fixedThumbContainer
159 - .addClass('hide')  
160 - .removeClass('fixed-bottom fixed-top'); 91 + .addClass('hide')
  92 + .removeClass('fixed-bottom fixed-top');
161 } 93 }
162 } else if (sTop <= cbTop + cbH - tcH) { 94 } else if (sTop <= cbTop + cbH - tcH) {
163 if (classList.indexOf('fixed-top') === -1) { 95 if (classList.indexOf('fixed-top') === -1) {
164 $fixedThumbContainer 96 $fixedThumbContainer
165 - .addClass('fixed-top')  
166 - .removeClass('hide absolute')  
167 - .css('top', ''); 97 + .addClass('fixed-top')
  98 + .removeClass('hide absolute')
  99 + .css('top', '');
168 } 100 }
169 } else if (sTop <= cbTop + cbH) { 101 } else if (sTop <= cbTop + cbH) {
170 if (classList.indexOf('absolute') === -1) { 102 if (classList.indexOf('absolute') === -1) {
171 $fixedThumbContainer 103 $fixedThumbContainer
172 - .addClass('absolute')  
173 - .removeClass('fixed-top hide'); 104 + .addClass('absolute')
  105 + .removeClass('fixed-top hide');
174 } 106 }
175 fixedThumbDom.style.top = cbTop + hH + cbH - tcH - sTop + 'px'; 107 fixedThumbDom.style.top = cbTop + hH + cbH - tcH - sTop + 'px';
176 } else if (sTop > cbTop + cbH) { 108 } else if (sTop > cbTop + cbH) {
177 if (classList.indexOf('hide') === -1) { 109 if (classList.indexOf('hide') === -1) {
178 $fixedThumbContainer 110 $fixedThumbContainer
179 - .addClass('hide')  
180 - .removeClass('absolute'); 111 + .addClass('hide')
  112 + .removeClass('absolute');
181 } 113 }
182 } 114 }
183 - $scroller.trigger('scroll');  
184 }); 115 });
185 } 116 }
186 117
187 -// window onload 后重新refresh iscroll  
188 -window.onload = function() {  
189 - myScroll && myScroll.refresh();  
190 -}; 118 +/*
  119 + // window onload 后重新refresh iscroll
  120 + window.onload = function() {
  121 + myScroll && myScroll.refresh();
  122 + };
191 123
192 -// 图片加载完成之后重新 refresh iscroll  
193 -$('img').on('load', function() {  
194 - myScroll && myScroll.refresh();  
195 -}); 124 + // 图片加载完成之后重新 refresh iscroll
  125 + $('img').on('load', function() {
  126 + myScroll && myScroll.refresh();
  127 + });
  128 + */
196 129
197 // 微信导航 130 // 微信导航
198 $('.nav-btn').on('touchstart', function() { 131 $('.nav-btn').on('touchstart', function() {
@@ -301,7 +234,6 @@ function setCookie(name, value, options) { @@ -301,7 +234,6 @@ function setCookie(name, value, options) {
301 // 初始化页面,包括是否使用iscorll初始化页面 234 // 初始化页面,包括是否使用iscorll初始化页面
302 // 接口暴露在HTML中,使用压缩名 235 // 接口暴露在HTML中,使用压缩名
303 (function() { 236 (function() {
304 - var useIscroll;  
305 var isIphone = navigator.userAgent.indexOf('iPhone') > 0 ? true : false; 237 var isIphone = navigator.userAgent.indexOf('iPhone') > 0 ? true : false;
306 var isweixin = navigator.userAgent.indexOf('MicroMessenger') ? true : false; 238 var isweixin = navigator.userAgent.indexOf('MicroMessenger') ? true : false;
307 var $this, $title; 239 var $this, $title;
@@ -312,17 +244,10 @@ function setCookie(name, value, options) { @@ -312,17 +244,10 @@ function setCookie(name, value, options) {
312 244
313 isHeader && $('#yoho-header').remove(); 245 isHeader && $('#yoho-header').remove();
314 246
315 - if ($('.guang-detail-page').hasClass('guang-detail')) {  
316 - useIscroll = true;  
317 - } else if ($('.guang-detail-page').hasClass('guang-ezine')) {  
318 - useIscroll = false;  
319 - }  
320 $('.main-wrap').css({ 247 $('.main-wrap').css({
321 position: 'static' 248 position: 'static'
322 }); 249 });
323 250
324 - pageInIscroll = isIphone && useIscroll;  
325 -  
326 ellipsis.init(); 251 ellipsis.init();
327 252
328 if ($('.good-detail-text .name').length > 0) { 253 if ($('.good-detail-text .name').length > 0) {
@@ -342,18 +267,10 @@ function setCookie(name, value, options) { @@ -342,18 +267,10 @@ function setCookie(name, value, options) {
342 267
343 // offset.left约等于marginLeft的值则表示介绍被换行,则清除intro的paddingTop让其更靠近头像和作者名 268 // offset.left约等于marginLeft的值则表示介绍被换行,则清除intro的paddingTop让其更靠近头像和作者名
344 if ($authorIntro.offset() && (parseInt($authorIntro.offset().left, 10) === 269 if ($authorIntro.offset() && (parseInt($authorIntro.offset().left, 10) ===
345 - parseInt($authorIntro.css('margin-left'), 10))) { 270 + parseInt($authorIntro.css('margin-left'), 10))) {
346 $authorIntro.css('padding-top', 0); 271 $authorIntro.css('padding-top', 0);
347 } 272 }
348 273
349 - if (pageInIscroll) {  
350 - if ($('.yoho-header').length > 0) {  
351 - $('#wrapper').addClass('ios has-head');  
352 - } else {  
353 - $('#wrapper').addClass('ios');  
354 - }  
355 - }  
356 -  
357 if (isweixin) { 274 if (isweixin) {
358 if (isIphone) { 275 if (isIphone) {
359 $overlay.css('position', 'relative'); 276 $overlay.css('position', 'relative');
@@ -362,41 +279,6 @@ function setCookie(name, value, options) { @@ -362,41 +279,6 @@ function setCookie(name, value, options) {
362 } 279 }
363 } 280 }
364 281
365 - // 有搭配模块,iphone使用iscroll初始化滚动并有固定的搭配栏,其他的没有  
366 - if (hasCollocationBlock) {  
367 - $coBlock = $('.collocation-block');  
368 - $thumbContainer = $coBlock.children('.thumb-container');  
369 - $thumbs = $thumbContainer.find('li');  
370 - $prods = $coBlock.find('.prod');  
371 -  
372 - thumbWidth = $thumbs.width();  
373 -  
374 - if (pageInIscroll) {  
375 - $fixedThumbContainer = $('#wrapper')  
376 - .after($thumbContainer.clone().addClass('fixed-thumb-container fixed-bottom'))  
377 - .next('.thumb-container');  
378 -  
379 - // load img of fixed thumb container  
380 - lazyLoad($fixedThumbContainer.find('.lazy'), {  
381 - event: 'sporty'  
382 - });  
383 - }  
384 -  
385 - // Init Arrow Position  
386 - posCollocationArrow($thumbs.filter('.focus'));  
387 -  
388 - $thumbContainer.delegate('.thumb', 'touchend', thumbTouchEvt);  
389 -  
390 - if (pageInIscroll) {  
391 - $fixedThumbContainer.delegate('.thumb', 'touchend', thumbTouchEvt);  
392 -  
393 - }  
394 - }  
395 -  
396 - if (pageInIscroll) {  
397 - initIscroll();  
398 - }  
399 -  
400 $('#float-layer-close').on('touchend', function(index) { 282 $('#float-layer-close').on('touchend', function(index) {
401 var appClose = window.cookie('_float-layer-app-close') || '0'; 283 var appClose = window.cookie('_float-layer-app-close') || '0';
402 284
@@ -430,4 +312,7 @@ function setCookie(name, value, options) { @@ -430,4 +312,7 @@ function setCookie(name, value, options) {
430 $('.down-bottom').hide(); 312 $('.down-bottom').hide();
431 } 313 }
432 } 314 }
  315 +
  316 + initIscroll();
433 }()); 317 }());
  318 +
@@ -5,10 +5,9 @@ @@ -5,10 +5,9 @@
5 */ 5 */
6 6
7 var $ = require('yoho-jquery'), 7 var $ = require('yoho-jquery'),
8 - Hammer = require('yoho-hammer'),  
9 ellipsis = require('yoho-mlellipsis'), 8 ellipsis = require('yoho-mlellipsis'),
10 lazyLoad = require('yoho-jquery-lazyload'), 9 lazyLoad = require('yoho-jquery-lazyload'),
11 - Swiper = require('yoho-swiper'); 10 + Swiper = require('yoho-swiper2');
12 11
13 var tip = require('../plugin/tip'); 12 var tip = require('../plugin/tip');
14 var loading = require('../plugin/loading'); 13 var loading = require('../plugin/loading');
@@ -21,7 +20,6 @@ var $loading = $(''), @@ -21,7 +20,6 @@ var $loading = $(''),
21 var searching = false; 20 var searching = false;
22 var mySwiper = {}; 21 var mySwiper = {};
23 22
24 -var isLoading = false;  
25 var getDynamicData = require('./list-dynamic'); 23 var getDynamicData = require('./list-dynamic');
26 24
27 require('../common'); 25 require('../common');
@@ -52,15 +50,18 @@ function getUrlParam(name) { @@ -52,15 +50,18 @@ function getUrlParam(name) {
52 50
53 // 初始化swiper 51 // 初始化swiper
54 function initSwiper(typeId) { 52 function initSwiper(typeId) {
55 - if (typeof typeId === undefined) { 53 + if (typeof typeId === 'undefined') {
56 return; 54 return;
57 } 55 }
58 - mySwiper[typeId] = new Swiper('.swiper-cont-' + typeId, {  
59 - lazyLoading: true,  
60 - wrapperClass: 'swiper-wrap-' + typeId,  
61 - pagination: '.swiper-pagi-' + typeId,  
62 - autoplay: 3000  
63 - }); 56 +
  57 + if (!mySwiper[typeId]) {
  58 + mySwiper[typeId] = new Swiper('.swiper-cont-' + typeId, {
  59 + lazyLoading: true,
  60 + wrapperClass: 'swiper-wrap-' + typeId,
  61 + pagination: '.swiper-pagi-' + typeId,
  62 + autoplay: 3000
  63 + });
  64 + }
64 } 65 }
65 66
66 /** 67 /**
@@ -85,38 +86,28 @@ function setLazyLoadAndMellipsis($infos) { @@ -85,38 +86,28 @@ function setLazyLoadAndMellipsis($infos) {
85 * @params $container 逛资讯列表容器 86 * @params $container 逛资讯列表容器
86 */ 87 */
87 function initInfosEvt($container) { 88 function initInfosEvt($container) {
88 - var cHammer;  
89 -  
90 if (typeof $container === 'undefined') { 89 if (typeof $container === 'undefined') {
91 return; 90 return;
92 } 91 }
93 if (typeof $container[0] === 'undefined') { 92 if (typeof $container[0] === 'undefined') {
94 return; 93 return;
95 } 94 }
96 - cHammer = new Hammer($container[0]);  
97 -  
98 - // 点赞或者收藏事件  
99 - cHammer.on('tap', function(e) {  
100 - var $this = $(e.target),  
101 - opt = 'ok',  
102 - $btn,  
103 - $info,  
104 - yhChannel;  
105 95
106 - // e.preventDefault(); 96 + $container.on('touchend touchcancel', function(e) {
  97 + var $this = $(e.target);
107 98
108 // 点赞 99 // 点赞
109 - $btn = $this.closest('.like-btn');  
110 - if ($btn.length > 0 && !isLoading) { 100 + var $btn = $this.closest('.like-btn');
  101 + if ($btn.length > 0) {
111 e.preventDefault(); 102 e.preventDefault();
  103 +
  104 + var opt = 'ok',
  105 + $info;
  106 +
112 if ($btn.hasClass('like')) { 107 if ($btn.hasClass('like')) {
113 opt = 'cancel'; 108 opt = 'cancel';
114 } 109 }
115 -  
116 - $info = $this.closest('.guang-info');  
117 -  
118 - isLoading = true;  
119 - 110 + $info = $btn.closest('.guang-info');
120 $.ajax({ 111 $.ajax({
121 type: 'POST', 112 type: 'POST',
122 url: '/guang/opt/praiseArticle', 113 url: '/guang/opt/praiseArticle',
@@ -127,19 +118,14 @@ function initInfosEvt($container) { @@ -127,19 +118,14 @@ function initInfosEvt($container) {
127 success: function(data) { 118 success: function(data) {
128 var code = data.code; 119 var code = data.code;
129 120
130 -  
131 if (code === 200) { 121 if (code === 200) {
132 $btn.next('.like-count').text(data.data); 122 $btn.next('.like-count').text(data.data);
133 -  
134 // 切换点赞状态 123 // 切换点赞状态
135 $btn.toggleClass('like'); 124 $btn.toggleClass('like');
136 } 125 }
137 }, 126 },
138 error: function() { 127 error: function() {
139 tip.show('网络断开连接了~'); 128 tip.show('网络断开连接了~');
140 - },  
141 - complete: function() {  
142 - isLoading = false;  
143 } 129 }
144 }); 130 });
145 return; 131 return;
@@ -149,28 +135,33 @@ function initInfosEvt($container) { @@ -149,28 +135,33 @@ function initInfosEvt($container) {
149 $btn = $this.closest('.collect-btn'); 135 $btn = $this.closest('.collect-btn');
150 if ($btn.length > 0) { 136 if ($btn.length > 0) {
151 e.preventDefault(); 137 e.preventDefault();
  138 +
  139 + var opt = 'ok',
  140 + $info,
  141 + yhChannel;
  142 +
152 if ($btn.hasClass('collected')) { 143 if ($btn.hasClass('collected')) {
153 opt = 'cancel'; 144 opt = 'cancel';
154 } 145 }
155 -  
156 - $info = $this.closest('.guang-info');  
157 - 146 + $info = $btn.closest('.guang-info');
158 if (getUrlParam('yh_channel')) { 147 if (getUrlParam('yh_channel')) {
159 yhChannel = getUrlParam('yh_channel'); 148 yhChannel = getUrlParam('yh_channel');
160 } 149 }
161 150
162 $.ajax({ 151 $.ajax({
163 type: 'POST', 152 type: 'POST',
164 - url: '/guang/opt/collectArticle', 153 + url: location.protocol + '//m.yohobuy.com/guang/opt/collectArticle',
165 data: { 154 data: {
166 id: $info.data('id'), 155 id: $info.data('id'),
167 opt: opt, 156 opt: opt,
168 yh_channel: yhChannel, 157 yh_channel: yhChannel,
169 uid: getUrlParam('uid') 158 uid: getUrlParam('uid')
170 }, 159 },
  160 + xhrFields: {
  161 + withCredentials: true
  162 + },
171 success: function(data) { 163 success: function(data) {
172 if (data.code && data.code === 200) { 164 if (data.code && data.code === 200) {
173 -  
174 // 切换收藏状态 165 // 切换收藏状态
175 $btn.toggleClass('collected'); 166 $btn.toggleClass('collected');
176 } 167 }
@@ -179,6 +170,7 @@ function initInfosEvt($container) { @@ -179,6 +170,7 @@ function initInfosEvt($container) {
179 tip.show('网络断开连接了~'); 170 tip.show('网络断开连接了~');
180 } 171 }
181 }); 172 });
  173 + return;
182 } 174 }
183 }); 175 });
184 176
@@ -253,8 +245,6 @@ function loadMore($container, opt, url) { @@ -253,8 +245,6 @@ function loadMore($container, opt, url) {
253 245
254 getDynamicData.getDynamicData(); 246 getDynamicData.getDynamicData();
255 window.rePosFooter();// 插入内容后重新计算底部位置 247 window.rePosFooter();// 插入内容后重新计算底部位置
256 -  
257 - getDynamicData.getDynamicData();  
258 } 248 }
259 249
260 opt.page++; 250 opt.page++;
@@ -31,6 +31,10 @@ function getDynamicByIds(ids) { @@ -31,6 +31,10 @@ function getDynamicByIds(ids) {
31 data.type = '0'; 31 data.type = '0';
32 } 32 }
33 33
  34 + if (qs.uid) {
  35 + data.uid = qs.uid;
  36 + }
  37 +
34 return $.ajax({ 38 return $.ajax({
35 type: 'GET', 39 type: 'GET',
36 url: '/guang/info/listData', 40 url: '/guang/info/listData',
@@ -64,6 +68,11 @@ function renderData(data) { @@ -64,6 +68,11 @@ function renderData(data) {
64 $it.find('.like-btn').removeClass('like'); 68 $it.find('.like-btn').removeClass('like');
65 } 69 }
66 70
  71 + //收藏数目
  72 + if (it.isFavor === 'Y') {
  73 + $it.find('.collect-btn').addClass('collected');
  74 + }
  75 +
67 // 点赞数目 76 // 点赞数目
68 $it.find('.like-count').text(it.praise_num); 77 $it.find('.like-count').text(it.praise_num);
69 78
@@ -78,17 +87,19 @@ function renderData(data) { @@ -78,17 +87,19 @@ function renderData(data) {
78 function getDynamicData() { 87 function getDynamicData() {
79 'use strict'; 88 'use strict';
80 89
81 - var idArr = []; 90 + setTimeout(function() {
  91 + var idArr = [];
82 92
83 - $('.info-list').not('.hide').find('.guang-info').each(function() {  
84 - var id = $(this).data('id'); 93 + $('.info-list').not('.hide').find('.guang-info').each(function() {
  94 + var id = $(this).data('id');
85 95
86 - if (id) {  
87 - idArr.push(id);  
88 - }  
89 - }); 96 + if (id) {
  97 + idArr.push(id);
  98 + }
  99 + });
90 100
91 - getDynamicByIds(idArr.join(',')).then(renderData); 101 + getDynamicByIds(idArr.join(',')).then(renderData);
  102 + }, 150);
92 } 103 }
93 104
94 module.exports = { 105 module.exports = {
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 */ 5 */
6 6
7 var $ = require('yoho-jquery'), 7 var $ = require('yoho-jquery'),
8 - Hammer = require('yoho-hammer'), 8 + Hammer = require('../common/toy-hammer'),
9 ellipsis = require('yoho-mlellipsis'), 9 ellipsis = require('yoho-mlellipsis'),
10 lazyLoad = require('yoho-jquery-lazyload'); 10 lazyLoad = require('yoho-jquery-lazyload');
11 11
@@ -103,7 +103,7 @@ $loginBtn.on('touchstart', function() { @@ -103,7 +103,7 @@ $loginBtn.on('touchstart', function() {
103 103
104 $loginBtn.text('正在登录...').addClass('disable'); 104 $loginBtn.text('正在登录...').addClass('disable');
105 105
106 - if (api.phoneRegx[areaCode].test(pn) && api.pwdValidate(pwd)) { 106 + if ((api.phoneRegx[areaCode].test(pn) || areaCode !== '+86') && api.pwdValidate(pwd)) {
107 let data = { 107 let data = {
108 areaCode: areaCode.replace('+', ''), 108 areaCode: areaCode.replace('+', ''),
109 account: pn, 109 account: pn,
@@ -87,7 +87,7 @@ $btnNext.on('touchstart', function() { @@ -87,7 +87,7 @@ $btnNext.on('touchstart', function() {
87 } 87 }
88 88
89 89
90 - if (api.phoneRegx[areaCode].test(pn)) { 90 + if (api.phoneRegx[areaCode].test(pn) || areaCode !== '+86') {
91 91
92 requested = true; 92 requested = true;
93 93
@@ -112,8 +112,9 @@ function subClassifyTapEvt($this) { @@ -112,8 +112,9 @@ function subClassifyTapEvt($this) {
112 if (fCbFn) { 112 if (fCbFn) {
113 fCbFn({ 113 fCbFn({
114 type: $sub.data('type'), 114 type: $sub.data('type'),
115 - id: id  
116 - }, true); 115 + id: id,
  116 + filtering: true
  117 + });
117 } 118 }
118 119
119 if (hCbFn) { 120 if (hCbFn) {
@@ -4,8 +4,10 @@ @@ -4,8 +4,10 @@
4 * @date: 2016/5/17 4 * @date: 2016/5/17
5 */ 5 */
6 6
  7 +require('../../scss/product/sale/_index.css');
  8 +
7 var $ = require('yoho-jquery'), 9 var $ = require('yoho-jquery'),
8 - Swiper = require('yoho-swiper'), 10 + Swiper = require('yoho-swiper2'),
9 ellipsis = require('yoho-mlellipsis'), 11 ellipsis = require('yoho-mlellipsis'),
10 fastclick = require('yoho-fastclick'), 12 fastclick = require('yoho-fastclick'),
11 lazyload = require('yoho-jquery-lazyload'); 13 lazyload = require('yoho-jquery-lazyload');
@@ -101,7 +101,7 @@ C_ID = window._ChannelVary[window.cookie('_Channel')]; @@ -101,7 +101,7 @@ C_ID = window._ChannelVary[window.cookie('_Channel')];
101 // 首屏无数据 101 // 首屏无数据
102 if ($fsgc.children().length === 0) { 102 if ($fsgc.children().length === 0) {
103 $goodsContainer.html(noResult); 103 $goodsContainer.html(noResult);
104 -} 104 +}
105 105
106 ellipsis.init(); 106 ellipsis.init();
107 107
@@ -295,8 +295,7 @@ if ($fsgc.children().length > 0) { @@ -295,8 +295,7 @@ if ($fsgc.children().length > 0) {
295 * 需要执行search的场景:1.点选筛选项;2.relaod为true时切换导航;3.下拉加载 295 * 需要执行search的场景:1.点选筛选项;2.relaod为true时切换导航;3.下拉加载
296 * @param opt {type, id} 296 * @param opt {type, id}
297 */ 297 */
298 -function search(opt, filtering) {  
299 - 298 +function search(opt) {
300 var setting = {}, 299 var setting = {},
301 ext, 300 ext,
302 att, 301 att,
@@ -517,7 +516,7 @@ function search(opt, filtering) { @@ -517,7 +516,7 @@ function search(opt, filtering) {
517 516
518 argument = setting; 517 argument = setting;
519 518
520 - if (filtering) { 519 + if (opt && opt.filtering) {
521 $fsgc.addClass('hide'); 520 $fsgc.addClass('hide');
522 if (params.start) { 521 if (params.start) {
523 delete setting.start; 522 delete setting.start;
@@ -917,7 +916,7 @@ $newList.on('touchstart', 'li', function(e) { @@ -917,7 +916,7 @@ $newList.on('touchstart', 'li', function(e) {
917 break; 916 break;
918 } 917 }
919 $pre = $firstLiDom; 918 $pre = $firstLiDom;
920 - search({}, true); 919 + search({filtering: true});
921 }); 920 });
922 921
923 $(document).on('touchstart', function(e) { 922 $(document).on('touchstart', function(e) {
@@ -1159,7 +1158,7 @@ $('#goods-container').on('click', '.good-info', function() { @@ -1159,7 +1158,7 @@ $('#goods-container').on('click', '.good-info', function() {
1159 PRD_NUM = $(this).index(), 1158 PRD_NUM = $(this).index(),
1160 FILTER_VALUE = filext ? JSON.stringify(filext).replace(/\{|\}|\"/g, '') : '', 1159 FILTER_VALUE = filext ? JSON.stringify(filext).replace(/\{|\}|\"/g, '') : '',
1161 yasparms, 1160 yasparms,
1162 - firstType; 1161 + firstType;
1163 1162
1164 if ($(this).parent().hasClass('firstscreen-goods')) { 1163 if ($(this).parent().hasClass('firstscreen-goods')) {
1165 firstType = 'default'; 1164 firstType = 'default';
@@ -38,6 +38,7 @@ @@ -38,6 +38,7 @@
38 .banner-swiper { 38 .banner-swiper {
39 position: static; 39 position: static;
40 max-height: 312px; 40 max-height: 312px;
  41 + height: 312px;
41 42
42 ul { 43 ul {
43 position: relative; 44 position: relative;
@@ -3,3 +3,25 @@ @@ -3,3 +3,25 @@
3 @import "sale"; 3 @import "sale";
4 @import "discount"; 4 @import "discount";
5 @import "discount-detail"; 5 @import "discount-detail";
  6 +@import "../../layout/_swiper.css";
  7 +@import "../../channel/_banner-top.css";
  8 +@import "../../channel/_floor-header.css";
  9 +@import "../../channel/_discount-list.css";
  10 +@import "../../channel/_thumb-row.css";
  11 +@import "../../common/_good.css";
  12 +@import "../../common/_filter.css";
  13 +
  14 +.banner-swiper {
  15 + ul {
  16 + li {
  17 + img {
  18 + width: 100%;
  19 + height: auto;
  20 + }
  21 + }
  22 + }
  23 +}
  24 +
  25 +.swiper-lazy-preloader {
  26 + transform: translate3d(0, 0, -1px);
  27 +}
@@ -8,10 +8,10 @@ module.exports = { @@ -8,10 +8,10 @@ module.exports = {
8 imgSrc: function(imgSrc) { 8 imgSrc: function(imgSrc) {
9 return url.resolve(assetUrl, imgSrc); 9 return url.resolve(assetUrl, imgSrc);
10 }, 10 },
11 - image2: function(url, opts) {  
12 - if (url) { 11 + image2: function(imageUrl, opts) {
  12 + if (imageUrl) {
13 let params = opts.hash; 13 let params = opts.hash;
14 - let urls = url.split('?'); 14 + let urls = imageUrl.split('?');
15 let query = urls[1] || ''; 15 let query = urls[1] || '';
16 let uri = urls[0]; 16 let uri = urls[0];
17 17
@@ -34,13 +34,23 @@ module.exports = { @@ -34,13 +34,23 @@ module.exports = {
34 } else { 34 } else {
35 query += '/quality/' + params.q; 35 query += '/quality/' + params.q;
36 } 36 }
  37 + } else if (query.indexOf('imageView/') === 0){
  38 + if (params.q && query.indexOf('/q/') > 0) {
  39 + query = query.replace(/\/q\/\d+/g, '/q/' + params.q);
  40 + } else {
  41 + query += '/q/' + params.q;
  42 + }
  43 +
  44 + if (params.mode) {
  45 + query = query.replace(/imageView\/\d{1}\//, 'imageView/' + params.mode + '/');
  46 + }
37 } 47 }
38 } else { 48 } else {
39 query = 'imageView2/2/interlace/1/q/' + (params.q || 75); 49 query = 'imageView2/2/interlace/1/q/' + (params.q || 75);
40 } 50 }
41 return uri + '?' + query; 51 return uri + '?' + query;
42 } else { 52 } else {
43 - return url; 53 + return imageUrl;
44 } 54 }
45 }, 55 },
46 ifor: function() { 56 ifor: function() {
@@ -60,5 +70,19 @@ module.exports = { @@ -60,5 +70,19 @@ module.exports = {
60 } else { 70 } else {
61 return opt.inverse(this); 71 return opt.inverse(this);
62 } 72 }
  73 + },
  74 +
  75 + /**
  76 + * 小于某zhi
  77 + *
  78 + * @param variable
  79 + * @param number
  80 + */
  81 + within: function(variable, number, opt) {
  82 + if (variable < number) {
  83 + return opt.fn(this);
  84 + } else {
  85 + return opt.inverse(this);
  86 + }
63 } 87 }
64 }; 88 };
  1 +/**
  2 + * Created by yoho on 2016/12/19.
  3 + */
  4 +
  5 +module.exports = function (nameStr) {
  6 + return nameStr.match(/\w/ig).join('');
  7 +};
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 require('../app'); 2 require('../app');
3 const _ = require('lodash'); 3 const _ = require('lodash');
4 const helpers = global.yoho.helpers; 4 const helpers = global.yoho.helpers;
  5 +const productNameProcess = require('./product-name-process');
5 6
6 const toArray = (obj) => { 7 const toArray = (obj) => {
7 if (_.isArray(obj)) { 8 if (_.isArray(obj)) {
@@ -93,6 +94,11 @@ exports.processProductList = (list, options) => { @@ -93,6 +94,11 @@ exports.processProductList = (list, options) => {
93 } 94 }
94 95
95 product.is_soon_sold_out = product.is_soon_sold_out === 'Y'; 96 product.is_soon_sold_out = product.is_soon_sold_out === 'Y';
  97 +
  98 + if (product.cn_alphabet) {
  99 + product.cn_alphabet = productNameProcess(product.cn_alphabet);
  100 + }
  101 +
96 product.url = helpers.urlFormat(`/product/pro_${product.product_id}_${product.goods_list[0].goods_id}/${product.cn_alphabet}.html`); // eslint-disable-line 102 product.url = helpers.urlFormat(`/product/pro_${product.product_id}_${product.goods_list[0].goods_id}/${product.cn_alphabet}.html`); // eslint-disable-line
97 103
98 // APP访问需要加附加的参数 104 // APP访问需要加附加的参数