From d55b83def94484da272ad98f2f3e2dd23da0f4c0 Mon Sep 17 00:00:00 2001 From: lore-w <metro-cpu@hotmail.com> Date: Fri, 27 Nov 2015 19:22:11 +0800 Subject: [PATCH] 图片上传优化/我的收藏优化 --- static/js/me/fav.js | 8 ++++---- static/js/me/suggest.js | 16 +++++++++++----- static/sass/me/_fav.scss | 6 ++++++ template/m.yohobuy.com/actions/index/home/favorite.phtml | 4 +++- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/static/js/me/fav.js b/static/js/me/fav.js index 19da507..4276937 100644 --- a/static/js/me/fav.js +++ b/static/js/me/fav.js @@ -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); } diff --git a/static/js/me/suggest.js b/static/js/me/suggest.js index 4b3bfd9..2a6a2a8 100644 --- a/static/js/me/suggest.js +++ b/static/js/me/suggest.js @@ -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); diff --git a/static/sass/me/_fav.scss b/static/sass/me/_fav.scss index aeed893..ad83996 100644 --- a/static/sass/me/_fav.scss +++ b/static/sass/me/_fav.scss @@ -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 diff --git a/template/m.yohobuy.com/actions/index/home/favorite.phtml b/template/m.yohobuy.com/actions/index/home/favorite.phtml index 041fecc..39ec69b 100644 --- a/template/m.yohobuy.com/actions/index/home/favorite.phtml +++ b/template/m.yohobuy.com/actions/index/home/favorite.phtml @@ -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}} -- libgit2 0.24.0