comment2.nvue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <view class="content" style="width:100%;">
  3. <list class="container" style="height: 700px;" loadmoreoffset="100" @loadmore="loadmore">
  4. <refresh @pullingdown='onpullingdown' @refresh="onrefresh" :display=" refreshing ? 'show' : 'hide' " class="refresh x-c ">
  5. <loading-indicator style="width: 22px;height: 22px;color:#999;"></loading-indicator>
  6. <text class="es-fs-32 es-ml-8">{{refreshText}}</text>
  7. </refresh>
  8. <cell v-for="(item,index) in list" :key="index">
  9. <view class="es es-h-120 es-pt-20 es-pb-20 x-c " style="width: 100%;background-color: red;" :style=" index == list.length-1 ? 'border-bottom-width:0' : '' ">
  10. <text class="f24_333 flex-1">一楼无线局域网</text>
  11. </view>
  12. </cell>
  13. <cell v-if="showLoadMore || list.length > 4">
  14. <view class="loading-more">
  15. <text class="loading-more-text">{{loadMoreText}}</text>
  16. </view>
  17. </cell>
  18. </list>
  19. <!-- <view class="uni-loadmore x-c" v-if="showLoadMore">
  20. <text class="es-fs-28">{{loadMoreText}}</text>
  21. </view> -->
  22. <!-- <uni-load-more :status="status" :icon-size="16" :content-text="loadMoreText" /> -->
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. data() {
  28. return {
  29. list:[],
  30. refreshing: false,
  31. refreshText: '↓ Pull To Refresh',
  32. loadMoreText:"加载中...",
  33. showLoadMore:false,
  34. max: 0
  35. };
  36. },
  37. onReachBottom() {
  38. console.log("onReachBottom");
  39. if (this.max > 50) {
  40. this.loadMoreText = "没有更多数据了!"
  41. return;
  42. }
  43. this.showLoadMore = true;
  44. setTimeout(() => {
  45. this.setListData();
  46. }, 300);
  47. },
  48. onPullDownRefresh() {
  49. console.log('onPullDownRefresh');
  50. this.initData();
  51. },
  52. onLoad() {
  53. this.initData();
  54. },
  55. methods: {
  56. onpullingdown(e) {
  57. if (this.refreshing) return;
  58. if (Math.abs(e.pullingDistance) > Math.abs(e.viewHeight)) {
  59. this.refreshText = '下拉更新'
  60. } else {
  61. this.refreshText = '释放更新'
  62. }
  63. },
  64. onrefresh(e) {
  65. if (this.refreshing) return;
  66. this.refreshing = true;
  67. setTimeout(() => {
  68. this.refreshing = false;
  69. this.refreshText = '加载中'
  70. }, 200)
  71. },
  72. loadmore(){
  73. console.log("loadmore");
  74. if (this.max > 50) {
  75. this.loadMoreText = "没有更多数据了!"
  76. return;
  77. }
  78. this.showLoadMore = true;
  79. setTimeout(() => {
  80. this.setListData();
  81. }, 300);
  82. },
  83. initData(){
  84. setTimeout(() => {
  85. this.max = 0;
  86. this.list = []
  87. let data = [];
  88. this.max += 10;
  89. for (var i = this.max - 19; i < this.max + 1; i++) {
  90. data.push(i)
  91. }
  92. this.list = this.list.concat(data);
  93. uni.stopPullDownRefresh();
  94. }, 300);
  95. },
  96. setListData() {
  97. let list = [];
  98. setTimeout(() => {
  99. this.max += 10;
  100. for (var i = this.max - 9; i < this.max + 1; i++) {
  101. list.push(i)
  102. }
  103. this.list = this.list.concat(list);
  104. uni.stopPullDownRefresh();
  105. }, 300);
  106. }
  107. }
  108. }
  109. </script>
  110. <style>
  111. .content{
  112. position: relative;
  113. width: 100%;
  114. }
  115. .refresh {
  116. display: flex;
  117. flex-direction: row;
  118. justify-content: center;
  119. height: 50px;
  120. }
  121. .refresh-view {
  122. /* #ifndef APP-NVUE */
  123. display: flex;
  124. /* #endif */
  125. width: 750rpx;
  126. height: 64px;
  127. flex-direction: row;
  128. flex-wrap: nowrap;
  129. align-items: center;
  130. justify-content: center;
  131. }
  132. .refresh-icon {
  133. width: 32px;
  134. height: 32px;
  135. transition-duration: .5s;
  136. transition-property: transform;
  137. transform: rotate(0deg);
  138. transform-origin: 15px 15px;
  139. }
  140. .refresh-icon-active {
  141. transform: rotate(180deg);
  142. }
  143. .loading-icon {
  144. width: 28px;
  145. height: 28px;
  146. margin-right: 5px;
  147. color: gray;
  148. }
  149. .loading-text {
  150. margin-left: 2px;
  151. font-size: 16px;
  152. color: #999999;
  153. }
  154. .loading-more {
  155. align-items: center;
  156. justify-content: center;
  157. padding-top: 14px;
  158. padding-bottom: 14px;
  159. text-align: center;
  160. }
  161. .loading-more-text {
  162. font-size: 30rpx;
  163. color: #999;
  164. }
  165. </style>