Authored by 姜枫

merge from shop-optim

@@ -237,6 +237,7 @@ const shop = { @@ -237,6 +237,7 @@ const shop = {
237 237
238 return _.split(uidString, '=')[1]; 238 return _.split(uidString, '=')[1];
239 }, 239 },
  240 +
240 /** 241 /**
241 * TODO TAR 店铺和品牌收藏状态调用新的接口 242 * TODO TAR 店铺和品牌收藏状态调用新的接口
242 * 基础模板收藏 243 * 基础模板收藏
@@ -255,6 +256,7 @@ const shop = { @@ -255,6 +256,7 @@ const shop = {
255 res.json(Object.assign({code: 200}, result)); 256 res.json(Object.assign({code: 200}, result));
256 }).catch(next); 257 }).catch(next);
257 }, 258 },
  259 +
258 /** 260 /**
259 * TODO TAR 店铺和品牌收藏状态调用新的接口 261 * TODO TAR 店铺和品牌收藏状态调用新的接口
260 * @param req 262 * @param req
@@ -263,8 +265,9 @@ const shop = { @@ -263,8 +265,9 @@ const shop = {
263 brandFav(req, res, next) { 265 brandFav(req, res, next) {
264 let brandId = req.query.brandId; 266 let brandId = req.query.brandId;
265 let uid = req.user.uid; 267 let uid = req.user.uid;
266 - if (!brandId) {  
267 - return res.json({code: 404}) 268 +
  269 + if (!brandId) {
  270 + return res.json({code: 404});
268 } 271 }
269 return listModel.getBrandIntro(brandId, uid).then(result => { 272 return listModel.getBrandIntro(brandId, uid).then(result => {
270 res.json(result); 273 res.json(result);
@@ -272,6 +275,7 @@ const shop = { @@ -272,6 +275,7 @@ const shop = {
272 }, 275 },
273 shopHotList(req, res, next) { 276 shopHotList(req, res, next) {
274 let skns = req.query.skns; 277 let skns = req.query.skns;
  278 +
275 return listModel.searchProductBySkn(skns).then(hotList => { 279 return listModel.searchProductBySkn(skns).then(hotList => {
276 hotList = productProcess.processProductList(hotList, {isApp: req.yoho.isApp}); 280 hotList = productProcess.processProductList(hotList, {isApp: req.yoho.isApp});
277 _.forEach(hotList, (value, key) => { 281 _.forEach(hotList, (value, key) => {
@@ -287,6 +291,7 @@ const shop = { @@ -287,6 +291,7 @@ const shop = {
287 }).catch(next); 291 }).catch(next);
288 } 292 }
289 }; 293 };
  294 +
290 /** 295 /**
291 * 从 useragent 获取 uid 296 * 从 useragent 获取 uid
292 * @returns {*} 297 * @returns {*}
1 -require('./shop/shop-base');  
  1 +require('./shop/shop-base');
1 -require('./shop/shop-base');  
  1 +require('./shop/shop-base');
@@ -45,6 +45,7 @@ var winH = $(window).height(), @@ -45,6 +45,7 @@ var winH = $(window).height(),
45 noResult = '<p class="no-result">未找到相关搜索结果</p>'; 45 noResult = '<p class="no-result">未找到相关搜索结果</p>';
46 46
47 require('../common'); 47 require('../common');
  48 +
48 // 默认筛选条件 49 // 默认筛选条件
49 var defaultOpt = require('../common/query-param'); 50 var defaultOpt = require('../common/query-param');
50 51
@@ -53,7 +54,7 @@ var defaultOpt = require('../common/query-param'); @@ -53,7 +54,7 @@ var defaultOpt = require('../common/query-param');
53 var param = location.search; 54 var param = location.search;
54 var isApp = param.indexOf('app_version') > -1 || param.indexOf('appVersion') > -1; 55 var isApp = param.indexOf('app_version') > -1 || param.indexOf('appVersion') > -1;
55 56
56 - //不阻塞字体文件加载 57 + // 不阻塞字体文件加载
57 setTimeout(function() { 58 setTimeout(function() {
58 if (isApp) { 59 if (isApp) {
59 $.ajax({ 60 $.ajax({
@@ -97,7 +98,7 @@ var defaultOpt = require('../common/query-param'); @@ -97,7 +98,7 @@ var defaultOpt = require('../common/query-param');
97 skns: $('.popularity-title').data('skns'), 98 skns: $('.popularity-title').data('skns'),
98 }, 99 },
99 success: function(data) { 100 success: function(data) {
100 - $('.product-warp>.goods-container').html(data) 101 + $('.product-warp>.goods-container').html(data);
101 }, 102 },
102 error: function() { 103 error: function() {
103 tip.show('网络断开连接了~'); 104 tip.show('网络断开连接了~');
@@ -128,8 +129,8 @@ var defaultOpt = require('../common/query-param'); @@ -128,8 +129,8 @@ var defaultOpt = require('../common/query-param');
128 }); 129 });
129 } 130 }
130 }); 131 });
131 - }, 0)  
132 - 132 + }, 0);
  133 +
133 }()); 134 }());
134 135
135 136
@@ -237,6 +238,7 @@ function getPageGoods(info) { @@ -237,6 +238,7 @@ function getPageGoods(info) {
237 238
238 navType = info.data.type; 239 navType = info.data.type;
239 nav = navInfo[navType]; 240 nav = navInfo[navType];
  241 +
240 // 不需要重新加载并且数据请求结束 242 // 不需要重新加载并且数据请求结束
241 if (nav.end && toTop) { 243 if (nav.end && toTop) {
242 toTop = false; 244 toTop = false;
@@ -296,6 +298,7 @@ function newData(callback) { @@ -296,6 +298,7 @@ function newData(callback) {
296 callback && $.isFunction(callback) && callback(); 298 callback && $.isFunction(callback) && callback();
297 }; 299 };
298 var result = getPageGoods(req); 300 var result = getPageGoods(req);
  301 +
299 if (!result) { 302 if (!result) {
300 callback && callback(); 303 callback && callback();
301 } 304 }
@@ -324,6 +327,7 @@ function hotData(callback) { @@ -324,6 +327,7 @@ function hotData(callback) {
324 callback && $.isFunction(callback) && callback(); 327 callback && $.isFunction(callback) && callback();
325 }; 328 };
326 var result = getPageGoods(req); 329 var result = getPageGoods(req);
  330 +
327 if (!result) { 331 if (!result) {
328 callback && callback(); 332 callback && callback();
329 } 333 }
@@ -340,8 +344,9 @@ function tabChange(dom, index) { @@ -340,8 +344,9 @@ function tabChange(dom, index) {
340 // 首页导航 344 // 首页导航
341 (function(nav, posNav, main) { 345 (function(nav, posNav, main) {
342 var scrollToNav1 = function() { 346 var scrollToNav1 = function() {
343 - window.scrollTo(0, $('#nav').offset().top + 5)  
344 - } 347 + window.scrollTo(0, $('#nav').offset().top + 5);
  348 + };
  349 +
345 $(nav + ' li, ' + posNav + ' li').not('li.all-goods').on('touchstart', function() { 350 $(nav + ' li, ' + posNav + ' li').not('li.all-goods').on('touchstart', function() {
346 var index = $(this).index(), 351 var index = $(this).index(),
347 activeTab = $(this).attr('tab'); 352 activeTab = $(this).attr('tab');
@@ -384,7 +389,9 @@ function scrollHandler() { @@ -384,7 +389,9 @@ function scrollHandler() {
384 nav2OffsetTop = $('#list-nav').length ? $('#list-nav').offset().top : 0; 389 nav2OffsetTop = $('#list-nav').length ? $('#list-nav').offset().top : 0;
385 390
386 var tra; 391 var tra;
387 - //分页加载店铺商品列表 392 +
  393 + // 分页加载店铺商品列表
  394 +
388 if (sTop > scH - winH * 2 && viewType === 1) { 395 if (sTop > scH - winH * 2 && viewType === 1) {
389 if ($pre !== undefined) { 396 if ($pre !== undefined) {
390 search({ 397 search({
@@ -397,7 +404,7 @@ function scrollHandler() { @@ -397,7 +404,7 @@ function scrollHandler() {
397 } 404 }
398 } 405 }
399 406
400 - //分页加载“上新”和“人气”商品数据 407 + // 分页加载“上新”和“人气”商品数据
401 if (sTop + winH * 2 > scH) { 408 if (sTop + winH * 2 > scH) {
402 switch (viewType) { 409 switch (viewType) {
403 case 2: 410 case 2:
@@ -427,7 +434,7 @@ function scrollHandler() { @@ -427,7 +434,7 @@ function scrollHandler() {
427 document.addEventListener('touchmove', function(e) { 434 document.addEventListener('touchmove', function(e) {
428 // sub classify不阻止默认事件 435 // sub classify不阻止默认事件
429 if ($(e.target).closest('.sub-classify').length === 0) { 436 if ($(e.target).closest('.sub-classify').length === 0) {
430 - //e.preventDefault(); 437 + // e.preventDefault();
431 } 438 }
432 if ($('.filter-mask').length && !$('.filter-mask').hasClass('hide')) { 439 if ($('.filter-mask').length && !$('.filter-mask').hasClass('hide')) {
433 e.preventDefault(); 440 e.preventDefault();
@@ -453,7 +460,7 @@ $(window).ready(function() { @@ -453,7 +460,7 @@ $(window).ready(function() {
453 scH = $('#scroller').outerHeight(); 460 scH = $('#scroller').outerHeight();
454 }, 500); 461 }, 500);
455 462
456 - $(document).scroll(scrollHandler) 463 + $(document).scroll(scrollHandler);
457 lazyLoad($('img.lazy')); 464 lazyLoad($('img.lazy'));
458 }); 465 });
459 466
@@ -723,18 +730,19 @@ $newList.on('touchstart', 'li', function(e) { @@ -723,18 +730,19 @@ $newList.on('touchstart', 'li', function(e) {
723 } 730 }
724 $pre = $('.first-li-more'); 731 $pre = $('.first-li-more');
725 var nav = navInfo[navType]; 732 var nav = navInfo[navType];
  733 +
726 if (nav.reload) { 734 if (nav.reload) {
727 search({ 735 search({
728 - type: 'shop_id',  
729 - id: shopId,  
730 - brand: brand,  
731 - appVersion: appVersion,  
732 - url: '/product/search/search',  
733 - nextPage: false  
734 - }, function() {  
735 - }); 736 + type: 'shop_id',
  737 + id: shopId,
  738 + brand: brand,
  739 + appVersion: appVersion,
  740 + url: '/product/search/search',
  741 + nextPage: false
  742 + }, function() {
  743 + });
736 } 744 }
737 - 745 +
738 }); 746 });
739 747
740 $(document).on('touchstart', function(e) { 748 $(document).on('touchstart', function(e) {
@@ -745,7 +753,7 @@ $(document).on('touchstart', function(e) { @@ -745,7 +753,7 @@ $(document).on('touchstart', function(e) {
745 } 753 }
746 }); 754 });
747 function subNavScrollTo() { 755 function subNavScrollTo() {
748 - window.scrollTo(0, $('#list-nav').offset().top + 5) 756 + window.scrollTo(0, $('#list-nav').offset().top + 5);
749 } 757 }
750 $subNav.on('touchend touchcancel', function(e) { 758 $subNav.on('touchend touchcancel', function(e) {
751 var $this = $(e.target).closest('li'), 759 var $this = $(e.target).closest('li'),
@@ -775,6 +783,7 @@ $subNav.on('touchend touchcancel', function(e) { @@ -775,6 +783,7 @@ $subNav.on('touchend touchcancel', function(e) {
775 subNavScrollTo(); 783 subNavScrollTo();
776 return true; 784 return true;
777 } 785 }
  786 +
778 // 最新li 列表 787 // 最新li 列表
779 $newList.addClass('hide'); 788 $newList.addClass('hide');
780 789
@@ -815,7 +824,7 @@ $subNav.on('touchend touchcancel', function(e) { @@ -815,7 +824,7 @@ $subNav.on('touchend touchcancel', function(e) {
815 } else if ($this.hasClass('default')) { 824 } else if ($this.hasClass('default')) {
816 cname = '.default'; 825 cname = '.default';
817 navType = 'default'; 826 navType = 'default';
818 - } 827 + }
819 828
820 nav = navInfo[navType]; 829 nav = navInfo[navType];
821 830
@@ -924,7 +933,7 @@ $nav2.on('touchstart', 'li', function(e) { @@ -924,7 +933,7 @@ $nav2.on('touchstart', 'li', function(e) {
924 933
925 $('.shop-foot-wrapper .buriedpoint').click(function() { 934 $('.shop-foot-wrapper .buriedpoint').click(function() {
926 var subGroup = $(this).find('.sub-group'); 935 var subGroup = $(this).find('.sub-group');
927 - 936 +
928 if (subGroup.hasClass('hide')) { 937 if (subGroup.hasClass('hide')) {
929 subGroup.removeClass('hide'); 938 subGroup.removeClass('hide');
930 } else { 939 } else {
@@ -90,7 +90,7 @@ ellipsis.init(); @@ -90,7 +90,7 @@ ellipsis.init();
90 }, 90 },
91 dataType: 'json', 91 dataType: 'json',
92 success: function(data) { 92 success: function(data) {
93 - $('.con').text(data.intro) 93 + $('.con').text(data.intro);
94 if (data.collected) { 94 if (data.collected) {
95 $('.brand-header .btn-col').addClass('coled'); 95 $('.brand-header .btn-col').addClass('coled');
96 } 96 }
@@ -110,7 +110,7 @@ ellipsis.init(); @@ -110,7 +110,7 @@ ellipsis.init();
110 if (data.is_favorite === 'Y') { 110 if (data.is_favorite === 'Y') {
111 $('.brand-header .btn-col').addClass('coled'); 111 $('.brand-header .btn-col').addClass('coled');
112 } 112 }
113 - $('.con').text(data.shop_intro) 113 + $('.con').text(data.shop_intro);
114 }, 114 },
115 error: function() { 115 error: function() {
116 tip.show('网络断开连接了~'); 116 tip.show('网络断开连接了~');
@@ -371,7 +371,7 @@ function search(opt) { @@ -371,7 +371,7 @@ function search(opt) {
371 if (setting.page >= 1) { 371 if (setting.page >= 1) {
372 loading.showLoadingMask(); 372 loading.showLoadingMask();
373 } 373 }
374 - 374 +
375 375
376 $.ajax({ 376 $.ajax({
377 type: 'GET', 377 type: 'GET',
@@ -413,9 +413,11 @@ function search(opt) { @@ -413,9 +413,11 @@ function search(opt) {
413 goodList.push(goodInfo); 413 goodList.push(goodInfo);
414 } 414 }
415 }); 415 });
  416 +
416 if (first_load) { 417 if (first_load) {
417 first_load = false; 418 first_load = false;
418 - //移除头四个 419 +
  420 + // 移除头四个
419 goodList.splice(0, 4); 421 goodList.splice(0, 4);
420 $container.append(goodList); 422 $container.append(goodList);
421 } else { 423 } else {
@@ -580,10 +582,11 @@ $newList.on('touchstart', 'li', function(e) { @@ -580,10 +582,11 @@ $newList.on('touchstart', 'li', function(e) {
580 } 582 }
581 $pre = $('.first-li-more'); 583 $pre = $('.first-li-more');
582 var nav = navInfo[navType]; 584 var nav = navInfo[navType];
  585 +
583 if (nav.reload) { 586 if (nav.reload) {
584 search(); 587 search();
585 } 588 }
586 - 589 +
587 }); 590 });
588 591
589 $(document).on('touchstart', function(e) { 592 $(document).on('touchstart', function(e) {
@@ -613,6 +616,7 @@ $listNav.on('touchend touchcancel', function(e) { @@ -613,6 +616,7 @@ $listNav.on('touchend touchcancel', function(e) {
613 newListHide(); 616 newListHide();
614 return true; 617 return true;
615 } 618 }
  619 +
616 // 最新li 列表 620 // 最新li 列表
617 $newList.addClass('hide'); 621 $newList.addClass('hide');
618 622
@@ -643,7 +647,7 @@ $listNav.on('touchend touchcancel', function(e) { @@ -643,7 +647,7 @@ $listNav.on('touchend touchcancel', function(e) {
643 navType = 'discount'; 647 navType = 'discount';
644 } else if ($pre.hasClass('default')) { 648 } else if ($pre.hasClass('default')) {
645 navType = 'default'; 649 navType = 'default';
646 - } 650 + }
647 651
648 nav = navInfo[navType]; 652 nav = navInfo[navType];
649 653