Authored by lore-w

图片上传优化/我的收藏优化

... ... @@ -44,7 +44,6 @@ function initSwiper() {
$swiperList = $('.swiper-container');
for (i = 0; i < $swiperList.length; i++) {
id = $swiperList.eq(i).attr('data-id');
console.log(id);
if (!!swiperObj[id]) {
swiperObj[id].destroy(true, true);
... ... @@ -91,7 +90,7 @@ function loadData($parent, url, page) {
} else if (data.length > 10) {
$parent.append(data);
$parent.closest('.fav-type').find('.fav-content-loading').remove();
if (url === 'favBrand') {
initSwiper();//如果是收藏品牌需要初始化swiper
... ... @@ -142,6 +141,7 @@ favTabHammer.on('tap', function(e) {
loadData($favProductList, 'favProduct', 1);
}
} else {
brandTab = true;
if ($favBrandList.find('div').length === 0 &&
$favBrandList.closest('.fav-type').find('.fav-null-box').hasClass('hide')) {
loadData($favBrandList, 'favBrand', 1);
... ... @@ -211,12 +211,13 @@ $(document).scroll(function() {
if ($(window).scrollTop() + winH >= $(document).height() - footerH) {
if (brandTab) {
console.log(1);
$brandLoadMore.filter('.hide').removeClass('hide');
if (!brandLockId) {
brandPageId++;
loadData($favBrandList, 'favBrand', brandPageId);
}
} else {
... ... @@ -224,7 +225,6 @@ $(document).scroll(function() {
$loadMore.filter('.hide').removeClass('hide');
if (!lockId) {
console.log(222);
pageId++;
loadData($favProductList, 'favProduct', pageId);
}
... ...
... ... @@ -20,14 +20,15 @@ var $uploadImgList = $('.upload-img-list'),
$likeBtn = $('.suggest-item .like-btn'),
$disLikeBtn = $('.suggest-item .dislike-btn'),
$imgAdd = $('.img-add'),
imgStr = '';
imgStr = '',
uploadImgNum = 0;
require('./jquery.uploadifive');
imgTpl = '{{# imgList}}' +
'<li>' +
'<img src="{{imgUrl}}" />' +
'<span class="upload-img-remove"></span>' +
'{{# imgUrl}}<img src="{{.}}" />' +
'<span class="upload-img-remove"></span>{{/ imgUrl}}' +
'</li>' +
'{{/ imgList}}';
... ... @@ -41,16 +42,20 @@ $('#upload-img').uploadifive({
fileSizeLimit: 1024,
height: '100%',
width: '100%',
queueSizeLimit: 1,
multi: false,
onAddQueueItem: function(files) {
//TODO
$uploadImgList.html(imgTemplate({
imgList: true
}));
},
onUploadComplete: function(file, data) {
$uploadImgList.html('');
imgStr = JSON.parse(data).imgList[0].imgRelUrl;
$uploadImgList.html(imgTemplate(JSON.parse(data)));
$imgAdd.hide();
uploadImgNum++;
}
});
... ... @@ -92,6 +97,7 @@ if (document.getElementById('img-form') !== null) {
if ($(e.target).hasClass('upload-img-remove')) {
$uploadImgList.html('');
imgStr = '';
uploadImgNum--;
setTimeout(function() {
$imgAdd.show();
}, 50);
... ...
... ... @@ -291,4 +291,10 @@
@include background-size(auto 40%);
}
}
.fav-content-loading {
width: 100%;
height: 2rem;
background: image_url('loading.gif') center center no-repeat;
@include background-size(auto 40%);
}
}
\ No newline at end of file
... ...
... ... @@ -8,6 +8,7 @@
<div class="fav-content" id="fav-content">
<div class="fav-type">
<ul class="fav-product-list"></ul>
<div class="fav-content-loading"></div>
<div class="fav-null-box hide">
<span class="fav-null">您暂无收藏任何商品</span>
... ... @@ -17,12 +18,13 @@
</div>
<div class="fav-type">
<div class="fav-brand-swiper"></div>
<div class="fav-content-loading"></div>
<div class="fav-null-box hide">
<span class="fav-null">您暂无收藏任何品牌</span>
<a class="go-shopping" href="{{brandUrl}}">随便逛逛</a>
</div>
<div class="fav-brand-load-more load-background hide"></div>
<div class="fav-brand-load-more fav-load-background hide"></div>
</div>
</div>
{{/ favorite}}
... ...