installment.page.js
1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
var $ = require('yoho-jquery'),
ellipsis = require('yoho-mlellipsis'),
tip = require('../plugin/tip'),
loading = require('../plugin/loading');
var winH = $(window).height(),
$installmentOnly = $('.installment-only'),
searching = false,
page = 0;
ellipsis.init();
function search() {
if (searching) {
return;
}
searching = true;
loading.showLoadingMask();
$.ajax({
type: 'GET',
url: '/product/recom/maylike?gender=1,3',
data: {
page: page + 1
},
success: function(data) {
if (data === '') {
loading.hideLoadingMask();
} else {
searching = false;
$('#goods-list').append(data);
loading.hideLoadingMask();
page++;
$('.good-detail-text .name').each(function() {
var $this = $(this),
$title = $this.find('a');
$title[0].mlellipsis(2);
});
}
},
error: function() {
tip.show('网络断开连接了~');
searching = false;
loading.hideLoadingMask();
}
});
}
function scrollHandler() {
if ($(window).scrollTop() + winH >= $(document).height() - 200) {
search();
}
}
// srcoll to load more
$(window).scroll(function() {
if ($installmentOnly.length > 0) {
window.requestAnimationFrame(scrollHandler);
}
});
if ($installmentOnly.length > 0) {
$('.installment-page').css({
background: '#efefef'
});
search();
}
if ($('.installment-bg').length > 0) {
$('body').css({
background: '#efefef'
});
}