我的收藏页面,处理data等于end时如果loadingMask存在且没有hide样式的情况. code review by LZF
Showing
1 changed file
with
13 additions
and
2 deletions
@@ -79,6 +79,8 @@ function loadData($parent, url, page) { | @@ -79,6 +79,8 @@ function loadData($parent, url, page) { | ||
79 | page: page | 79 | page: page |
80 | }, | 80 | }, |
81 | success: function(data) { | 81 | success: function(data) { |
82 | + var $loadingMask = $parent.closest('.fav-type').find('.fav-content-loading'); | ||
83 | + | ||
82 | if (url === 'favBrand') { | 84 | if (url === 'favBrand') { |
83 | $brandLoadMore.addClass('hide'); | 85 | $brandLoadMore.addClass('hide'); |
84 | } else { | 86 | } else { |
@@ -86,9 +88,16 @@ function loadData($parent, url, page) { | @@ -86,9 +88,16 @@ function loadData($parent, url, page) { | ||
86 | } | 88 | } |
87 | 89 | ||
88 | if (data === ' ') { | 90 | if (data === ' ') { |
89 | - $parent.closest('.fav-type').find('.fav-content-loading').addClass('hide'); | 91 | + $loadingMask.addClass('hide'); |
90 | $parent.closest('.fav-type').find('.fav-null-box').removeClass('hide'); | 92 | $parent.closest('.fav-type').find('.fav-null-box').removeClass('hide'); |
91 | } else if (data === 'end') { | 93 | } else if (data === 'end') { |
94 | + | ||
95 | + //处理data等于end时如果loadingMask存在且没有hide样式的情况 | ||
96 | + if ($loadingMask && !$loadingMask.hasClass('hide')) { | ||
97 | + $loadingMask.addClass('hide'); | ||
98 | + $parent.closest('.fav-type').find('.fav-null-box').removeClass('hide'); | ||
99 | + } | ||
100 | + | ||
92 | $parent.closest('.fav-type').find('.fav-load-background') | 101 | $parent.closest('.fav-type').find('.fav-load-background') |
93 | .removeClass('fav-load-background').html('没有更多了'); | 102 | .removeClass('fav-load-background').html('没有更多了'); |
94 | 103 | ||
@@ -97,7 +106,9 @@ function loadData($parent, url, page) { | @@ -97,7 +106,9 @@ function loadData($parent, url, page) { | ||
97 | lockId = true; | 106 | lockId = true; |
98 | } else if (data.length > 10) { | 107 | } else if (data.length > 10) { |
99 | $parent.append(data); | 108 | $parent.append(data); |
100 | - $parent.closest('.fav-type').find('.fav-content-loading').remove(); | 109 | + |
110 | + //如果有数据loadingMask会被remove掉 | ||
111 | + $loadingMask.remove(); | ||
101 | if (url === 'favBrand') { | 112 | if (url === 'favBrand') { |
102 | initSwiper(data);//如果是收藏品牌需要初始化swiper | 113 | initSwiper(data);//如果是收藏品牌需要初始化swiper |
103 | 114 |
-
Please register or login to post a comment