Authored by 陈峰

rss路由配置

@@ -55,7 +55,9 @@ router.get('/plustar/brandinfo', plustar.getDetailData); // 祕 @@ -55,7 +55,9 @@ router.get('/plustar/brandinfo', plustar.getDetailData); // 祕
55 router.post('/plustar/brandinfoAsync', plustar.getDetailDataAsync); // 国际优选详情页异步数据 55 router.post('/plustar/brandinfoAsync', plustar.getDetailDataAsync); // 国际优选详情页异步数据
56 56
57 router.get('/rss/new', rss.rss); // 订阅资讯 57 router.get('/rss/new', rss.rss); // 订阅资讯
58 -router.get('/rss/new-gmt', (req, res, next) => rss.rss(req, res, next, 'gmt')); // 订阅资讯 58 +router.get('/rss/new-gmt', (req, res, next) => {
  59 + rss.rss(req, res, next, 'gmt')
  60 +}); // 订阅资讯
59 router.get(/^\/rss(\/\w+)?(\/\w+)?/, rss.index); // 订阅资讯 61 router.get(/^\/rss(\/\w+)?(\/\w+)?/, rss.index); // 订阅资讯
60 62
61 router.get('/info/listData', index.listDynamicData); 63 router.get('/info/listData', index.listDynamicData);
  1 +/**
  2 + * 品牌店铺首页
  3 + */
  4 +
  5 +var $ = require('yoho-jquery'),
  6 + IScroll = require('yoho-iscroll/build/iscroll-probe'),
  7 + lazyLoad = require('yoho-jquery-lazyload'),
  8 + Swiper = require('yoho-swiper');
  9 +var bannerSwiper,
  10 + multiSwiper,
  11 + myScroll,
  12 + imgH,
  13 + nav1H,
  14 + main1H,
  15 + main1oH,
  16 + nav2H,
  17 + main2oH,
  18 + scH,
  19 + $nav1 = $('#pos-nav'),
  20 + $nav2 = $('#pos-list'),
  21 + sTop,
  22 + toTop = false;
  23 +
  24 +var tip = require('../plugin/tip'),
  25 + filter = require('../plugin/filter'),
  26 + loading = require('../plugin/loading');
  27 +
  28 +var $subNav = $('.home-sub-nav'),
  29 + $collect = $('#collect'),
  30 + $goodsContainer = $('#goods-container'),
  31 + $goodsChildren = $goodsContainer.children(),
  32 + $ngc = $($goodsChildren.get(0)),
  33 + $pgc = $($goodsChildren.get(1)),
  34 + $dgc = $($goodsChildren.get(2)),
  35 + shopId = $('input[name="shop_id"]').val(),
  36 + appVersion = $('input[name="app_version"]').val(),
  37 + brand = $('input[name="brand"]').val(),
  38 + coverChannel = $('input[name="coverChannel"]').val(),
  39 + favId = $('input[name="favId"]').val(),
  40 + uid = $('input[name="uid"]').val();
  41 +
  42 +var winH = $(window).height(),
  43 + noResult = '<p class="no-result">未找到相关搜索结果</p>';
  44 +
  45 +require('../common');
  46 +// 默认筛选条件
  47 +var defaultOpt = require('../common/query-param');
  48 +
  49 +// pagecache判断app设置cookie,判断是否收藏
  50 +(function() {
  51 + var param = location.search;
  52 + var isApp = param.indexOf('app_version') > -1 || param.indexOf('appVersion') > -1;
  53 +
  54 + //不阻塞字体文件加载
  55 + setTimeout(function() {
  56 + if (isApp) {
  57 + $.ajax({
  58 + type: 'GET',
  59 + url: '/product/index/shopAppCookie',
  60 + xhrFields: {
  61 + withCredentials: true
  62 + },
  63 + error: function() {
  64 + tip.show('网络断开连接了~');
  65 + }
  66 + });
  67 + }
  68 +
  69 + $.ajax({
  70 + type: 'GET',
  71 + url: '/product/index/shopFav',
  72 + xhrFields: {
  73 + withCredentials: true
  74 + },
  75 + data: {
  76 + shopId: $('.shopid').val(),
  77 + },
  78 + success: function(data) {
  79 + if (data.collect) {
  80 + $collect.attr('class', 'already-collect');
  81 + }
  82 + },
  83 + error: function() {
  84 + tip.show('网络断开连接了~');
  85 + }
  86 + });
  87 + if ($('.popularity-title').data('skns')) {
  88 + $.ajax({
  89 + type: 'GET',
  90 + url: '/product/new/shop/hotlist',
  91 + xhrFields: {
  92 + withCredentials: true
  93 + },
  94 + data: {
  95 + skns: $('.popularity-title').data('skns'),
  96 + },
  97 + success: function(data) {
  98 + $('.product-warp>.goods-container').html(data)
  99 + },
  100 + error: function() {
  101 + tip.show('网络断开连接了~');
  102 + }
  103 + });
  104 + }
  105 + $.ajax({
  106 + type: 'GET',
  107 + url: '/product/search/filter',
  108 + data: {
  109 + shop_id: $('.shopid').val(),
  110 + type: 'default',
  111 + order: '0',
  112 + channel: defaultOpt.channel
  113 + },
  114 + success: function(data) {
  115 + $goodsContainer.append(data);
  116 +
  117 + // 初始化filter&注册filter回调
  118 + filter.initFilter({
  119 + fCbFn: search,
  120 + hCbFn: function() {
  121 +
  122 + // 切换active状态到$pre上
  123 + $pre.addClass('active');
  124 + $pre.siblings('.filter').removeClass('active');
  125 + }
  126 + });
  127 + }
  128 + });
  129 + }, 0)
  130 +
  131 +}());
  132 +
  133 +
  134 +var $listNav = $('#list-nav'),
  135 +
  136 + // 导航数据信息
  137 + navInfo = {
  138 + new: {
  139 + order: 1,
  140 + reload: true,
  141 + page: 1,
  142 + end: false
  143 + },
  144 + hot: {
  145 + order: 1,
  146 + reload: true,
  147 + page: 1,
  148 + end: false
  149 + },
  150 + newest: {
  151 + order: 0,
  152 + reload: true,
  153 + page: 0,
  154 + end: false
  155 + },
  156 + price: {
  157 + order: 1,
  158 + reload: true,
  159 + page: 0,
  160 + end: false
  161 + },
  162 + discount: {
  163 + order: 1,
  164 + reload: true,
  165 + page: 0,
  166 + end: false
  167 + }
  168 + },
  169 + $pre = $listNav.find('.active'), // 纪录进入筛选前的active项,初始为选中项
  170 + searching;
  171 +
  172 +var viewType = 1, // 1-首页,2-上新,3-人气
  173 + listCount = $('.category-list li').length,
  174 + listModValue = 4 - listCount % 4,
  175 + listIndex;
  176 +
  177 +
  178 +// $('.main-wrap').css({
  179 +// position: 'static'
  180 +// });
  181 +
  182 +// 焦点效果
  183 +if ($('.banner-swiper').find('li').size() > 1) {
  184 + bannerSwiper = new Swiper('.banner-swiper', {
  185 + lazyLoading: true,
  186 + lazyLoadingInPrevNext: true,
  187 + loop: true,
  188 + autoplay: 3000,
  189 + autoplayDisableOnInteraction: false,
  190 + paginationClickable: true,
  191 + slideElement: 'li',
  192 + pagination: '.banner-top .pagination-inner'
  193 + });
  194 +}
  195 +
  196 +if ($('.multi-browse').find('li').size() > 1) {
  197 + multiSwiper = new Swiper('.multi-browse', {
  198 + lazyLoading: true,
  199 + lazyLoadingInPrevNext: true,
  200 + lazyLoadingOnTransitionStart: true,
  201 + grabCursor: true,
  202 + slidesPerView: 'auto',
  203 + slideElement: 'li',
  204 + watchSlidesVisibility: true
  205 + });
  206 +}
  207 +
  208 +// 根据热门品类的个数来改变样式展示
  209 +//
  210 +if ($('.category-list li').length % 4 !== 0) {
  211 + $('.category-list li:last-child').addClass('category-list-last-li');
  212 +}
  213 +
  214 +if ($('.category-list li').length < 4) {
  215 + $('.category-list').addClass('category-list-top-board');
  216 + $('.category-list').find('.buriedpoint').addClass('category-list-only-one-row');
  217 +} else if ($('.category-list li').length >= 5) {
  218 + for (listIndex = listModValue; listIndex >= 0; listIndex--) {
  219 + $('.category-list li').eq(listCount - 4 + listIndex - 1).addClass('category-list-last-full-row');
  220 + }
  221 +}
  222 +
  223 +function getPageGoods(info) {
  224 + var nav, navType;
  225 +
  226 + if (searching) {
  227 + return;
  228 + }
  229 +
  230 + navType = info.data.type;
  231 + nav = navInfo[navType];
  232 + // 不需要重新加载并且数据请求结束
  233 + if (nav.end && toTop) {
  234 + toTop = false;
  235 + return;
  236 + }
  237 +
  238 + if (info.data && coverChannel) {
  239 + info.data.coverChannel = coverChannel;
  240 + }
  241 +
  242 + searching = true;
  243 + $.ajax({
  244 + type: 'GET',
  245 + url: info.url,
  246 + data: info.data,
  247 + success: function(data) {
  248 + nav.end = true;
  249 + info.callBack(data);
  250 + },
  251 + error: function() {
  252 + tip.show('网络断开连接了~');
  253 + searching = false;
  254 + }
  255 + });
  256 +}
  257 +
  258 +function getParam(req) {
  259 + if (brand) {
  260 + req.data.brand = brand;
  261 + }
  262 +
  263 + if (shopId) {
  264 + req.data.shop_id = shopId;
  265 + }
  266 +}
  267 +
  268 +function newData(callback) {
  269 + var req = {};
  270 +
  271 + req.url = '/product/search/search';
  272 + req.data = {
  273 + type: 'new',
  274 + order: '0',
  275 + page: navInfo.new.page,
  276 + tagNew: '1',
  277 + appVersion: appVersion
  278 + };
  279 +
  280 + getParam(req);
  281 +
  282 + req.callBack = function(data) {
  283 + $('#new-arrival').append(data);
  284 + navInfo.new.page++;
  285 + lazyLoad($('#new-arrival .lazy'));
  286 + scH = $('#scroller').outerHeight();
  287 + searching = false;
  288 + callback && $.isFunction(callback) && callback();
  289 + };
  290 + var result = getPageGoods(req);
  291 + if (!result) {
  292 + callback && callback();
  293 + }
  294 +}
  295 +
  296 +function hotData(callback) {
  297 + var req = {};
  298 +
  299 + req.url = '/product/search/search';
  300 + req.data = {
  301 + type: 'hot',
  302 + order: '1',
  303 + page: navInfo.hot.page,
  304 + showTag: '1',
  305 + appVersion: appVersion
  306 + };
  307 +
  308 + getParam(req);
  309 +
  310 + req.callBack = function(data) {
  311 + $('#popularity').append(data);
  312 + navInfo.hot.page++;
  313 + lazyLoad($('#popularity .lazy'));
  314 + scH = $('#scroller').outerHeight();
  315 + searching = false;
  316 + callback && $.isFunction(callback) && callback();
  317 + };
  318 + var result = getPageGoods(req);
  319 + if (!result) {
  320 + callback && callback();
  321 + }
  322 +}
  323 +
  324 +function tabChange(dom, index) {
  325 + var li = dom.eq(index);
  326 +
  327 + dom.removeClass('active color');
  328 + li.addClass('active color');
  329 +}
  330 +
  331 +
  332 +// 首页导航
  333 +(function(nav, posNav, main) {
  334 + var scrollToNav1 = function() {
  335 + window.scrollTo(0, $('#nav').offset().top + 5)
  336 + }
  337 + $(nav + ' li, ' + posNav + ' li').not('li.all-goods').on('touchstart', function() {
  338 + var index = $(this).index(),
  339 + activeTab = $(this).attr('tab');
  340 +
  341 + if ($('.filter-mask').length && !$('.filter-mask').hasClass('hide')) {
  342 + return;
  343 + }
  344 +
  345 + $nav1.removeClass('fixed-top');
  346 + tabChange($(nav + ' li'), index);
  347 + tabChange($(posNav + ' li'), index);
  348 + $(main).hide();
  349 + $('#' + activeTab).fadeIn();
  350 + if (activeTab === 'new-arrival') {
  351 + toTop = true;
  352 + newData(scrollToNav1);
  353 + viewType = 2;
  354 + } else if (activeTab === 'popularity') {
  355 + toTop = true;
  356 + hotData(scrollToNav1);
  357 + viewType = 3;
  358 + } else if (activeTab === 'home-page') {
  359 + $nav1.removeClass('fixed-top absolute');
  360 + $nav2.removeClass('fixed-top absolute');
  361 + viewType = 1;
  362 + scrollToNav1();
  363 + }
  364 + scH = $('#scroller').outerHeight();
  365 + });
  366 +}('#nav', '#pos-nav', '.main'));
  367 +
  368 +
  369 +
  370 +
  371 +function scrollHandler() {
  372 + var scrollCall,
  373 + sTop = $(document).scrollTop(),
  374 + scH = $('#scroller').outerHeight(),
  375 + nav1OffsetTop = $('#nav').length ? $('#nav').offset().top : 0,
  376 + nav2OffsetTop = $('#list-nav').length ? $('#list-nav').offset().top : 0;
  377 +
  378 + var tra;
  379 + //分页加载店铺商品列表
  380 + if (sTop + winH > scH - 0.25 * $goodsContainer.height() - 50) {
  381 + if ($pre !== undefined) {
  382 + search({
  383 + type: 'shop_id',
  384 + id: shopId,
  385 + brand: brand,
  386 + url: '/product/search/search',
  387 + nextPage: true
  388 + });
  389 + }
  390 + }
  391 +
  392 + //分页加载“上新”和“人气”商品数据
  393 + if (sTop + winH * 2 > scH) {
  394 + switch (viewType) {
  395 + case 2:
  396 + newData();
  397 + break;
  398 + case 3:
  399 + hotData();
  400 + break;
  401 + }
  402 + }
  403 +
  404 + if (sTop > nav2OffsetTop && $('#list-nav').length) {
  405 + if ($('#home-page').is(':hidden')) {
  406 + return false;
  407 + }
  408 + $nav2.removeClass('hide');
  409 + $nav1.addClass('hide');
  410 + } else if (sTop > nav1OffsetTop && $('#nav').length) {
  411 + $nav1.removeClass('hide');
  412 + $nav2.addClass('hide');
  413 + } else {
  414 + $nav1.addClass('hide');
  415 + $nav2.addClass('hide');
  416 + }
  417 +}
  418 +
  419 +document.addEventListener('touchmove', function(e) {
  420 + // sub classify不阻止默认事件
  421 + if ($(e.target).closest('.sub-classify').length === 0) {
  422 + //e.preventDefault();
  423 + }
  424 + if ($('.filter-mask').length && !$('.filter-mask').hasClass('hide')) {
  425 + e.preventDefault();
  426 + }
  427 +}, false);
  428 +
  429 +/* if (!isIphone) {
  430 + return;
  431 + }*/
  432 +
  433 +
  434 +// window ready 后重新refresh iscroll
  435 +$(window).ready(function() {
  436 + // myScroll && myScroll.refresh();
  437 + imgH = $('#nav-top').outerHeight();
  438 + nav1H = $('#nav').outerHeight();
  439 + main1H = $('#nav-main').height();
  440 + main1oH = $('#nav-main').outerHeight(true);
  441 + nav2H = $('#list-nav').outerHeight(true);
  442 + main2oH = $('#goods-container').outerHeight(true);
  443 +
  444 + setTimeout(function() {
  445 + scH = $('#scroller').outerHeight();
  446 + }, 500);
  447 +
  448 + $(document).scroll(scrollHandler)
  449 + lazyLoad($('img.lazy'));
  450 +});
  451 +
  452 +function bindGoodThumbClick() {
  453 + $(document).trigger('rebindBpEvent');
  454 +}
  455 +
  456 +function search(opt, callback) {
  457 + var setting = {},
  458 + ext,
  459 + att,
  460 + nav, navType,
  461 + page;
  462 +
  463 + if (searching) {
  464 + return;
  465 + }
  466 +
  467 + if (!opt.url) {
  468 + opt.url = '/product/search/search';
  469 + }
  470 +
  471 + $pre = $listNav.find('.active').eq(0);
  472 +
  473 + if (!opt.nextPage) {
  474 +
  475 + // 筛选项变更则重置reload为true
  476 + for (att in navInfo) {
  477 + if (navInfo.hasOwnProperty(att)) {
  478 + navInfo[att].reload = true;
  479 + }
  480 + }
  481 +
  482 + $listNav.children('.active').removeClass('active');
  483 + $pre.addClass('active');
  484 + if (opt.hasOwnProperty('id')) {
  485 + switch (opt.type) {
  486 + case 'shop_id':
  487 + ext = {
  488 + shop_id: opt.id
  489 + };
  490 + break;
  491 + case 'gender':
  492 + ext = {
  493 + gender: opt.id
  494 + };
  495 +
  496 + ext.coverChannel = opt.id;
  497 + break;
  498 + case 'brand':
  499 + ext = {
  500 + brand: opt.id
  501 + };
  502 + break;
  503 + case 'sort':
  504 + ext = {
  505 + sort: opt.id
  506 + };
  507 + break;
  508 + case 'color':
  509 + ext = {
  510 + color: opt.id
  511 + };
  512 + break;
  513 + case 'size':
  514 + ext = {
  515 + size: opt.id
  516 + };
  517 + break;
  518 + case 'price':
  519 + ext = {
  520 + price: opt.id
  521 + };
  522 + break;
  523 + case 'discount':
  524 + ext = {
  525 + discount: opt.id
  526 + };
  527 + break;
  528 + case 'ageLevel':
  529 + ext = {
  530 + age_level: opt.id
  531 + };
  532 + break;
  533 + default:
  534 + break;
  535 + }
  536 + $.extend(defaultOpt, ext); // 扩展筛选项
  537 + }
  538 + }
  539 +
  540 + // 导航类别
  541 + if ($pre.hasClass('new')) {
  542 + navType = 'newest';
  543 + } else if ($pre.hasClass('price')) {
  544 + navType = 'price';
  545 + } else if ($pre.hasClass('discount')) {
  546 + navType = 'discount';
  547 + }
  548 + nav = navInfo[navType];
  549 +
  550 + page = nav.page + 1;
  551 + if (nav.reload) {
  552 + page = 1;
  553 + } else if (nav.end) {
  554 +
  555 + // 不需要重新加载并且数据请求结束
  556 + return;
  557 + }
  558 +
  559 + // 封面图,defaultOpt对象也有可能包含coverChannel,但defaultOpt优先级高
  560 + if (coverChannel) {
  561 + setting.coverChannel = coverChannel;
  562 + }
  563 +
  564 + $.extend(setting, defaultOpt, {
  565 + type: navType,
  566 + order: nav.order,
  567 + page: page,
  568 + appVersion: appVersion
  569 + });
  570 +
  571 + if (brand) {
  572 + setting.brand = brand;
  573 + }
  574 + if (shopId) {
  575 + setting.shop_id = shopId;
  576 + }
  577 +
  578 + searching = true;
  579 + loading.showLoadingMask();
  580 +
  581 + $.ajax({
  582 + type: 'GET',
  583 + url: opt.url ? opt.url : '',
  584 + data: setting,
  585 + success: function(data) {
  586 + var $container,
  587 + num;
  588 +
  589 + switch (navType) {
  590 + case 'newest':
  591 + $container = $ngc;
  592 + break;
  593 + case 'price':
  594 + $container = $pgc;
  595 + break;
  596 + case 'discount':
  597 + $container = $dgc;
  598 + break;
  599 + default:
  600 + break;
  601 + }
  602 +
  603 + if (data === '') {
  604 + nav.end = true;
  605 +
  606 + if (nav.reload) {
  607 + $container.html(noResult);
  608 + }
  609 + } else {
  610 + if (nav.reload) {
  611 + $container.html(data);
  612 + lazyLoad($container.find('.lazy'));
  613 + } else {
  614 + num = $container.find('.good-info').length;
  615 + $container.append(data);
  616 + lazyLoad($container.find('.good-info:gt(' + (num - 1) + ') .lazy'));
  617 + }
  618 + }
  619 +
  620 + scH = $('#scroller').outerHeight();
  621 +
  622 + nav.reload = false;
  623 + nav.page = page;
  624 +
  625 + searching = false;
  626 + loading.hideLoadingMask();
  627 +
  628 + window.rePosFooter();
  629 +
  630 + // myScroll && myScroll.refresh();
  631 + // reNav1Pos();
  632 +
  633 + bindGoodThumbClick();
  634 + callback && callback();
  635 + },
  636 + error: function() {
  637 + tip.show('网络断开连接了~');
  638 + searching = false;
  639 + loading.hideLoadingMask();
  640 + callback && callback();
  641 + }
  642 + });
  643 +}
  644 +
  645 +
  646 +$listNav.bind('contextmenu', function(e) {
  647 + return false;
  648 +});
  649 +
  650 +$subNav.on('touchend touchcancel', function(e) {
  651 + var $this = $(e.target).closest('li'),
  652 + cname,
  653 + nav,
  654 + navType,
  655 + $active;
  656 + var bpIdData = $this.attr('data-bp-id') || '';
  657 +
  658 + e.preventDefault();
  659 + $(document).trigger('shouldSendBpData', [bpIdData]);
  660 +
  661 + if (typeof $this === 'undefined' || $this.length === 0) {
  662 + return;
  663 + }
  664 +
  665 + if ($this.hasClass('filter')) {
  666 +
  667 + // 筛选面板切换状态
  668 + if ($this.hasClass('active') && !$('.filter-mask').hasClass('hide')) {
  669 + $('.home-sub-nav>li.filter').removeClass('active');
  670 + $this.removeClass('active');
  671 + filter.hideFilter();
  672 + } else {
  673 + $('.home-sub-nav>li.filter').addClass('active');
  674 + $this.addClass('active');
  675 +
  676 + filter.showFilter();
  677 +
  678 + if ($this.closest('.pos-list').length > 0) {
  679 + $('.filter-mask').addClass('call-by-fix').css('top', '');
  680 + } else {
  681 + $('.filter-mask').removeClass('call-by-fix').css('top', $this.offset().top + nav1H);
  682 + }
  683 +
  684 + }
  685 + window.scrollTo(0, $('#list-nav').offset().top + 5)
  686 + } else {
  687 +
  688 + filter.hideFilter();// 隐藏面板
  689 +
  690 + if ($this.hasClass('new')) {
  691 + cname = '.new';
  692 + navType = 'newest';
  693 + } else if ($this.hasClass('price')) {
  694 + cname = '.price';
  695 + navType = 'price';
  696 + } else if ($this.hasClass('discount')) {
  697 + cname = '.discount';
  698 + navType = 'discount';
  699 + }
  700 +
  701 + nav = navInfo[navType];
  702 +
  703 + if ($this.hasClass('active')) {
  704 +
  705 + // 最新无排序切换
  706 + if ($this.hasClass('new')) {
  707 + return;
  708 + }
  709 +
  710 + if ($this.hasClass('price') || $this.hasClass('discount')) {
  711 + $this = $subNav.find(cname);
  712 +
  713 + // 价格/折扣切换排序状态
  714 + $this.find('.icon > .iconfont').toggleClass('cur');
  715 + nav.reload = true; // 重置reload,HTML会被替换为逆序的HTML
  716 + nav.order = nav.order === 0 ? 1 : 0; // 切换排序
  717 +
  718 + $goodsContainer.children('.container:not(.hide)').addClass('hide');
  719 +
  720 + switch (navType) {
  721 + case 'newest':
  722 + $ngc.removeClass('hide');
  723 + break;
  724 +
  725 + case 'price':
  726 + $pgc.removeClass('hide');
  727 + break;
  728 +
  729 + case 'discount':
  730 + $dgc.removeClass('hide');
  731 + break;
  732 + default:
  733 + break;
  734 + }
  735 +
  736 + }
  737 + } else {
  738 + $active = $subNav.find('.active');
  739 +
  740 + if ($active.hasClass('filter')) {
  741 +
  742 + // 若之前active项为筛选,则隐藏筛选面板
  743 + filter.hideFilter();
  744 + } else {
  745 +
  746 + // 切换container显示
  747 + $goodsContainer.children('.container:not(.hide)').addClass('hide');
  748 +
  749 + switch (navType) {
  750 + case 'newest':
  751 + $ngc.removeClass('hide');
  752 + break;
  753 +
  754 + case 'price':
  755 + $pgc.removeClass('hide');
  756 + break;
  757 +
  758 + case 'discount':
  759 + $dgc.removeClass('hide');
  760 + break;
  761 + default:
  762 + break;
  763 + }
  764 + }
  765 +
  766 + $subNav.children().removeClass('active');
  767 + $subNav.find(cname).addClass('active');
  768 + }
  769 +
  770 + if (nav.reload) {
  771 + search({
  772 + type: 'shop_id',
  773 + id: shopId,
  774 + brand: brand,
  775 + appVersion: appVersion,
  776 + url: '/product/search/search',
  777 + nextPage: false
  778 + }, function() {
  779 + window.scrollTo(0, $('#list-nav').offset().top + 5)
  780 + });
  781 + }
  782 + }
  783 + e.stopPropagation();
  784 +});
  785 +
  786 +
  787 +$listNav.on('touchstart', 'li', function(e) {
  788 + $(this).addClass('bytouch');
  789 +}).on('touchend touchcancel', function() {
  790 + $listNav.find('li').removeClass('bytouch');
  791 +
  792 +});
  793 +
  794 +$nav2.on('touchstart', 'li', function(e) {
  795 + $(this).addClass('bytouch');
  796 +}).on('touchend touchcancel', function() {
  797 + $nav2.find('li').removeClass('bytouch');
  798 +});
  799 +
  800 +$('.shop-foot-wrapper .buriedpoint').click(function() {
  801 + var subGroup = $(this).find('.sub-group');
  802 +
  803 + if (subGroup.hasClass('hide')) {
  804 + subGroup.removeClass('hide');
  805 + } else {
  806 + subGroup.addClass('hide');
  807 + }
  808 +});
  809 +
  810 +// 店铺收藏 || 取消收藏
  811 +$collect.on('touchstart', function() {
  812 + var opt;
  813 +
  814 + if (searching) {
  815 + return;
  816 + }
  817 + searching = true;
  818 +
  819 + if ($collect.hasClass('already-collect')) {
  820 + opt = 'cancel';
  821 + } else {
  822 + opt = 'ok';
  823 + }
  824 +
  825 + $.ajax({
  826 + method: 'get',
  827 + url: '' + '/product/opt/favoriteBrand',
  828 + data: {
  829 + id: favId ? favId : shopId,
  830 + appVersion: appVersion,
  831 + opt: opt,
  832 + type: 'shop',
  833 + uid: uid
  834 + },
  835 + xhrFields: {
  836 + withCredentials: true
  837 + },
  838 + success: function(data) {
  839 + var url = '';
  840 +
  841 + if (data.code === 200) {
  842 + if ($collect.hasClass('already-collect')) {
  843 + $collect.attr('class', 'not-collect');
  844 + tip.show('店铺取消收藏成功');
  845 + } else {
  846 + $collect.attr('class', 'already-collect');
  847 + tip.show('店铺收藏成功');
  848 + }
  849 + }
  850 +
  851 + if (data.code === 400) {
  852 + url = data.data;
  853 + if ($('#jump-login').length <= 0) {
  854 + $('body').append('<a href=\'' + url + '\'><span id="jump-login"><span></a>');
  855 + }
  856 + $('#jump-login').click();
  857 + }
  858 +
  859 + setTimeout(function() {
  860 + myScroll && myScroll.refresh();
  861 + scH = $('#scroller').outerHeight();
  862 + }, 500);
  863 + searching = false;
  864 + },
  865 + error: function() {
  866 + tip.show('网络断开连接了~');
  867 + searching = false;
  868 + }
  869 + });
  870 +});