...
|
...
|
@@ -6,28 +6,22 @@ |
|
|
|
|
|
var $ = require('jquery'),
|
|
|
Hammer = require('yoho.hammer'),
|
|
|
lazyLoad = require('yoho.lazyload'),
|
|
|
Swiper = require('yoho.iswiper');
|
|
|
|
|
|
//导航
|
|
|
var $navLi = $('#fav-tab > li'),
|
|
|
$favContainer = $('.fav-content');
|
|
|
|
|
|
var $curContainer = $favContainer.children('.fav-type').first();//保存当前显示的$favContainer
|
|
|
|
|
|
var favTabHammer;
|
|
|
|
|
|
//轮播图
|
|
|
var $swiperList = $('.swiper-container'),
|
|
|
swiperArray = [],
|
|
|
swiperObj = {};
|
|
|
|
|
|
//lazyLoad();
|
|
|
$favContainer = $('.fav-content'),
|
|
|
$curContainer = $favContainer.children('.fav-type').first(),
|
|
|
$swiperList = $('.swiper-container'),
|
|
|
swiperObj = {},
|
|
|
favTabHammer,
|
|
|
favContentHammer;
|
|
|
|
|
|
favTabHammer = new Hammer(document.getElementById('fav-tab'));
|
|
|
favTabHammer.on('tap', function(e) {
|
|
|
var $cur = $(e.target).closest('li'),
|
|
|
index;
|
|
|
index,
|
|
|
id,
|
|
|
i;
|
|
|
|
|
|
if ($cur.length === 0 || $cur.hasClass('active')) {
|
|
|
return;
|
...
|
...
|
@@ -42,9 +36,10 @@ favTabHammer.on('tap', function(e) { |
|
|
$curContainer = $favContainer.children(':eq(' + index + ')').removeClass('hide');
|
|
|
|
|
|
if (index === 1) {
|
|
|
|
|
|
//导航
|
|
|
for (var i = 0; i < $swiperList.length; i++) {
|
|
|
var id = $swiperList.eq(i).attr('data-id');
|
|
|
for (i = 0; i < $swiperList.length; i++) {
|
|
|
id = $swiperList.eq(i).attr('data-id');
|
|
|
swiperObj[id] = new Swiper('#swiper-container-' + id, {
|
|
|
slidesPerView: 'auto',
|
|
|
grabCursor: true,
|
...
|
...
|
@@ -57,3 +52,31 @@ favTabHammer.on('tap', function(e) { |
|
|
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//删除收藏的商品
|
|
|
favContentHammer = new Hammer(document.getElementById('fav-content'));
|
|
|
|
|
|
favContentHammer.on('tap', function (e) {
|
|
|
var id = '';
|
|
|
|
|
|
|
|
|
if ($(e.target).hasClass('del-fav')) {
|
|
|
id = $(e.target).closest('li').attr('data-id');
|
|
|
$.ajax({
|
|
|
method: 'post',
|
|
|
url: '/home/favoriteDel',
|
|
|
data: {
|
|
|
id: id
|
|
|
}
|
|
|
}).then(function (data) {
|
|
|
|
|
|
|
|
|
if (data.code === 200) {
|
|
|
$(e.target).closest('li').remove();
|
|
|
}
|
|
|
}).fail(function () {
|
|
|
|
|
|
//TODO
|
|
|
});
|
|
|
}
|
|
|
}); |
|
|
\ No newline at end of file |
...
|
...
|
|