随着互联网时代的发展,web前端已经和后台数据挂钩,作为web前端仅仅不是只切图写写html,css 和简单js交互。
js code
$(function() { var page = 1; var discount = $('#discount'); var innerheight = window.innerheight; var timer2 = null; $.ajax({ url: '/lightapp/marketing/verify/apply/list?page=1', type: 'get', datatype: 'json', timeout: '1000', cache: 'false', success: function (data) { if (data.error_code === 0) { var arrtext = []; for (var i = 0, t; t = data.list[i++];) { arrtext.push(''); arrtext.push('' + t.title + ''); if (t.coupon_type == 1 ) { arrtext.push('金额:¥' + t.amount + '
'); } else { arrtext.push('优惠:' + t.amount + '
'); } arrtext.push('用户:s账户飒飒是是是啊啊12' + t.user_name +'' + '核销时间:' + t.use_time + '
'); arrtext.push('
'); } discount.html(arrtext.join('')); }; var ajax_getting = false; $(window).scroll(function() { cleartimeout(timer2); timer2 = settimeout(function() { var scrolltop = $(document.body).scrolltop(); var scrollheight = $('body').height(); var windowheight = innerheight; var scrollwhole = math.max(scrollheight - scrolltop - windowheight); if (scrollwhole < 100) { if (ajax_getting) { return false; } else { ajax_getting = true; } discount.append('
'); $('html,body').scrolltop($(window).height() + $(document).height()); page++; $.ajax({ url: '/lightapp/marketing/verify/apply/list?page=' + page, type: 'get', datatype: 'json', success: function (data) { if (data.error_code === 0) { var arrtext = []; for (var i = 0, t; t = data.list[i++];) { arrtext.push(''); arrtext.push('' + t.title + ''); if (t.coupon_type == 1 ) { arrtext.push('金额:¥' + t.amount + '
'); } else { arrtext.push('优惠:' + t.amount + '
'); }; arrtext.push('用户:账户飒111111111' + t.user_name +'' + '核销时间:' + t.use_time + '
'); arrtext.push('
'); } discount.append(arrtext.join('')); $(.load).remove(); } else { $(.load).remove(); discount.append('没有更多数据。
'); $(window).unbind('scroll'); }; ajax_getting = false; } }); }; $(.load).remove(); }, 200); }); if (data.error_code == 156006) { $('.coupon').html('出错啦!原因:未登录
') }; if (data.error_code == 156003) { $('.coupon').html('出错啦!原因:权限不足~请补充
') }; if (data.error_code == 156007) { $('.coupon').html('出错啦!原因:服务异常
') }; if (data.error_code == 511) { $('.coupon').html('出错啦!原因:账号未开通直达号
') }; if (data.error_code == 520) { $('.coupon').html('暂无核销记录
') } }, error: function (data) { } }) $(window).bind(orientationchange, function() { $('.sliders').css('left',$(window).width() / 2 +'px'); })})
以上所述就是本文的全部内容了,希望大家能够喜欢。