...
|
...
|
@@ -3,14 +3,105 @@ |
|
|
*/
|
|
|
|
|
|
var $ = require('yoho-jquery'),
|
|
|
Swiper = require('yoho-swiper');
|
|
|
Swiper = require('yoho-swiper'),
|
|
|
tip = require('../plugin/tip');
|
|
|
|
|
|
// tip = require('../../plugin/tip');
|
|
|
// Handlebars = require('yoho-handlebars');
|
|
|
|
|
|
// $(function() {
|
|
|
// new Swiper('.nav', {
|
|
|
// slideElement: 'nav-info',
|
|
|
// slidesPerView: 'auto',
|
|
|
// watchSlidesVisibility: true
|
|
|
// });
|
|
|
// }); |
|
|
var searching,
|
|
|
$collect = $('.collect-btn'),
|
|
|
shopId,
|
|
|
navSwiper;
|
|
|
|
|
|
var shopNav = require('./collect-shop/shop-nav.hbs');
|
|
|
|
|
|
var navString = shopNav({
|
|
|
navList: [
|
|
|
{
|
|
|
navName: '欧美'
|
|
|
},
|
|
|
{
|
|
|
navName: '欧美'
|
|
|
},
|
|
|
{
|
|
|
navName: '推荐'
|
|
|
}
|
|
|
]
|
|
|
});
|
|
|
|
|
|
require('../common');
|
|
|
|
|
|
$('.shop-nav').append(navString);
|
|
|
|
|
|
$collect.on('touchstart', function() {
|
|
|
var opt,
|
|
|
$this = $(this);
|
|
|
|
|
|
shopId = $this.parents('.shop-info').data('id');
|
|
|
|
|
|
if (searching) {
|
|
|
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',
|
|
|
data: {
|
|
|
id: shopId,
|
|
|
opt: opt,
|
|
|
type: 'shop',
|
|
|
},
|
|
|
xhrFields: {
|
|
|
withCredentials: true
|
|
|
},
|
|
|
success: function(data) {
|
|
|
|
|
|
if (data.code === 200) {
|
|
|
if ($collect.hasClass('already-collect')) {
|
|
|
$collect.removeClass('already-collect');
|
|
|
tip.show('店铺取消收藏成功');
|
|
|
} else {
|
|
|
$collect.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;
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
$(function() {
|
|
|
navSwiper = new Swiper('.shop-nav', {
|
|
|
grabCursor: true,
|
|
|
slidesPerView: 'auto',
|
|
|
slideElement: 'li'
|
|
|
});
|
|
|
|
|
|
if ($('.banner-swiper').find('li').size() > 1) {
|
|
|
bannerSwiper = new Swiper('.banner-swiper', {
|
|
|
lazyLoading: true,
|
|
|
lazyLoadingInPrevNext: true,
|
|
|
loop: true,
|
|
|
autoplay: 3000,
|
|
|
autoplayDisableOnInteraction: false,
|
|
|
paginationClickable: true,
|
|
|
slideElement: 'li',
|
|
|
pagination: '.banner-top .pagination-inner'
|
|
|
});
|
|
|
}
|
|
|
}); |
...
|
...
|
|