1.引入css、js

<link rel="stylesheet" href=" ${pageContext.request.contextPath}/dist/dropload.css">

<script src="${pageContext.request.contextPath}/dist/dropload.min.js"></script>

2、

  $('.list').dropload({
scrollArea : window,
domUp : {
domClass : 'dropload-up',
domRefresh : '<div class="dropload-refresh">↓下拉刷新</div>',
domUpdate : '<div class="dropload-update">↑释放更新</div>',
domLoad : '<div class="dropload-load"><span class="loading"></span>加载中...</div>'
},
domDown : {
domClass : 'dropload-down',
domRefresh : '<div class="dropload-refresh">↑上拉加载更多</div>',
domLoad : '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
domNoData : '<div class="dropload-noData">暂无数据 </div>'
},
loadUpFn : function(me){
var reqjson = {
"pageNum":1,
"pageSize":pageSize,
};
$.ajax({
type : "GET",
dataType : "JSON",
cache:false,
url : "mall/product",
data : reqjson,
beforeSend: function(request) {
request.setRequestHeader("token", localStorage.getItem("token"));
},
success : function(result) {
var html='';
$.each(result.data, function(name, value) {
html+='<li>';
html+='<a href="mall/product/'+value.id+'">';
html+='<div class="imag"><img src="http://pic.91peini.com/'+value.image+'" alt="'+value.proName+'" ><div class="price">¥'+Validate.isMoney(value.showPrice)+'</div></div>';
html+='<div class="inf">';
html+='<h6>'+value.proName+'</h6>';
html+='<p><span>月销'+value.sellCount+'笔</span></p>';
html+='</div>';
html+='</a>';
html+='</li>';
}); // 为了测试,延迟1秒加载
setTimeout(function(){
$("#productlist").html(html);
// 每次数据加载完,必须重置
me.resetload();
// 重置页数,重新获取loadDownFn的数据
pageNum = 1;
// 解锁loadDownFn里锁定的情况
me.unlock();
me.noData(false);
},1000);
$(".banner").width($(window).width());
var wid=$(".banner").width();
$(".banner").height(wid/2.2);
var iwid=$("#productlist li div.imag").width();
$("#productlist li div.imag").height(iwid)
var swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
paginationClickable: true,
spaceBetween: 30,
centeredSlides: true,
autoplay: 2500,
autoplayDisableOnInteraction: false
});
}, error: function(xhr, type){
// alert('Ajax error!');
// 即使加载出错,也得重置
me.resetload();
}
})
},
loadDownFn : function(me){
// 拼接HTML
var result = '';
pageNum++; var reqjson = {
"pageNum":pageNum,
"pageSize":pageSize,
}; $.ajax({
type : "GET",
dataType : "JSON",
cache:false,
url : "mall/product",
data : reqjson,
beforeSend: function(request) {
request.setRequestHeader("token", localStorage.getItem("token"));
},
success : function(result) {
var html='';
if(result.data.length>0){
$.each(result.data, function(name, value) {
html+='<li>';
html+='<a href="mall/product/'+value.id+'">';
html+='<div class="imag"><img src="http://pic.91peini.com/'+value.image+'" alt="'+value.proName+'" ><div class="price">¥'+Validate.isMoney(value.price)+'</div></div>';
html+='<div class="inf">';
html+='<h6>'+value.proName+'</h6>';
html+='<p><span>月销'+value.sellCount+'笔</span></p>';
html+='</div>';
html+='</a>';
html+='</li>';
});
}else{
// 锁定
me.lock();
// 无数据
me.noData();
}
// 为了测试,延迟1秒加载
setTimeout(function(){
// 插入数据到页面,放到最后面
$("#productlist").append(html);
// 每次数据插入,必须重置
me.resetload();
},1000);
$(".banner").width($(window).width());
var wid=$(".banner").width();
$(".banner").height(wid/2.2);
var iwid=$("#productlist li div.imag").width();
$("#productlist li div.imag").height(iwid)
var swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
paginationClickable: true,
spaceBetween: 30,
centeredSlides: true,
autoplay: 2500,
autoplayDisableOnInteraction: false
});
}, error: function(xhr, type){
// alert('Ajax error!');
// 即使加载出错,也得重置
me.resetload();
}
})
},
threshold : 50
});

  

