<template>
<div class="serverList">
<ul class="scrollModeBox" :style="{'-webkit-overflow-scrolling': scrollMode,height: wrapperHeight + 'px'}">
<mt-loadmore :top-method="loadTop" :bottom-method="loadBottom" :auto-fill="false" :bottom-all-loaded="allLoaded"
ref="loadmore" @top-status-change="handleTopChange" @bottom-status-change="handleBottomChange">
<li class="bbb" v-for="item in playList" :key="item.index" @click="toRepairDetails(item.pkBill)">
<p class="content">{{item.content}}</p>
<p class="time">上报日期:{{item.submitTime}}</p>
<p class="status red" v-if="item.billState === 'UNTREATED'">{{item.billStateValue}}</p>
<p class="status orange" v-if="item.billState === 'IN_PROGRESS'">{{item.billStateValue}}</p>
<p class="status orange" v-if="item.billState === 'SERVICE_COMPLETED'">{{item.billStateValue}}</p>
<p class="status blue2" v-if="item.billState === 'RETURN_VISIT_COMPLETED'">{{item.billStateValue}}</p>
</li> <div slot="top" class="mint-loadmore-top" style="text-align:center">
<span v-show="topStatus !== 'loading'" :class="{ 'is-rotate': topStatus === 'drop' }">↓</span>
<!--<mt-spinner v-show="topStatus == 'loading'" color="#26a2ff"></mt-spinner>-->
<span class="mint-loadmore-text">{{ topText }}</span>
</div>
<div slot="bottom" class="mint-loadmore-bottom">
<span v-show="bottomStatus !== 'loading'" :class="{ 'is-rotate': bottomStatus === 'drop' }">↑</span>
<!--<mt-spinner v-show="bottomStatus == 'loading'" color="#26a2ff"></mt-spinner>-->
<span class="mint-loadmore-text">{{ bottomText }}</span>
</div>
</mt-loadmore>
</ul> </div>
</template>
<script>
export default {
data() {
return {
playList: [],
pageNum: 1,
pageSize: 4,
topStatus: '',
bottomStatus: '',//底部上拉加载状态
allLoaded: false,
scrollMode: 'auto',
haveMore: true,
// 下拉刷新
topText: '',
topPullText: '下拉刷新',
topDropText: '释放更新',
topLoadingText: '加载中...',
bottomText: '',
bottomPullText: '上拉刷新',
bottomDropText: '释放更新',
bottomLoadingText: '加载中...',
wrapperHeight: 0,//容器高度 }
},
mounted() {
//获取屏幕宽度
this.wrapperHeight = document.documentElement.clientHeight;
// 报修记录
let vm = this;
vm.toServerList();
},
watch: {
topStatus(val) {
switch (val) {
case 'pull':
this.topText = this.topPullText;
break;
case 'drop':
this.topText = this.topDropText;
break;
case 'loading':
this.topText = this.topLoadingText;
break;
}
},
bottomStatus(val) {
switch (val) {
case 'pull':
this.bottomText = this.bottomPullText;
break;
case 'drop':
this.bottomText = this.bottomDropText;
break;
case 'loading':
this.bottomText = this.bottomLoadingText;
break;
}
}
},
methods: {
toServerList() {//跳转到投诉页面。
const _this = this;
_this.$Indicator.open({
text: '加载中',
spinnerType: 'fading-circle'
});
_this.postRequest('', {
pageNum: _this.pageNum,
pageSize: _this.pageSize,
}, function (data) {
_this.$Indicator.close();
if (data) {
_this.playList = data.datas;
// 判断上拉刷新,下拉加载.
if (_this.pageNum < data.pages) {
// 当页面相同时,最后一页弹窗提示。
_this.haveMore = true;
_this.pageNum = data.pageNum;
} else {
_this.haveMore = false;
}
if(_this.pageNum>1){
_this.isHaveMore(_this.haveMore)
}
_this.$nextTick(function () {
_this.scrollMode = 'touch';
})
} else {
// 此处需要加一个全局的类名,修改Toast 否则可能会报错
_this.$Toast({
message: '暂无记录',
duration: 2000,
className: 'noticeErrorToast'
});
} })
setTimeout(function () {
_this.$Indicator.close();
}, 5000); },
handleTopChange(status) {
this.topStatus = status;
},
handleBottomChange(status) {
this.bottomStatus = status;
},
loadTop() {
// 下拉刷新数据
this.handleTopChange("loading");//下拉时 改变状态码
this.pageNum = 1;
this.allLoaded = false;//下拉刷新时解除上拉加载的禁用
// 查询数据
this.toServerList();
this.$refs.loadmore.onTopLoaded();
},
loadBottom() {
// 上拉加载
this.more();
this.allLoaded = true;
this.handleBottomChange("loadingEnd");//数据加载完毕 修改状态码
this.$refs.loadmore.onBottomLoaded();
},
more() {
const _this = this;
_this.handleBottomChange("loading");//上拉时 改变状态码
_this.pageNum = parseInt(_this.pageNum) + 1;
console.log(this.pageNum, '1111')
this.toServerList();
},
isHaveMore(isHaveMore) {
this.allLoaded = true; // true 是禁止上拉加载;
if (isHaveMore) {
//isHaveMore 为true 有下一页,不禁止上拉
this.allLoaded = false
} else {
//false 没有下一页,禁止下拉,默认为true
this.$Toast({
message: '没有更多了',
duration: 2000,
className: 'noticeErrorToast'
});
this.allLoaded = true;
return;
}
},
toRepairDetails(id) {
this.$router.push({
path: '/complaindetails',
query: {id: id}
})
}
}
}
</script>
<style scoped>
/*状态的判断*/
.red {
color: red;
} .orange {
color: #F69203;
} .blue2 {
color: #0585C8;
} .yellow {
color: yellow;
} .current {
background-color: #fff;
color: #0585C8;
} .serverList {
width: 100%;
/* height: 100%; */
background-color: #f2f2f2;
padding-bottom: 20px;
} .serverList ul {
padding-top: 10px;
} .serverList ul li {
box-sizing: border-box;
background-color: #fff;
margin: 40px 26px 0 26px;
border-radius: 10px;
padding: 34px 23px;
} /*待处理状态*/
.serverList ul li .status {
font-size: 28px;
text-align: right;
height: 60px;
line-height: 60px;
padding-top: 8px;
box-sizing: border-box;
padding-right: 20px;
} /*报修内容*/
.serverList ul li .content {
font-size: 28px;
width: 550px;
color: #333;
text-align: left;
margin-left: 30px;
line-height: 48px;
} /*上报时间*/
.serverList ul li .time {
text-align: left;
font-size: 24px;
color: #999;
margin: 10px 0 0 30px;
padding-bottom: 20px;
} .load-more-normal {
text-align: center;
line-height: 60px;
} .load-more-hide {
height: 0;
}
</style>

  

在vue中运用mt-loadmore 实现上拉加载,下拉刷新(完整源码)的更多相关文章

  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. 微信小程序上拉加载下拉刷新

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

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

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

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

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

  7. 基于better-scroll封装一个上拉加载下拉刷新组件

    1.起因 上拉加载和下拉刷新在移动端项目中是很常见的需求,遂自己便基于better-scroll封装了一个下拉刷新上拉加载组件. 2.过程 better-scroll是目前比较好用的开源滚动库,提供很 ...

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

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

  9. zepto.js + iscroll.js上拉加载 下拉加载的 移动端 新闻列表页面

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name ...

  10. 利用iscroll实现上拉加载下拉刷新

    1.首先引用isScroll插件 说明:页面加载时初始化isScroll,然后调用pullDownAction()和pullUpAction(),每次切换tab时,只需要对pullDownAction ...

随机推荐

  1. 2、Jmeter测试

    一.测试流程 1.添加本次测试计划 (右键-->添加-->Threads(Users)-->线程组) 2.设置线程数 (所谓线程数就是并发用户数) 3.在线程组内添加请求(右键--& ...

  2. Jenkins构建触发器(定时构建项目)

    如上图所示,Jenkins通常通过点击“立即构建”来进行手动构建项目,其实也可以使用配置中的 Poll SCM和Build periodically来进行定时自动构建项目: 在“配置”——>“构 ...

  3. Java性能调优工具(Linux)

    为了能准确获得程序的性能信息,需要使用各种辅助工具.以下主要介绍了Linux上关于Java的系统性能分析工具,掌握这些工具,对于性能瓶颈定位.系统故障排查都有帮助. 1.top命令 [root@loc ...

  4. git clone的低级错误

    犯了一个低级错误: server ip: 192.168.40.41 有一个git账户 所有的git仓库都在/home/git仓库下 比如/home/git/u-boot-2018.07-fmxx.g ...

  5. 解决Debug JDK source 无法查看局部变量的问题方案

    一.问题阐述首先我们要明白JDK source为什么在debug的时候无法观察局部变量,因为在jdk中,sun对rt.jar中的类编译时,去除了调试信息,这样在eclipse中就不能看到局部变量的值. ...

  6. LightOJ 1079 Just another Robbery (01背包)

    题目链接 题意:Harry Potter要去抢银行(wtf???),有n个银行,对于每个银行,抢的话,能抢到Mi单位的钱,并有pi的概率被抓到.在各个银行被抓到是独立事件.总的被抓到的概率不能超过P. ...

  7. SpringBoot自定义Jackson配置

    为了在SpringBoot工程中集中解决long类型转成json时JS丢失精度问题和统一设置常见日期类型序列化格式,我们可以自定义Jackson配置类,具体如下: import com.fasterx ...

  8. javascrip的数组扁平化

    扁平化 数组的扁平化,就是将一个嵌套多层的数组 array (嵌套可以是任何层数)转换为只有一层的数组. 举个例子,假设有个名为 flatten 的函数可以做到数组扁平化,效果就会如下: var ar ...

  9. Influxdb根据配置文件启动(Influxdb的数据存储)

    1.在Influxdb文件夹下建立一个bat文件 2.文件内容如下: @echo offSETLOCAL :: 获取当前批处理所在路径SET InfluxdP==%~dp0 :: 开启influxdb ...

  10. Codeforces 830A. Office Keys (贪心二分 or DP)

    原题链接:http://codeforces.com/contest/830/problem/A 题意:在一条数轴上分别有n个人和k把钥匙(n<=k),以及一个目的地,每个人要各自拿到一个钥匙后 ...