1. <template>
  2. <div class="serverList">
  3. <ul class="scrollModeBox" :style="{'-webkit-overflow-scrolling': scrollMode,height: wrapperHeight + 'px'}">
  4. <mt-loadmore :top-method="loadTop" :bottom-method="loadBottom" :auto-fill="false" :bottom-all-loaded="allLoaded"
  5. ref="loadmore" @top-status-change="handleTopChange" @bottom-status-change="handleBottomChange">
  6. <li class="bbb" v-for="item in playList" :key="item.index" @click="toRepairDetails(item.pkBill)">
  7. <p class="content">{{item.content}}</p>
  8. <p class="time">上报日期:{{item.submitTime}}</p>
  9. <p class="status red" v-if="item.billState === 'UNTREATED'">{{item.billStateValue}}</p>
  10. <p class="status orange" v-if="item.billState === 'IN_PROGRESS'">{{item.billStateValue}}</p>
  11. <p class="status orange" v-if="item.billState === 'SERVICE_COMPLETED'">{{item.billStateValue}}</p>
  12. <p class="status blue2" v-if="item.billState === 'RETURN_VISIT_COMPLETED'">{{item.billStateValue}}</p>
  13. </li>
  14.  
  15. <div slot="top" class="mint-loadmore-top" style="text-align:center">
  16. <span v-show="topStatus !== 'loading'" :class="{ 'is-rotate': topStatus === 'drop' }"></span>
  17. <!--<mt-spinner v-show="topStatus == 'loading'" color="#26a2ff"></mt-spinner>-->
  18. <span class="mint-loadmore-text">{{ topText }}</span>
  19. </div>
  20. <div slot="bottom" class="mint-loadmore-bottom">
  21. <span v-show="bottomStatus !== 'loading'" :class="{ 'is-rotate': bottomStatus === 'drop' }"></span>
  22. <!--<mt-spinner v-show="bottomStatus == 'loading'" color="#26a2ff"></mt-spinner>-->
  23. <span class="mint-loadmore-text">{{ bottomText }}</span>
  24. </div>
  25. </mt-loadmore>
  26. </ul>
  27.  
  28. </div>
  29. </template>
  30. <script>
  31. export default {
  32. data() {
  33. return {
  34. playList: [],
  35. pageNum: 1,
  36. pageSize: 4,
  37. topStatus: '',
  38. bottomStatus: '',//底部上拉加载状态
  39. allLoaded: false,
  40. scrollMode: 'auto',
  41. haveMore: true,
  42. // 下拉刷新
  43. topText: '',
  44. topPullText: '下拉刷新',
  45. topDropText: '释放更新',
  46. topLoadingText: '加载中...',
  47. bottomText: '',
  48. bottomPullText: '上拉刷新',
  49. bottomDropText: '释放更新',
  50. bottomLoadingText: '加载中...',
  51. wrapperHeight: 0,//容器高度
  52.  
  53. }
  54. },
  55. mounted() {
  56. //获取屏幕宽度
  57. this.wrapperHeight = document.documentElement.clientHeight;
  58. // 报修记录
  59. let vm = this;
  60. vm.toServerList();
  61. },
  62. watch: {
  63. topStatus(val) {
  64. switch (val) {
  65. case 'pull':
  66. this.topText = this.topPullText;
  67. break;
  68. case 'drop':
  69. this.topText = this.topDropText;
  70. break;
  71. case 'loading':
  72. this.topText = this.topLoadingText;
  73. break;
  74. }
  75. },
  76. bottomStatus(val) {
  77. switch (val) {
  78. case 'pull':
  79. this.bottomText = this.bottomPullText;
  80. break;
  81. case 'drop':
  82. this.bottomText = this.bottomDropText;
  83. break;
  84. case 'loading':
  85. this.bottomText = this.bottomLoadingText;
  86. break;
  87. }
  88. }
  89. },
  90. methods: {
  91. toServerList() {//跳转到投诉页面。
  92. const _this = this;
  93. _this.$Indicator.open({
  94. text: '加载中',
  95. spinnerType: 'fading-circle'
  96. });
  97. _this.postRequest('', {
  98. pageNum: _this.pageNum,
  99. pageSize: _this.pageSize,
  100. }, function (data) {
  101. _this.$Indicator.close();
  102. if (data) {
  103. _this.playList = data.datas;
  104. // 判断上拉刷新,下拉加载.
  105. if (_this.pageNum < data.pages) {
  106. // 当页面相同时,最后一页弹窗提示。
  107. _this.haveMore = true;
  108. _this.pageNum = data.pageNum;
  109. } else {
  110. _this.haveMore = false;
  111. }
  112. if(_this.pageNum>1){
  113. _this.isHaveMore(_this.haveMore)
  114. }
  115. _this.$nextTick(function () {
  116. _this.scrollMode = 'touch';
  117. })
  118. } else {
    // 此处需要加一个全局的类名,修改Toast 否则可能会报错
  119. _this.$Toast({
  120. message: '暂无记录',
  121. duration: 2000,
  122. className: 'noticeErrorToast'
  123. });
  124. }
  125.  
  126. })
  127. setTimeout(function () {
  128. _this.$Indicator.close();
  129. }, 5000);
  130.  
  131. },
  132. handleTopChange(status) {
  133. this.topStatus = status;
  134. },
  135. handleBottomChange(status) {
  136. this.bottomStatus = status;
  137. },
  138. loadTop() {
  139. // 下拉刷新数据
  140. this.handleTopChange("loading");//下拉时 改变状态码
  141. this.pageNum = 1;
  142. this.allLoaded = false;//下拉刷新时解除上拉加载的禁用
  143. // 查询数据
  144. this.toServerList();
  145. this.$refs.loadmore.onTopLoaded();
  146. },
  147. loadBottom() {
  148. // 上拉加载
  149. this.more();
  150. this.allLoaded = true;
  151. this.handleBottomChange("loadingEnd");//数据加载完毕 修改状态码
  152. this.$refs.loadmore.onBottomLoaded();
  153. },
  154. more() {
  155. const _this = this;
  156. _this.handleBottomChange("loading");//上拉时 改变状态码
  157. _this.pageNum = parseInt(_this.pageNum) + 1;
  158. console.log(this.pageNum, '1111')
  159. this.toServerList();
  160. },
  161. isHaveMore(isHaveMore) {
  162. this.allLoaded = true; // true 是禁止上拉加载;
  163. if (isHaveMore) {
  164. //isHaveMore 为true 有下一页,不禁止上拉
  165. this.allLoaded = false
  166. } else {
  167. //false 没有下一页,禁止下拉,默认为true
  168. this.$Toast({
  169. message: '没有更多了',
  170. duration: 2000,
  171. className: 'noticeErrorToast'
  172. });
  173. this.allLoaded = true;
  174. return;
  175. }
  176. },
  177. toRepairDetails(id) {
  178. this.$router.push({
  179. path: '/complaindetails',
  180. query: {id: id}
  181. })
  182. }
  183. }
  184. }
  185. </script>
  186. <style scoped>
  187. /*状态的判断*/
  188. .red {
  189. color: red;
  190. }
  191.  
  192. .orange {
  193. color: #F69203;
  194. }
  195.  
  196. .blue2 {
  197. color: #0585C8;
  198. }
  199.  
  200. .yellow {
  201. color: yellow;
  202. }
  203.  
  204. .current {
  205. background-color: #fff;
  206. color: #0585C8;
  207. }
  208.  
  209. .serverList {
  210. width: 100%;
  211. /* height: 100%; */
  212. background-color: #f2f2f2;
  213. padding-bottom: 20px;
  214. }
  215.  
  216. .serverList ul {
  217. padding-top: 10px;
  218. }
  219.  
  220. .serverList ul li {
  221. box-sizing: border-box;
  222. background-color: #fff;
  223. margin: 40px 26px 0 26px;
  224. border-radius: 10px;
  225. padding: 34px 23px;
  226. }
  227.  
  228. /*待处理状态*/
  229. .serverList ul li .status {
  230. font-size: 28px;
  231. text-align: right;
  232. height: 60px;
  233. line-height: 60px;
  234. padding-top: 8px;
  235. box-sizing: border-box;
  236. padding-right: 20px;
  237. }
  238.  
  239. /*报修内容*/
  240. .serverList ul li .content {
  241. font-size: 28px;
  242. width: 550px;
  243. color: #333;
  244. text-align: left;
  245. margin-left: 30px;
  246. line-height: 48px;
  247. }
  248.  
  249. /*上报时间*/
  250. .serverList ul li .time {
  251. text-align: left;
  252. font-size: 24px;
  253. color: #999;
  254. margin: 10px 0 0 30px;
  255. padding-bottom: 20px;
  256. }
  257.  
  258. .load-more-normal {
  259. text-align: center;
  260. line-height: 60px;
  261. }
  262.  
  263. .load-more-hide {
  264. height: 0;
  265. }
  266. </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. node npm vue.js 笔记

    cnpm 下载包的速度更快一些. 地址:http://npm.taobao.org/ 安装cnpm: npm install -g cnpm --registry=https://registry.n ...

  2. mysql查询每个部门/班级前几名

    Employee 表包含所有员工信息,每个员工有其对应的 Id, salary 和 department Id . +----+-------+--------+--------------+ | I ...

  3. 【Java学习笔记】线程安全的单例模式及双重检查锁—个人理解

    搬以前写的博客[2014-12-30 16:04] 在web应用中服务器面临的是大量的访问请求,免不了多线程程序,但是有时候,我们希望在多线程应用中的某一个类只能新建一个对象的时候,就会遇到问题. 首 ...

  4. springboot 整合Druid

    Druid连接池监控配置 1) 引入依赖 <!-- https://mvnrepository.com/artifact/com.alibaba/druid --> <depende ...

  5. 对Promise的研究3

    Promise.race() Promise.race方法同样是将多个 Promise 实例,包装成一个新的 Promise 实例. const p = Promise.race([p1, p2, p ...

  6. VM虚拟机中MAC OS调整磁盘大小

    1.打开终端,输入diskutil list: 2.从显示的列表中找到你需要扩展的分区(是分区不是磁盘,分区的ID一般为diskXsX): 3.然后输入 diskutil resizeVolume d ...

  7. Jenkines邮件中添加图片

    1.在Jenkins的邮件插件 Email-ext中的Default Content内容编写html文件,简单模板如下: <html>  <head>  </head&g ...

  8. 变量类型,-数据类型(值类型,引用类型)uint 不有存负数,int,可以存负数,

    俩种命名方法 1.Pascal 命名法,第一个字母大写其它字母小写Userid 2.Camel命名法,所有单第一方写大写,其它小写,骆峰命名法,userId 程序中元素的命名规范项目名:公司名.项目名 ...

  9. php strrpos()函数 语法

    php strrpos()函数 语法 作用:寻找某字符串中某字符最后出现的位置.大理石构件怎么选择 语法:strrpos(string,find,start) 参数: 参数 描述 string 必需. ...

  10. JAVA学习纲要

    这份面试题,包含的内容了十九了模块:Java 基础.容器.多线程.反射.对象拷贝.Java Web 模块.异常.网络.设计模式.Spring/Spring MVC.Spring Boot/Spring ...