瀑布流下拉刷新

知识点:使用瀑布流,实现数据列表的下拉刷新

 (1)引入waterfall.js,jquery.imageload.js,handlebars.js三个js文件

 (2)前端页面

<!-- 数据列表 -->

<div class="box" style=" border-top-width: 0px;margin-bottom: 0px;">

<div id="waterfallContainer" class="box-body" style="padding-bottom: 0px;padding-top: 0px;">

</div>


</div>

<script type="text/x-handlebars-template" id="waterfall-tpl">
{{#waterfall data}}
<div class="col-md-3">
<div class="thumbnail">
<div class="videobottom">
<img src={{adv_url}} οnerrοr="nofindimg(event)" height="135px" width="240px" style="margin-top: -130px;margin-left: -5px;">
<p>
<span class="{{adv_type}}" aria-hidden="true"></span>
<span style="color: black">{{adv_time}}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span style="margin-right: 5px">{{adv_resolving_power}}</span>
<span style="color: black">{{adv_size}}</span>
</p>

</div>
</div>
<div class="centerarea">
<span class="pull-left">上传日期:{{create_time}} </span>
<span class="pull-right"> {{file_type}}</span>
</div>
<div style="text-align: center;margin-top: 40px">
<input type="checkbox" name="checkbox" value={{id}}><span id="{{id}}" οnclick="updatefilename(this)" data-fileid="{{id}}">{{file_name}}</span>
</div>
</div>
{{/waterfall}}
</script>

<script>
//默认图片显示
function nofindimg(event) {
var img = event.srcElement||event.target;

img.src = "${pageContext.request.contextPath}/static/img/spring.png";

img.onerror = null;
}

//下拉刷新,每一页,ajax请求后台接口
$(document).ready(function () {
$('#waterfallContainer').waterfall({
debug: false,
path: function (page) {
var url="${pageContext.request.contextPath}/screen/adverlist/12/"+page+"?1=1";
if($("#name").val() !=null && $("#name").val() !=""){
url+="&name="+$("#name").val();
}
if($("input[name='adv']:checked").val() !=null && $("input[name='adv']:checked").val() !=""){
url+="&filetype="+$("input[name='adv']:checked").val();
}
return url;
}
});

});

//js工具里的方法
Handlebars.registerHelper('waterfall', function (result, options) {
var items = result;
var out = '';
for (var i = 0; i < items.length; i++) {
out += options.fn(items[i])
}
return out;
});

function find() {
$('#waterfallContainer').waterfall('removeItems', 'div.col-md-3');
$('#waterfallContainer').waterfall('scroll');
}
 
</script>

(3)后台接口
/**
* 查询所有广告信息
*
* @return
*/
@RequestMapping("/adverlist/{total}/{page}")
@ResponseBody
public Object advwaterfalllist(@PathVariable("total") int total,@PathVariable("page") Integer page, HttpServletRequest request)
{
AdvList advlist=new AdvList();
PageData pageData=new PageData(request);
pageData.put("page",(page - 1) * total);
pageData.put("total",total);
List<PageData> adverlist=screenAdvService.getadverList(pageData);
advlist.setData(adverlist);
advlist.setTotal(5);
return advlist;
}


源码demo:https://github.com/shuaishuaihand/fileupload.git
 


 

转载于:https://www.cnblogs.com/shuaifing/p/9582596.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
UniApp的瀑布流布局(通常用于图片或卡片的瀑布式展示)和下拉刷新功能是其组件库中常用的设计模式,它们旨在提供流畅的用户体验,特别是在大量数据加载时。"uni瀑布流"通常指的是使用`uni-swiper`或自定义滚动组件结合`uni-fetcher`进行数据分页的布局,而"下拉刷新"则是一个常见的交互设计,让用户知道内容正在更新。 **Uni瀑布流下拉刷新简介:** 1. **uni-swiper**:这是一个基于原生swiper的封装,支持横向或竖向滑动,可以设置为瀑布流模式,通过改变`loop`和`direction`属性来实现。 2. **uni-fetcher**:这个组件用于管理页面滚动过程中的数据请求。当用户滚动到底部,fetcher会检测到并自动触发数据加载,加载更多的内容添加到列表末尾,形成瀑布流效果。 3. **下拉刷新**:用户在列表顶部拉动时,通常会显示一个刷新指示器(比如旋转的圈圈或波浪线)。当用户松开手指,会发送一个请求到服务器获取最新的数据,然后更新列表内容。 **实现步骤:** - 配置uni-swiper或自定义滚动组件,设置自动滚动和分页功能。 - 使用uni-fetcher监控滚动事件,当接近底部时发起请求。 - 设计下拉刷新动画,使用`v-loading`或自定义视图展示加载状态。 - 当新数据返回后,更新列表,并可能清除当前的刷新指示器。 **相关问题--:** 1. UniApp的哪些库可以帮助实现瀑布流布局? 2. 如何在uni-app中配置uni-swiper以支持瀑布流下拉刷新? 3. uni-fetcher如何与uni-swiper配合,实现智能的数据加载?

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值