Authored by lore-w

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

@@ -44,7 +44,6 @@ function initSwiper() { @@ -44,7 +44,6 @@ function initSwiper() {
44 $swiperList = $('.swiper-container'); 44 $swiperList = $('.swiper-container');
45 for (i = 0; i < $swiperList.length; i++) { 45 for (i = 0; i < $swiperList.length; i++) {
46 id = $swiperList.eq(i).attr('data-id'); 46 id = $swiperList.eq(i).attr('data-id');
47 - console.log(id);  
48 47
49 if (!!swiperObj[id]) { 48 if (!!swiperObj[id]) {
50 swiperObj[id].destroy(true, true); 49 swiperObj[id].destroy(true, true);
@@ -91,7 +90,7 @@ function loadData($parent, url, page) { @@ -91,7 +90,7 @@ function loadData($parent, url, page) {
91 90
92 } else if (data.length > 10) { 91 } else if (data.length > 10) {
93 $parent.append(data); 92 $parent.append(data);
94 - 93 + $parent.closest('.fav-type').find('.fav-content-loading').remove();
95 if (url === 'favBrand') { 94 if (url === 'favBrand') {
96 initSwiper();//如果是收藏品牌需要初始化swiper 95 initSwiper();//如果是收藏品牌需要初始化swiper
97 96
@@ -142,6 +141,7 @@ favTabHammer.on('tap', function(e) { @@ -142,6 +141,7 @@ favTabHammer.on('tap', function(e) {
142 loadData($favProductList, 'favProduct', 1); 141 loadData($favProductList, 'favProduct', 1);
143 } 142 }
144 } else { 143 } else {
  144 + brandTab = true;
145 if ($favBrandList.find('div').length === 0 && 145 if ($favBrandList.find('div').length === 0 &&
146 $favBrandList.closest('.fav-type').find('.fav-null-box').hasClass('hide')) { 146 $favBrandList.closest('.fav-type').find('.fav-null-box').hasClass('hide')) {
147 loadData($favBrandList, 'favBrand', 1); 147 loadData($favBrandList, 'favBrand', 1);
@@ -211,12 +211,13 @@ $(document).scroll(function() { @@ -211,12 +211,13 @@ $(document).scroll(function() {
211 if ($(window).scrollTop() + winH >= $(document).height() - footerH) { 211 if ($(window).scrollTop() + winH >= $(document).height() - footerH) {
212 212
213 if (brandTab) { 213 if (brandTab) {
  214 + console.log(1);
214 215
215 $brandLoadMore.filter('.hide').removeClass('hide'); 216 $brandLoadMore.filter('.hide').removeClass('hide');
216 217
217 if (!brandLockId) { 218 if (!brandLockId) {
218 -  
219 brandPageId++; 219 brandPageId++;
  220 + loadData($favBrandList, 'favBrand', brandPageId);
220 } 221 }
221 222
222 } else { 223 } else {
@@ -224,7 +225,6 @@ $(document).scroll(function() { @@ -224,7 +225,6 @@ $(document).scroll(function() {
224 $loadMore.filter('.hide').removeClass('hide'); 225 $loadMore.filter('.hide').removeClass('hide');
225 226
226 if (!lockId) { 227 if (!lockId) {
227 - console.log(222);  
228 pageId++; 228 pageId++;
229 loadData($favProductList, 'favProduct', pageId); 229 loadData($favProductList, 'favProduct', pageId);
230 } 230 }
@@ -20,14 +20,15 @@ var $uploadImgList = $('.upload-img-list'), @@ -20,14 +20,15 @@ var $uploadImgList = $('.upload-img-list'),
20 $likeBtn = $('.suggest-item .like-btn'), 20 $likeBtn = $('.suggest-item .like-btn'),
21 $disLikeBtn = $('.suggest-item .dislike-btn'), 21 $disLikeBtn = $('.suggest-item .dislike-btn'),
22 $imgAdd = $('.img-add'), 22 $imgAdd = $('.img-add'),
23 - imgStr = ''; 23 + imgStr = '',
  24 + uploadImgNum = 0;
24 25
25 require('./jquery.uploadifive'); 26 require('./jquery.uploadifive');
26 27
27 imgTpl = '{{# imgList}}' + 28 imgTpl = '{{# imgList}}' +
28 '<li>' + 29 '<li>' +
29 - '<img src="{{imgUrl}}" />' +  
30 - '<span class="upload-img-remove"></span>' + 30 + '{{# imgUrl}}<img src="{{.}}" />' +
  31 + '<span class="upload-img-remove"></span>{{/ imgUrl}}' +
31 '</li>' + 32 '</li>' +
32 '{{/ imgList}}'; 33 '{{/ imgList}}';
33 34
@@ -41,16 +42,20 @@ $('#upload-img').uploadifive({ @@ -41,16 +42,20 @@ $('#upload-img').uploadifive({
41 fileSizeLimit: 1024, 42 fileSizeLimit: 1024,
42 height: '100%', 43 height: '100%',
43 width: '100%', 44 width: '100%',
44 - queueSizeLimit: 1,  
45 - 45 + multi: false,
46 onAddQueueItem: function(files) { 46 onAddQueueItem: function(files) {
47 47
48 //TODO 48 //TODO
  49 + $uploadImgList.html(imgTemplate({
  50 + imgList: true
  51 + }));
49 }, 52 },
50 onUploadComplete: function(file, data) { 53 onUploadComplete: function(file, data) {
  54 + $uploadImgList.html('');
51 imgStr = JSON.parse(data).imgList[0].imgRelUrl; 55 imgStr = JSON.parse(data).imgList[0].imgRelUrl;
52 $uploadImgList.html(imgTemplate(JSON.parse(data))); 56 $uploadImgList.html(imgTemplate(JSON.parse(data)));
53 $imgAdd.hide(); 57 $imgAdd.hide();
  58 + uploadImgNum++;
54 } 59 }
55 }); 60 });
56 61
@@ -92,6 +97,7 @@ if (document.getElementById('img-form') !== null) { @@ -92,6 +97,7 @@ if (document.getElementById('img-form') !== null) {
92 if ($(e.target).hasClass('upload-img-remove')) { 97 if ($(e.target).hasClass('upload-img-remove')) {
93 $uploadImgList.html(''); 98 $uploadImgList.html('');
94 imgStr = ''; 99 imgStr = '';
  100 + uploadImgNum--;
95 setTimeout(function() { 101 setTimeout(function() {
96 $imgAdd.show(); 102 $imgAdd.show();
97 }, 50); 103 }, 50);
@@ -291,4 +291,10 @@ @@ -291,4 +291,10 @@
291 @include background-size(auto 40%); 291 @include background-size(auto 40%);
292 } 292 }
293 } 293 }
  294 + .fav-content-loading {
  295 + width: 100%;
  296 + height: 2rem;
  297 + background: image_url('loading.gif') center center no-repeat;
  298 + @include background-size(auto 40%);
  299 + }
294 } 300 }
@@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
8 <div class="fav-content" id="fav-content"> 8 <div class="fav-content" id="fav-content">
9 <div class="fav-type"> 9 <div class="fav-type">
10 <ul class="fav-product-list"></ul> 10 <ul class="fav-product-list"></ul>
  11 + <div class="fav-content-loading"></div>
11 12
12 <div class="fav-null-box hide"> 13 <div class="fav-null-box hide">
13 <span class="fav-null">您暂无收藏任何商品</span> 14 <span class="fav-null">您暂无收藏任何商品</span>
@@ -17,12 +18,13 @@ @@ -17,12 +18,13 @@
17 </div> 18 </div>
18 <div class="fav-type"> 19 <div class="fav-type">
19 <div class="fav-brand-swiper"></div> 20 <div class="fav-brand-swiper"></div>
  21 + <div class="fav-content-loading"></div>
20 22
21 <div class="fav-null-box hide"> 23 <div class="fav-null-box hide">
22 <span class="fav-null">您暂无收藏任何品牌</span> 24 <span class="fav-null">您暂无收藏任何品牌</span>
23 <a class="go-shopping" href="{{brandUrl}}">随便逛逛</a> 25 <a class="go-shopping" href="{{brandUrl}}">随便逛逛</a>
24 </div> 26 </div>
25 - <div class="fav-brand-load-more load-background hide"></div> 27 + <div class="fav-brand-load-more fav-load-background hide"></div>
26 </div> 28 </div>
27 </div> 29 </div>
28 {{/ favorite}} 30 {{/ favorite}}