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