|
|
1
|
+"use strict";
|
|
|
2
|
+
|
1
|
var $ = require('yoho-jquery'),
|
3
|
var $ = require('yoho-jquery'),
|
2
|
Hammer = require('yoho-hammer'),
|
4
|
Hammer = require('yoho-hammer'),
|
3
|
ellipsis = require('yoho-mlellipsis'),
|
5
|
ellipsis = require('yoho-mlellipsis'),
|
|
@@ -5,12 +7,44 @@ var $ = require('yoho-jquery'), |
|
@@ -5,12 +7,44 @@ var $ = require('yoho-jquery'), |
5
|
|
7
|
|
6
|
var employ,
|
8
|
var employ,
|
7
|
statu = 0,
|
9
|
statu = 0,
|
8
|
- page = 1;
|
10
|
+ page = 1,
|
|
|
11
|
+ //防止重复请求
|
|
|
12
|
+ AjaxFlag = 0,
|
|
|
13
|
+ //上滑不请求
|
|
|
14
|
+ direction = true;
|
|
|
15
|
+
|
|
|
16
|
+require('../common');
|
9
|
|
17
|
|
10
|
ellipsis.init();
|
18
|
ellipsis.init();
|
11
|
|
19
|
|
|
|
20
|
+//判断滑动方向
|
|
|
21
|
+$('body').on('touchstart', function(e) {
|
|
|
22
|
+ var touch = e.originalEvent,
|
|
|
23
|
+ startX = touch.changedTouches[0].pageX,
|
|
|
24
|
+ startY = touch.changedTouches[0].pageY;
|
|
|
25
|
+ $('body').on('touchmove', function(e) {
|
|
|
26
|
+ touch = e.originalEvent.touches[0] ||
|
|
|
27
|
+ e.originalEvent.changedTouches[0];
|
|
|
28
|
+ if (touch.pageX - startX > 10) {
|
|
|
29
|
+ $('body').off('touchmove');
|
|
|
30
|
+ } else if (touch.pageX - startX < -10) {
|
|
|
31
|
+ $('body').off('touchmove');
|
|
|
32
|
+ };
|
|
|
33
|
+ if (touch.pageY - startY > 10) {
|
|
|
34
|
+ direction = false;
|
|
|
35
|
+ } else if (touch.pageY - startY < -10) {
|
|
|
36
|
+ direction = true;
|
|
|
37
|
+ };
|
|
|
38
|
+ });
|
|
|
39
|
+}).on('touchend', function() {
|
|
|
40
|
+ $('body').off('touchmove');
|
|
|
41
|
+});
|
|
|
42
|
+
|
12
|
function couponAJAX(statu, page) {
|
43
|
function couponAJAX(statu, page) {
|
13
|
- return;
|
44
|
+ if (AjaxFlag) {
|
|
|
45
|
+ return;
|
|
|
46
|
+ }
|
|
|
47
|
+ AjaxFlag = 1;
|
14
|
loading.showLoadingMask();
|
48
|
loading.showLoadingMask();
|
15
|
$.ajax({
|
49
|
$.ajax({
|
16
|
type: 'POST',
|
50
|
type: 'POST',
|
|
@@ -24,6 +58,7 @@ function couponAJAX(statu, page) { |
|
@@ -24,6 +58,7 @@ function couponAJAX(statu, page) { |
24
|
$('#employ').append(data);
|
58
|
$('#employ').append(data);
|
25
|
window.rePosFooter();
|
59
|
window.rePosFooter();
|
26
|
loading.hideLoadingMask();
|
60
|
loading.hideLoadingMask();
|
|
|
61
|
+ AjaxFlag = 0;
|
27
|
}
|
62
|
}
|
28
|
});
|
63
|
});
|
29
|
}
|
64
|
}
|
|
@@ -43,7 +78,7 @@ $('.employ span').each(function(index) { |
|
@@ -43,7 +78,7 @@ $('.employ span').each(function(index) { |
43
|
|
78
|
|
44
|
|
79
|
|
45
|
function scrollHandler() {
|
80
|
function scrollHandler() {
|
46
|
- if ($(window).scrollTop() + $(window).height() > $('body').height() - 100) {
|
81
|
+ if (direction && ($(window).scrollTop() + $(window).height() > $('body').height() - 100)) {
|
47
|
page++;
|
82
|
page++;
|
48
|
couponAJAX(statu, page);
|
83
|
couponAJAX(statu, page);
|
49
|
return;
|
84
|
return;
|
|
@@ -54,4 +89,4 @@ $(window).scroll(function() { |
|
@@ -54,4 +89,4 @@ $(window).scroll(function() { |
54
|
window.requestAnimationFrame(scrollHandler);
|
89
|
window.requestAnimationFrame(scrollHandler);
|
55
|
});
|
90
|
});
|
56
|
|
91
|
|
57
|
-couponAJAX(statu, page); |
92
|
+couponAJAX(statu, page); |