Authored by lore-w

优化品牌收藏swiper

... ... @@ -12,7 +12,6 @@ var diaLog = require('./dialog');
var $navLi = $('#fav-tab > li'),
$favContainer = $('.fav-content > .fav-type'),
$swiperList = '',
swiperObj = {},
favTabHammer,
favContentHammer,
... ... @@ -37,22 +36,30 @@ function showFavTab(index) {
}
//初始化swiper
function initSwiper() {
function initSwiper(data) {
var i,
id;
idStrReg = /container-(\d+)['"]{1}/gi,
idReg = /\d+/,
idArr = data.match(idStrReg),
idArrLen = idArr.length,
containerId;
$swiperList = $('.swiper-container');
for (i = 0; i < $swiperList.length; i++) {
id = $swiperList.eq(i).attr('data-id');
//$swiperList = $('.swiper-container');
for (i = 0; i < idArrLen; i++) {
/*id = $swiperList.eq(i).attr('data-id');
if (!!swiperObj[id]) {
swiperObj[id].destroy(true, true);
}
swiperObj[id] = new Swiper('#swiper-container-' + id, {
}*/
containerId = idArr[i].match(idReg)[0];
swiperObj[containerId] = new Swiper('#swiper-container-' + containerId, {
slidesPerView: 'auto',
grabCursor: true,
slideElement: 'li',
wrapperClass: 'swiper-wrapper-' + id,
wrapperClass: 'swiper-wrapper-' + containerId,
lazyLoading: true,
watchSlidesVisibility: true
});
... ... @@ -93,7 +100,7 @@ function loadData($parent, url, page) {
$parent.append(data);
$parent.closest('.fav-type').find('.fav-content-loading').remove();
if (url === 'favBrand') {
initSwiper();//如果是收藏品牌需要初始化swiper
initSwiper(data);//如果是收藏品牌需要初始化swiper
brandLockId = false;//请求成功后解锁品牌收藏page++
} else {
... ...
... ... @@ -39,7 +39,7 @@ $('#upload-img').uploadifive({
fileType: 'image*/*',
uploadScript: '/home/suggestimgUpload',
fileObjName: 'fileData',
fileSizeLimit: 1024,
fileSizeLimit: 300,
height: '100%',
width: '100%',
multi: false,
... ...