|
@@ -0,0 +1,70 @@
|
|
|
+$(function () {
|
|
|
+ // 图片懒加载
|
|
|
+ $("img").lazyload();
|
|
|
+ // 显示区高度
|
|
|
+ let ch = document.documentElement.clientHeight || document.body.clientHeight,
|
|
|
+ lock = false,
|
|
|
+ // 加载 数据
|
|
|
+ currentPage = 3, totalPage = 3,
|
|
|
+ // 判断请求参数
|
|
|
+ url = window.location.href,
|
|
|
+ path = lxd.parseUrl(url).pathname
|
|
|
+ , reg = /(?<=\/xgk\/).*?(?=.html)/, special_report = !path.match(reg) ? '' : path.match(reg)[0];
|
|
|
+ $(window).scroll(function () {
|
|
|
+ if (lock) return false;
|
|
|
+ // 滑动区高度
|
|
|
+ let sh = document.documentElement.scrollHeight || document.body.scrollHeight,
|
|
|
+ // 滑动位置
|
|
|
+ st = document.documentElement.scrollTop || document.body.scrollTop,
|
|
|
+ c = sh * 1 - ch * 1 - st * 1;
|
|
|
+ if (c == 0 && currentPage <= totalPage) {
|
|
|
+ lock = true;
|
|
|
+ $(".my-loading").show();
|
|
|
+
|
|
|
+ data({ currentPage, special_report }).then(res => { totalPage = res.totalPage; currentPage++; lock = res.lock; $(".my-loading").hide(); })
|
|
|
+ }
|
|
|
+ if (c == 0 && currentPage > totalPage) {
|
|
|
+
|
|
|
+ $(".my-loading").html("已经没有可以加载的数据了").show();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // 加载数据
|
|
|
+ function data (data) {
|
|
|
+ return new Promise(resolve => {
|
|
|
+ $.ajax({
|
|
|
+ url: `http://api.gaokaoapp.net/exampaper/special/h/`,
|
|
|
+ data: {
|
|
|
+ ...data,
|
|
|
+ pageSize: 10
|
|
|
+ },
|
|
|
+ type: "get",
|
|
|
+ error: function (error) {
|
|
|
+ $(".my-loading").html("已经没有可以加载的数据了")
|
|
|
+ },
|
|
|
+ success: function (res) {
|
|
|
+ let { dataList, totalPage } = res.data;
|
|
|
+ let father = document.createDocumentFragment();
|
|
|
+ Array.from(dataList).forEach(
|
|
|
+ item => {
|
|
|
+ let str = `<a target="_blank" href="http://www.gaokaoapp.net/h_exam/${item.exampaper_id}.html" class="list-item">
|
|
|
+ <div class="item-img">
|
|
|
+ <img data-original="${item.thumbnail}"
|
|
|
+ src="../imgs/app.png"
|
|
|
+ alt="">
|
|
|
+ </div>
|
|
|
+ <div class="item-detail">
|
|
|
+ <div class="title">${item.title}</div>
|
|
|
+ <div class="time">${item.uk}<span>${item.create_time}</span></div>
|
|
|
+ </div>
|
|
|
+ </a>`
|
|
|
+ $(father).append(str);
|
|
|
+ }
|
|
|
+ )
|
|
|
+ $(".list").append(father);
|
|
|
+ $("img").lazyload();
|
|
|
+ resolve({ lock: false, totalPage })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+})
|