index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <template>
  2. <view class="monitoring">
  3. <view class="monitoring-content">
  4. <scroll-view scroll-y="true" class="scroll-Y" @scrolltolower="handleScrolltolower">
  5. <view class="monitoring-listbody">
  6. <!-- 列表无数据 -->
  7. <template v-if="list_empty">
  8. <view class="monitoring-listbody-nodata">
  9. <text class="monitoring-listbody-nodata-text">暂无数据</text>
  10. </view>
  11. </template>
  12. <!-- 列表有数据 -->
  13. <template v-else>
  14. <view
  15. class="listbody-item"
  16. v-for="monitoringItem in monitoringList"
  17. :key="monitoringItem.id"
  18. @click="handleMonitoringDetails(monitoringItem)"
  19. >
  20. <view class="item-container">
  21. <view class="container-left">
  22. <view class="left-title">{{ monitoringItem.artTitle }}</view>
  23. <view class="left-releasetime">发布时间:{{ monitoringItem.artInTime }}</view>
  24. </view>
  25. <view class="container-right">
  26. <view class="right-content">
  27. <template v-if="monitoringItem.artImage">
  28. <image
  29. :src="baseApiUrl + monitoringItem.artImage"
  30. mode="scaleToFill"
  31. class="right-content-image"
  32. />
  33. </template>
  34. <template v-else>
  35. <image
  36. src="@/static/agrcloud-images/agrcloud-empty-img.png"
  37. mode="scaleToFill"
  38. class="right-content-image"
  39. />
  40. </template>
  41. </view>
  42. </view>
  43. <view style="clear: both;"></view>
  44. </view>
  45. </view>
  46. </template>
  47. <!-- 加载更多组件 -->
  48. <uni-load-more :status="loadStatus" v-if="!list_empty"></uni-load-more>
  49. </view>
  50. </scroll-view>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. import {
  56. monitoringListData
  57. } from '@/agrcloud-api/monitoring';
  58. import uniLoadMore from "@/agrcloud-components/uni-load-more/uni-load-more.vue"
  59. export default {
  60. name: 'monitoring',
  61. components: {
  62. uniLoadMore
  63. },
  64. data() {
  65. return {
  66. loadStatus: 'more',
  67. list_empty: false,
  68. pageTotal: 0,
  69. pageCount: 0,
  70. pagination: {
  71. artCategoryId: '2',
  72. pageNum: 1,
  73. pageSize: 10
  74. },
  75. monitoringList: []
  76. };
  77. },
  78. onLoad() {
  79. this.initData();
  80. },
  81. methods: {
  82. /** 初始化数据 */
  83. initData() {
  84. this.getMonitoringListData();
  85. },
  86. /** 获取政策法规之列表数据 */
  87. getMonitoringListData() {
  88. this.list_empty = false;
  89. this.loadStatus = 'loading';
  90. monitoringListData(this.pagination).then(res => {
  91. // 数据总条数
  92. this.pageTotal = res.total || 0;
  93. // 如果列表为第一页,返回列表数据清空
  94. if (this.pagination.pageNum == 1) {
  95. this.monitoringList = [];
  96. };
  97. // 处理返回结果
  98. if ((res.rows || []).length <= 0) { // 返回结果没有数据
  99. if ((this.monitoringList || []).length <= 0) {
  100. this.loadStatus = 'noMores';
  101. this.list_empty = true;
  102. } else {
  103. this.loadStatus = 'noMores';
  104. }
  105. } else { //返回结果有数据
  106. this.list_empty = false;
  107. // 获取列表数据分页数量
  108. this.pageCount = Math.ceil((res.total || 0) / this.pagination.pageSize);
  109. if ((res.total || 0) % this.pagination.pageSize == 0) {
  110. this.pageCount = Math.ceil((res.total || 0) / this.pagination.pageSize);
  111. if (this.pageCount == 1) {
  112. this.pageCount--;
  113. }
  114. } else {
  115. this.pageCount--;
  116. };
  117. // 处理页面状态
  118. if (this.pageCount === 0) {
  119. this.loadStatus = 'noMores'
  120. } else {
  121. this.loadStatus = 'more'
  122. }
  123. // 组装返回数据
  124. this.monitoringList.push.apply(this.monitoringList, res.rows || []);
  125. uni.stopPullDownRefresh();
  126. }
  127. }).catch(err => {
  128. this.loadStatus = 'noMores';
  129. });
  130. },
  131. handleScrolltolower() {
  132. this.loadStatus = 'loading';
  133. if (this.pagination.pageNum - 1 >= this.pageCount) {
  134. this.loadStatus = 'noMores';
  135. return;
  136. } else {
  137. this.pagination.pageNum++;
  138. this.getMonitoringListData();
  139. }
  140. },
  141. /** 政策法规之详情数据操作 */
  142. handleMonitoringDetails(param) {
  143. this.$store.dispatch("SetMonitoringDetails", param).then(() => {
  144. uni.navigateTo({
  145. url: '/pages/monitoring/details/index'
  146. });
  147. }).catch(() => {
  148. this.$msgbox('访问数据异常!', 'none');
  149. });
  150. }
  151. }
  152. }
  153. </script>
  154. <style lang="scss" scoped>
  155. .monitoring {
  156. padding-top: 25rpx;
  157. width: 100%;
  158. .monitoring-content {
  159. width: 100%;
  160. .scroll-Y {
  161. height: calc(
  162. 100vh - 88rpx - 100rpx - env(safe-area-inset-bottom) -
  163. var(--status-bar-height)
  164. );
  165. }
  166. .monitoring-listbody {
  167. width: 100%;
  168. .listbody-item {
  169. width: 750rpx;
  170. height: 208rpx;
  171. background: #ffffff;
  172. margin-bottom: 24rpx;
  173. .item-container {
  174. padding: 24rpx;
  175. .container-left {
  176. float: left;
  177. width: 478rpx;
  178. .left-title {
  179. height: 84rpx;
  180. font-size: 30rpx;
  181. font-family: PingFangSC-Medium, PingFang SC;
  182. font-weight: 500;
  183. color: #333333;
  184. line-height: 42rpx;
  185. }
  186. .left-releasetime {
  187. margin-top: 16rpx;
  188. }
  189. }
  190. .container-right {
  191. float: left;
  192. margin-left: 24rpx;
  193. .right-content {
  194. width: 200rpx;
  195. height: 160rpx;
  196. border-radius: 8rpx;
  197. .right-content-image {
  198. width: 200rpx;
  199. height: 160rpx;
  200. }
  201. }
  202. }
  203. }
  204. }
  205. &-nodata {
  206. text-align: center;
  207. margin-top: 20rpx;
  208. &-text {
  209. font-size: 30rpx;
  210. color: #777777;
  211. }
  212. }
  213. }
  214. }
  215. }
  216. </style>