review by zhaobiao
Showing
1 changed file
with
78 additions
and
4 deletions
@@ -12,8 +12,46 @@ var page = 1, | @@ -12,8 +12,46 @@ var page = 1, | ||
12 | notab = 0, | 12 | notab = 0, |
13 | sort = '', | 13 | sort = '', |
14 | id = '', | 14 | id = '', |
15 | + hotrankNav, | ||
15 | noResult = '<p class="no-result">未找到相关搜索结果</p>'; | 16 | noResult = '<p class="no-result">未找到相关搜索结果</p>'; |
16 | 17 | ||
18 | +// var renderRank = { | ||
19 | +// errMsg: '<p class="no-result">未找到相关搜索结果</p>', | ||
20 | +// navSelector: '.goods-nav', | ||
21 | +// rankSelector: '#hotRank', | ||
22 | +// navHTML: null, | ||
23 | +// data: null, | ||
24 | +// inited: 0, | ||
25 | +// setData: function(data) { | ||
26 | +// this.data = data; | ||
27 | +// }, | ||
28 | +// showDataEmptyMsg: function() { | ||
29 | +// $(this.rankSelector).append(this.errMsg); | ||
30 | +// }, | ||
31 | +// isDataEmpty: function() { | ||
32 | +// if (this.data.indexOf('>') === -1) { | ||
33 | +// return true; | ||
34 | +// } else { | ||
35 | +// return false; | ||
36 | +// } | ||
37 | +// }, | ||
38 | +// appendData: function() { | ||
39 | +// if (!this.inited) { | ||
40 | +// this.inited = 1; | ||
41 | +// } | ||
42 | +// $(this.rankSelector).append(this.data); | ||
43 | +// }, | ||
44 | +// render: function(data) { | ||
45 | +// this.setData(data); | ||
46 | +// if (!this.isDataEmpty()) { | ||
47 | +// this.appendData(); | ||
48 | +// } else { | ||
49 | +// this.showDataEmptyMsg(); | ||
50 | +// } | ||
51 | +// } | ||
52 | + | ||
53 | +// }; | ||
54 | + | ||
17 | function hotrank(page, sort, tabId, notab) { | 55 | function hotrank(page, sort, tabId, notab) { |
18 | loading.showLoadingMask(); | 56 | loading.showLoadingMask(); |
19 | $.ajax({ | 57 | $.ajax({ |
@@ -26,15 +64,47 @@ function hotrank(page, sort, tabId, notab) { | @@ -26,15 +64,47 @@ function hotrank(page, sort, tabId, notab) { | ||
26 | notab: notab | 64 | notab: notab |
27 | }, | 65 | }, |
28 | success: function(data) { | 66 | success: function(data) { |
29 | - console.log(data); | 67 | + |
68 | + // if (page === 1) { | ||
69 | + // $('.no-result').remove(); | ||
70 | + // $('.rank-main').remove(); | ||
71 | + // } | ||
72 | + | ||
73 | + // if (notab === 1) { | ||
74 | + // if (data === ' ' && $('.rank-main').length < 1) { | ||
75 | + // var hotrankNav = $('.goods-nav').prop("outerHTML"); | ||
76 | + | ||
77 | + // $('#hotRank').html(hotrankNav + noResult); | ||
78 | + // } else { | ||
79 | + // $('#hotRank').append(data); | ||
80 | + // } | ||
81 | + // } else { | ||
82 | + // if (data === ' ') { | ||
83 | + // $('#hotRank').html(noResult); | ||
84 | + // } else { | ||
85 | + // $('#hotRank').append(data); | ||
86 | + // } | ||
87 | + // } | ||
88 | + if (data === ' ') { | ||
89 | + if ($('.rank-main').length < 1 && $('.goods-nav').length < 1) { | ||
90 | + $('#hotRank').html(noResult); | ||
91 | + } else { | ||
30 | if (page === 1) { | 92 | if (page === 1) { |
31 | - $('.rank-main').remove(); | 93 | + hotrankNav = $('.goods-nav').prop('outerHTML'); |
94 | + | ||
95 | + $('#hotRank').html(hotrankNav + noResult); | ||
96 | + } | ||
32 | } | 97 | } |
33 | - if (data === ' ' && $('.rank-main ul li').length < 1) { | ||
34 | - $('#hotRank').html(noResult); | ||
35 | } else { | 98 | } else { |
99 | + $('.no-result').remove(); | ||
100 | + $('.rank-main').remove(); | ||
36 | $('#hotRank').append(data); | 101 | $('#hotRank').append(data); |
37 | } | 102 | } |
103 | + | ||
104 | + // renderRank.render(data); | ||
105 | + | ||
106 | + | ||
107 | + | ||
38 | lazyLoad($('img.lazy')); | 108 | lazyLoad($('img.lazy')); |
39 | $('.rank-main ul li:gt(2)').find('.item-content i').removeClass('top'); | 109 | $('.rank-main ul li:gt(2)').find('.item-content i').removeClass('top'); |
40 | winH = $(window).height(); | 110 | winH = $(window).height(); |
@@ -83,7 +153,11 @@ hotnav.on('tap', function(e) { | @@ -83,7 +153,11 @@ hotnav.on('tap', function(e) { | ||
83 | id = target.getAttribute('data-id') ? target.getAttribute('data-id') : ''; | 153 | id = target.getAttribute('data-id') ? target.getAttribute('data-id') : ''; |
84 | sort = target.getAttribute('data-sort') ? target.getAttribute('data-sort') : ''; | 154 | sort = target.getAttribute('data-sort') ? target.getAttribute('data-sort') : ''; |
85 | page = 1; | 155 | page = 1; |
156 | + | ||
157 | + // notab = renderRank.inited; | ||
86 | notab = 1; | 158 | notab = 1; |
159 | + | ||
160 | + | ||
87 | hotrank(page, sort, id, notab); | 161 | hotrank(page, sort, id, notab); |
88 | } | 162 | } |
89 | }); | 163 | }); |
-
Please register or login to post a comment