Showing
6 changed files
with
96 additions
and
9 deletions
@@ -37,6 +37,7 @@ | @@ -37,6 +37,7 @@ | ||
37 | <a class="list-item" href="#" target="_blank">北京</a> | 37 | <a class="list-item" href="#" target="_blank">北京</a> |
38 | <a class="list-item" href="#" target="_blank">北京</a> | 38 | <a class="list-item" href="#" target="_blank">北京</a> |
39 | </div> | 39 | </div> |
40 | + <div id="list-container"> | ||
40 | <div class="shop-item"> | 41 | <div class="shop-item"> |
41 | <div class="shop-pic"> | 42 | <div class="shop-pic"> |
42 | <img src="../../src/images/area/city-test.png" alt="alt" /> | 43 | <img src="../../src/images/area/city-test.png" alt="alt" /> |
@@ -226,6 +227,7 @@ | @@ -226,6 +227,7 @@ | ||
226 | </a> | 227 | </a> |
227 | </div> | 228 | </div> |
228 | </div> | 229 | </div> |
230 | + </div> | ||
229 | <h1 class="h1-g">新鲜好去处,探索城市潮流,潮流火星APP下载|火星Mars</h1> | 231 | <h1 class="h1-g">新鲜好去处,探索城市潮流,潮流火星APP下载|火星Mars</h1> |
230 | <a target="_blank" title="app下载" class="download" href="http://a.app.qq.com/o/simple.jsp?pkgname=com.yohobuy.mars"></a> | 232 | <a target="_blank" title="app下载" class="download" href="http://a.app.qq.com/o/simple.jsp?pkgname=com.yohobuy.mars"></a> |
231 | </div> | 233 | </div> |
src/js/area/more-area.js
0 → 100644
1 | +const $ = require('jquery'); | ||
2 | +const lazyload = require('../plugins/lazyload'); | ||
3 | +window.jQuery = $; | ||
4 | + | ||
5 | +let moreObj = { | ||
6 | + domInit: function () { | ||
7 | + this.el = { | ||
8 | + $listContainer: $('#list-container') | ||
9 | + }; | ||
10 | + }, | ||
11 | + init: function () { | ||
12 | + this.domInit(); | ||
13 | + this.page = 0; | ||
14 | + this.loading = false; | ||
15 | + this.end = false; | ||
16 | + this.scroll(); | ||
17 | + }, | ||
18 | + scroll: function () { | ||
19 | + $(window).scroll(() => { | ||
20 | + if (($(window).scrollTop() + $(window).height() >= $(document).height() * 0.8)) { | ||
21 | + this.doMore(); | ||
22 | + } | ||
23 | + }); | ||
24 | + }, | ||
25 | + doMore: function () { | ||
26 | + if (!this.loading && !this.end) { | ||
27 | + this.page++; | ||
28 | + this.getMore(); | ||
29 | + } | ||
30 | + }, | ||
31 | + getMore: function () { | ||
32 | + this.loading = true; | ||
33 | + let ajaxData = { | ||
34 | + page: this.page, | ||
35 | + row: 10 | ||
36 | + }; | ||
37 | + if ($('#cityId').val()) { | ||
38 | + Object.assign(ajaxData, {cityId: $('#cityId').val()}); | ||
39 | + } | ||
40 | + $.ajax({ | ||
41 | + method: 'GET', | ||
42 | + url: window.$ajaxPath, | ||
43 | + data: ajaxData, | ||
44 | + success: (result) => { | ||
45 | + if ($(result).length > 0) { | ||
46 | + let $result = $(result); | ||
47 | + let $lazyImg = $result.find('img.lazy'); | ||
48 | + | ||
49 | + this.el.$listContainer.append($result); | ||
50 | + lazyload($lazyImg, { | ||
51 | + threshold: 1000, | ||
52 | + q: 80 | ||
53 | + }); | ||
54 | + this.loading = false; | ||
55 | + } else { | ||
56 | + this.end = true; | ||
57 | + } | ||
58 | + } | ||
59 | + }); | ||
60 | + } | ||
61 | +}; | ||
62 | + | ||
63 | +$( | ||
64 | + function () { | ||
65 | + moreObj.init(); | ||
66 | + } | ||
67 | +); |
1 | const $ = require('jquery'); | 1 | const $ = require('jquery'); |
2 | +const lazyload = require('../plugins/lazyload'); | ||
2 | window.jQuery = $; | 3 | window.jQuery = $; |
3 | 4 | ||
4 | let moreObj = { | 5 | let moreObj = { |
@@ -29,17 +30,33 @@ let moreObj = { | @@ -29,17 +30,33 @@ let moreObj = { | ||
29 | }, | 30 | }, |
30 | getMore: function () { | 31 | getMore: function () { |
31 | this.loading = true; | 32 | this.loading = true; |
33 | + let ajaxData = { | ||
34 | + page: this.page, | ||
35 | + row: 10 | ||
36 | + }; | ||
37 | + if ($('#businessAreaId').val()) { | ||
38 | + Object.assign(ajaxData, {businessAreaId: $('#businessAreaId').val()}); | ||
39 | + } | ||
40 | + if ($('#cityId').val()) { | ||
41 | + Object.assign(ajaxData, {cityId: $('#cityId').val()}); | ||
42 | + } | ||
43 | + if ($('#tagId').val()) { | ||
44 | + Object.assign(ajaxData, {tagId: $('#tagId').val()}); | ||
45 | + } | ||
32 | $.ajax({ | 46 | $.ajax({ |
33 | method: 'GET', | 47 | method: 'GET', |
34 | url: window.$ajaxPath, | 48 | url: window.$ajaxPath, |
35 | - data: { | ||
36 | - page: this.page, | ||
37 | - row: 10, | ||
38 | - businessAreaId: 44 | ||
39 | - }, | 49 | + data: ajaxData, |
40 | success: (result) => { | 50 | success: (result) => { |
41 | - if (result) { | ||
42 | - this.el.$listContainer.append(result); | 51 | + if ($(result).length > 0) { |
52 | + let $result = $(result); | ||
53 | + let $lazyImg = $result.find('img.lazy'); | ||
54 | + | ||
55 | + this.el.$listContainer.append($result); | ||
56 | + lazyload($lazyImg, { | ||
57 | + threshold: 1000, | ||
58 | + q: 80 | ||
59 | + }); | ||
43 | this.loading = false; | 60 | this.loading = false; |
44 | } else { | 61 | } else { |
45 | this.end = true; | 62 | this.end = true; |
@@ -204,7 +204,7 @@ | @@ -204,7 +204,7 @@ | ||
204 | .down-list { | 204 | .down-list { |
205 | display: none; | 205 | display: none; |
206 | position: absolute; | 206 | position: absolute; |
207 | - top: 86px; | 207 | + top: 85px; |
208 | left: 0; | 208 | left: 0; |
209 | max-height: 665px; | 209 | max-height: 665px; |
210 | width: 720px; | 210 | width: 720px; |
-
Please register or login to post a comment