|
|
// 不要使用es6
|
|
|
'use strict';
|
|
|
|
|
|
require('home/_coupons.css');
|
|
|
var $ = require('yoho-jquery'),
|
|
|
Hammer = require('yoho-hammer'),
|
|
|
ellipsis = require('yoho-mlellipsis'),
|
|
|
loading = require('../plugin/loading');
|
|
|
fastclick = require('yoho-fastclick'),
|
|
|
ellipsis = require('yoho-mlellipsis');
|
|
|
|
|
|
var employ,
|
|
|
var $employ = $('#employ'),
|
|
|
$employ2 = $('#employ2'),
|
|
|
statu = 0,
|
|
|
page = 1,
|
|
|
dic = {},
|
|
|
AjaxFlag = 0; // 防止重复请求
|
|
|
|
|
|
require('../common');
|
|
|
ellipsis.init();
|
|
|
|
|
|
// 防止重复请求
|
|
|
AjaxFlag = 0;
|
|
|
dic[statu + '_' + page] = true;
|
|
|
fastclick.attach(document.body);
|
|
|
|
|
|
var couponAJAX = function(statu, page) {
|
|
|
if (AjaxFlag) {
|
|
|
if (AjaxFlag || dic[statu + '_' + page]) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
var employDom = statu === 0 ? $employ : $employ2;
|
|
|
|
|
|
AjaxFlag = 1;
|
|
|
loading.showLoadingMask();
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/home/coupons',
|
...
|
...
|
@@ -28,55 +35,50 @@ var couponAJAX = function(statu, page) { |
|
|
page: page
|
|
|
},
|
|
|
success: function(data) {
|
|
|
dic[statu + '_' + page] = true; // tab切换时,防止频繁请求
|
|
|
if ($(data).find('.null').html()) {
|
|
|
page === 1 && $('#employ').append($(data).find('.null'));
|
|
|
if (page === 1) {
|
|
|
employDom.append($(data).find('.null'));
|
|
|
}
|
|
|
AjaxFlag = 1;
|
|
|
window.rePosFooter();
|
|
|
loading.hideLoadingMask();
|
|
|
return;
|
|
|
}
|
|
|
if (!$(data).find('.employ-main').html()) {
|
|
|
AjaxFlag = 1;
|
|
|
window.rePosFooter();
|
|
|
loading.hideLoadingMask();
|
|
|
return;
|
|
|
}
|
|
|
$('#employ').append($(data).find('.employ-main'));
|
|
|
window.rePosFooter();
|
|
|
loading.hideLoadingMask();
|
|
|
employDom.append($(data).find('.employ-main'));
|
|
|
AjaxFlag = 0;
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
var scrollHandler = function() {
|
|
|
if ($(window).scrollTop() + $(window).height() > $('body').height() - 100) {
|
|
|
page++;
|
|
|
couponAJAX(statu, page);
|
|
|
return;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
|
|
|
require('../common');
|
|
|
|
|
|
ellipsis.init();
|
|
|
|
|
|
$('.yoho-footer').css('border-top', '1px solid #e0e0e0');
|
|
|
$('.employ span').each(function(index) {
|
|
|
employ = new Hammer($('.employ span')[index]);
|
|
|
employ.on('tap', function(e) {
|
|
|
$('.employ span').each(function(index, el) {
|
|
|
$(el).on('click', function() {
|
|
|
$('.employ span').removeClass('active').eq(index).addClass('active');
|
|
|
$('#employ').html(' ');
|
|
|
if (index === 0) {
|
|
|
$employ.removeClass('hide');
|
|
|
$employ2.addClass('hide');
|
|
|
} else {
|
|
|
$employ.addClass('hide');
|
|
|
$employ2.removeClass('hide');
|
|
|
}
|
|
|
|
|
|
statu = index;
|
|
|
page = 1;
|
|
|
AjaxFlag = 0;
|
|
|
status === 1 && $('#employ').empty();
|
|
|
couponAJAX(statu, page);
|
|
|
window.rePosFooter();
|
|
|
});
|
|
|
});
|
|
|
|
|
|
var scrollHandler = function() {
|
|
|
if ($(window).scrollTop() + $(window).height() > $('body').height() - 100) {
|
|
|
page++;
|
|
|
couponAJAX(statu, page);
|
|
|
return;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
$(window).scroll(function() {
|
|
|
window.requestAnimationFrame(scrollHandler);
|
|
|
}); |
...
|
...
|
|