dropload上拉加载 下拉刷新的更多相关文章

  1. Vue mint ui用在消息页面上拉加载下拉刷新loadmore 标记

    之前总结过一个页面存在多个下拉加载的处理方式,今天再来说一下在消息页面的上拉加载和下拉刷新,基本上每个app都会有消息页面,会遇到这个需求 需求:每次加载十条数据,上拉加载下拉刷新,并且没有点击查看过 ...

  2. 上拉加载下拉刷新控件WaterRefreshLoadMoreView

    上拉加载下拉刷新控件WaterRefreshLoadMoreView 效果: 源码: // // SRSlimeView // @author SR // Modified by JunHan on ...

  3. RecyclerView 上拉加载下拉刷新

    RecyclerView 上拉加载下拉刷新 <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/teach_s ...

  4. APICloud上啦加载下拉刷新模块

    apicloud有自带的上啦加载下拉刷新,当让也可以用第三方或者在模块库里面找一个使用 一.下拉刷新,一下代码写在 apiready = function (){} 里面 apiready = fun ...

  5. 微信小程序上拉加载下拉刷新

    微信小程序实现上拉加载下拉刷新 使用小程序默认提供方法. (1). 在xxx.json 中开启下拉刷新,需要设置backgroundColor,或者是backgroundTextStyle ,因为加载 ...

  6. mui scroll和上拉加载/下拉刷新

    mui中 scroll和上拉加载/下拉刷新同时存在会出现两个滚动条 把/*   */ /* //mui页面鼠标拖动代码: mui('.mui-scroll-wrapper').scroll({ dec ...

  7. SwipeRefreshLayout实现上拉加载下拉刷新

    package com.example.swiperefreshlayoutdemo; import java.util.ArrayList;import java.util.HashMap; imp ...

  8. MJRefresh(上拉加载下拉刷新)

    整理自:https://github.com/CoderMJLee/MJRefresh#%E6%94%AF%E6%8C%81%E5%93%AA%E4%BA%9B%E6%8E%A7%E4%BB%B6%E ...

  9. Flutter上拉加载下拉刷新---flutter_easyrefresh

    前言 Flutter默认不支持上拉加载,下拉刷新也仅仅支持Material的一种样式.Android开发使用过SmartRefreshLayout的小伙伴都知道这是一个强大的刷新UI库,集成了很多出色 ...

随机推荐

  1. ZBrush中平滑笔刷介绍

    平滑笔刷在ZBrush®中的使用颇多,它可以在ZBrush®模型的多层细分下工作,并且能够控制对模型的平滑效果,而且还能将模型的细节完整保留.默认情况下,按住Shift键就会切换到平滑笔刷,根据调整不 ...

  2. 阿里云数据库MySQL版快速上手!

    MySQL是全球最受欢迎的开源数据库,其在各Web应用中均有广泛部署.阿里云数据库MySQL版基于Alibaba的MySQL源码分支,经过双11高并发.大数据量的考验,拥有优良的性能和吞吐量.除此之外 ...

  3. Codeforces Round #506 (Div. 3) D-F

    Codeforces Round #506 (Div. 3) (中等难度) 自己的做题速度大概只尝试了D题,不过TLE D. Concatenated Multiples 题意 数组a[],长度n,给 ...

  4. libvirtd.service

    [root@kvm-server ~]# systemctl status libvirtd.service ● libvirtd.service - Virtualization daemon Lo ...

  5. poj 2288 Islands and Bridges (状压dp+Tsp问题)

    这道题千辛万苦啊! 这道题要涉及到当前点和前面两个点,那就设dp[state][i][j]为当前状态为state,当前点为i,前一个点为j 这个状态表示和之前做炮兵那题很像,就是涉及到三个点时,就多设 ...

  6. sql 语句中的 (+) 是什么意思?

    在select语句中(+)指的是外连接,是连接查询的一种方法.例:select t1.*,t2.* from dept t1,emp t2 where t1.deptno=t2.deptno(+);其 ...

  7. nginx配置修改

    改变nginx配置想让它生效而不停止服务,如下两种方式都可以:1) 检查nginx配置: nginx -t; 配置重载: nginx -s reload2) 检查nginx配置: nginx -t; ...

  8. NYIST 1030 Yougth's Game[Ⅲ]

    Yougth's Game[Ⅲ]时间限制:3000 ms | 内存限制:65535 KB难度:4 描述有一个长度为n的整数序列,A和B轮流取数,A先取,每次可以从左端或者右端取一个数,所有数都被取完时 ...

  9. NYIST 860 又见01背包

    又见01背包时间限制:1000 ms | 内存限制:65535 KB难度:3 描述 有n个重量和价值分别为wi 和 vi 的 物品,从这些物品中选择总重量不超过 W 的物品,求所有挑选方案中物品价值总 ...

  10. ubuntu设置PATH

    试了好多遍,多无效.. 最后在/etc/enviroment下设置才有效. 不过让有一些未解问题 我使用sudo su 进入到root用户权限,设置完成的. 重新使用sudo -s进入root用户权限 ...