...
|
...
|
@@ -9,7 +9,6 @@ var $ = require('yoho-jquery'), |
|
|
// Handlebars = require('yoho-handlebars');
|
|
|
|
|
|
var searching,
|
|
|
$collect = $('.collect-btn'),
|
|
|
shopId,
|
|
|
navSwiper,
|
|
|
stoping;
|
...
|
...
|
@@ -17,125 +16,145 @@ var searching, |
|
|
var shopNav = require('template/shopCollect/shop-nav.hbs'),
|
|
|
shopList = require('template/shopCollect/shop-list.hbs');
|
|
|
|
|
|
var navString = shopNav({
|
|
|
navList: [
|
|
|
{
|
|
|
navName: '欧美',
|
|
|
tabName: 'promotion'
|
|
|
},
|
|
|
{
|
|
|
navName: '欧美',
|
|
|
tabName: 'promotion1'
|
|
|
},
|
|
|
{
|
|
|
navName: '推荐',
|
|
|
tabName: 'promotion2'
|
|
|
}
|
|
|
]
|
|
|
});
|
|
|
|
|
|
require('../common');
|
|
|
|
|
|
var navType = window.queryString;
|
|
|
|
|
|
$('.shop-nav').html(navString);
|
|
|
|
|
|
$collect.on('click', function() {
|
|
|
console.log(12);
|
|
|
var opt,
|
|
|
$this = $(this);
|
|
|
require('../common');
|
|
|
|
|
|
shopId = $this.parents('.shop-info').data('id');
|
|
|
// 店铺列表数据
|
|
|
function shopListData(tabName, stoping) {
|
|
|
|
|
|
if (searching) {
|
|
|
if (stoping) {
|
|
|
return;
|
|
|
}
|
|
|
searching = true;
|
|
|
|
|
|
if ($collect.hasClass('already-collect')) {
|
|
|
opt = 'cancel';
|
|
|
} else {
|
|
|
opt = 'ok';
|
|
|
}
|
|
|
|
|
|
$.ajax({
|
|
|
method: 'get',
|
|
|
url: location.protocol + '//m.yohobuy.com' + '/product/opt/favoriteBrand',
|
|
|
url: '/activity/shopList',
|
|
|
data: {
|
|
|
id: shopId,
|
|
|
opt: opt,
|
|
|
type: 'shop',
|
|
|
},
|
|
|
xhrFields: {
|
|
|
withCredentials: true
|
|
|
tabName: tabName
|
|
|
},
|
|
|
success: function(data) {
|
|
|
|
|
|
if (data.code === 200) {
|
|
|
if ($collect.hasClass('already-collect')) {
|
|
|
$collect.removeClass('already-collect');
|
|
|
tip.show('店铺取消收藏成功');
|
|
|
var list = shopList({
|
|
|
shopList: data
|
|
|
});
|
|
|
|
|
|
$('.shop-list').html(list);
|
|
|
|
|
|
stoping = false;
|
|
|
|
|
|
$('.collect-btn').on('click', function() {
|
|
|
var opt,
|
|
|
$this = $(this);
|
|
|
|
|
|
shopId = $this.parents('.shop-info').data('id');
|
|
|
|
|
|
if (searching) {
|
|
|
return;
|
|
|
}
|
|
|
searching = true;
|
|
|
|
|
|
if ($this.hasClass('already-collect')) {
|
|
|
opt = 'cancel';
|
|
|
} else {
|
|
|
$collect.addClass('already-collect');
|
|
|
tip.show('店铺收藏成功');
|
|
|
opt = 'ok';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (data.code === 400) {
|
|
|
window.location.href = 'http://www.yohobuy.com/passport/login';
|
|
|
}
|
|
|
searching = false;
|
|
|
$.ajax({
|
|
|
method: 'get',
|
|
|
url: location.protocol + '//m.yohobuy.com' + '/product/opt/favoriteBrand',
|
|
|
data: {
|
|
|
id: shopId,
|
|
|
opt: opt,
|
|
|
type: 'shop',
|
|
|
},
|
|
|
xhrFields: {
|
|
|
withCredentials: true
|
|
|
},
|
|
|
success: function(data) {
|
|
|
|
|
|
if (data.code === 200) {
|
|
|
if ($this.hasClass('already-collect')) {
|
|
|
$this.removeClass('already-collect');
|
|
|
tip.show('店铺取消收藏成功');
|
|
|
} else {
|
|
|
$this.addClass('already-collect');
|
|
|
tip.show('店铺收藏成功');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (data.code === 400) {
|
|
|
window.location.href = 'http://www.yohobuy.com/passport/login';
|
|
|
}
|
|
|
searching = false;
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
searching = false;
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
searching = false;
|
|
|
stoping = false;
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function shopListData(tabName, stoping) {
|
|
|
|
|
|
if (stoping) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 导航数据
|
|
|
function shopNavData() {
|
|
|
$.ajax({
|
|
|
method: 'get',
|
|
|
url: '/activity/shopList',
|
|
|
data: {
|
|
|
tabName: tabName
|
|
|
},
|
|
|
url: '/activity/shopNav',
|
|
|
|
|
|
success: function(data) {
|
|
|
|
|
|
var list = shopList({
|
|
|
shopList: data
|
|
|
var navString = shopNav({
|
|
|
navList: data
|
|
|
});
|
|
|
|
|
|
$('.shop-list').html(list);
|
|
|
$('.shop-nav').html(navString);
|
|
|
|
|
|
if (navType.id) {
|
|
|
$('.shop-nav').find('li').each(function() {
|
|
|
if (navType.id === $(this).data('type')) {
|
|
|
$(this).addClass('active');
|
|
|
shopListData($(this).data('type'));
|
|
|
}
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
$('.shop-nav').find('li').eq(0).addClass('active');
|
|
|
shopListData($('.shop-nav').find('li').eq(0).data('type'));
|
|
|
}
|
|
|
|
|
|
$('.shop-nav').find('li').on('click', function() {
|
|
|
var $this = $(this),
|
|
|
tabName = $this.data('type');
|
|
|
|
|
|
if ($this.hasClass('active')) {
|
|
|
stoping = true;
|
|
|
} else {
|
|
|
stoping = false;
|
|
|
}
|
|
|
|
|
|
shopListData(tabName, stoping);
|
|
|
|
|
|
$this.addClass('active').siblings().removeClass('active');
|
|
|
});
|
|
|
|
|
|
stoping = false;
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
stoping = false;
|
|
|
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
$('.shop-nav').find('li').on('click', function() {
|
|
|
var $this = $(this),
|
|
|
tabName = $this.data('type');
|
|
|
|
|
|
if ($this.hasClass('active')) {
|
|
|
stoping = true;
|
|
|
} else {
|
|
|
stoping = false;
|
|
|
}
|
|
|
|
|
|
shopListData(tabName, stoping);
|
|
|
|
|
|
$this.addClass('active').siblings().removeClass('active');
|
|
|
});
|
|
|
|
|
|
$(function() {
|
|
|
navSwiper = new Swiper('.shop-nav', {
|
...
|
...
|
@@ -157,18 +176,5 @@ $(function() { |
|
|
});
|
|
|
}
|
|
|
|
|
|
if (navType.id) {
|
|
|
$('.shop-nav').find('li').each(function() {
|
|
|
if (navType.id === $(this).data('type')) {
|
|
|
$(this).addClass('active');
|
|
|
shopListData($(this).data('type'));
|
|
|
}
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
$('.shop-nav').find('li').eq(0).addClass('active');
|
|
|
shopListData($('.shop-nav').find('li').eq(0).data('type'));
|
|
|
}
|
|
|
|
|
|
|
|
|
shopNavData();
|
|
|
}); |
...
|
...
|
|