Blame view

static/js/me/coupons.js 1.28 KB
uedxwg authored
1
var $ = require('jquery'),
uedxwg authored
2
    Hammer = require('yoho.hammer'),
3 4 5 6 7 8
    ellipsis = require('mlellipsis'),
    loading = require('../plugin/loading');

var employ,
    statu = 0,
    page = 1;
uedxwg authored
9
uedxwg authored
10 11
ellipsis.init();
12 13 14 15 16 17 18 19 20 21 22
function couponAJAX(statu, page) {
    loading.showLoadingMask();
    $.ajax({
        type: 'POST',
        url: '/home/couponData',
        dataType: 'html',
        data: {
            status: statu,
            page: page
        },
        success: function(data) {
23
            $('#employ').append(data);
24 25 26
            window.rePosFooter();
            loading.hideLoadingMask();
        }
uedxwg authored
27
    });
28
}
uedxwg authored
29
uedxwg authored
30
$('.yoho-footer').css('border-top', '1px solid #e0e0e0');
uedxwg authored
31 32 33 34
$('.employ span').each(function(index) {
    employ = new Hammer($('.employ span')[index]);
    employ.on('tap', function(e) {
        $('.employ span').removeClass('active').eq(index).addClass('active');
35 36 37 38
        $('#employ').html(' ');
        statu = index;
        page = 1;
        couponAJAX(statu, page);
39
        window.rePosFooter();
uedxwg authored
40
    });
41 42
});
梁志锋 authored
43 44
function scrollHandler() {
    if ($(window).scrollTop() + $(window).height() > $('body').height() - 100) {
45 46 47 48
        page++;
        couponAJAX(statu, page);
        return;
    }
梁志锋 authored
49
}
50
梁志锋 authored
51 52
$(window).scroll(function() {
    window.requestAnimationFrame(scrollHandler);
53
});
梁志锋 authored
54
55
couponAJAX(statu, page);