index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <script setup>
  2. import {
  3. ref
  4. } from "vue";
  5. import {
  6. onLoad,
  7. onPullDownRefresh,
  8. onReachBottom,
  9. onPageScroll,
  10. } from "@dcloudio/uni-app";
  11. import {
  12. getPolicyList,
  13. } from "@/api/work/policy.js";
  14. // 页面标题
  15. let pageName = ref(null);
  16. // 滚动
  17. let scrollTop = ref(0);
  18. // 搜索条件
  19. let searchInfo = ref({
  20. pageNo: 1,
  21. pageSize: 10,
  22. columnId: null
  23. });
  24. // 列表
  25. let policyList = ref([]);
  26. let listTotal = ref(0);
  27. // 获取列表
  28. let loading = ref(true);
  29. const getList = function() {
  30. if (searchInfo.value.pageNo == 1) {
  31. loading.value = true
  32. };
  33. getPolicyList(searchInfo.value).then(res => {
  34. loading.value = false;
  35. policyList.value = policyList.value.concat(res.data.list);
  36. listTotal.value = res.data.total;
  37. if (res.data.total == searchInfo.value.pageNo * searchInfo.value.pageSize - (10 - res.data.list.length))
  38. moreListFlag = false;
  39. }).catch(() => {
  40. loading.value = false;
  41. })
  42. };
  43. //跳转详情
  44. const showDetail = function(title, id) {
  45. uni.navigateTo({
  46. url: `/pages/policy/detail/index?title=${title}&id=${id}`,
  47. });
  48. }
  49. // 触底加载flag
  50. let moreListFlag = true
  51. onLoad(options => {
  52. pageName = options.title;
  53. searchInfo.value.columnId = options.id;
  54. getList();
  55. });
  56. //图片预览
  57. // function viewImg(e){
  58. // let imglist = [e]
  59. // uni.previewImage({
  60. // longPressActions:true,
  61. // urls:imglist
  62. // })
  63. // }
  64. onPullDownRefresh(() => {
  65. searchInfo.value.pageNo = 1;
  66. policyList.value = [];
  67. moreListFlag = true;
  68. try {
  69. getList();
  70. } finally {
  71. uni.stopPullDownRefresh();
  72. }
  73. });
  74. onReachBottom(() => {
  75. if (!moreListFlag) {
  76. return uni.showToast({
  77. title: "已经到底了。",
  78. icon: "none",
  79. duration: 2000
  80. })
  81. }
  82. searchInfo.value.pageNo++;
  83. getList();
  84. });
  85. onPageScroll((e) => {
  86. scrollTop.value = e.scrollTop
  87. })
  88. </script>
  89. <template>
  90. <view class="container">
  91. <page-title>{{pageName}}</page-title>
  92. <view class="items-list">
  93. <view class="item" v-for="(item,index) in policyList" :key="index" @click="showDetail(item.title,item.id)">
  94. <img :src="item.coverImg" alt="" class="item-icon" @click='viewImg(item.coverImg)'>
  95. <view class="item-text">
  96. <view class="item-title">{{item.title?? "--"}}</view>
  97. <!-- <view class="item-rptDate">{{item.rptDate?? "--"}}</view> -->
  98. <view class="item-kind">{{item.columnName??"--"}}</view>
  99. </view>
  100. <view class="item-btn">查看</view>
  101. </view>
  102. </view>
  103. <u-back-top :scroll-top="scrollTop"></u-back-top>
  104. <u-loading-page :loading="loading"></u-loading-page>
  105. </view>
  106. </template>
  107. <style lang="scss" scoped>
  108. .items-list {
  109. position: absolute;
  110. top: 5%;
  111. left: 0;
  112. width: 100%;
  113. min-height: 95%;
  114. padding: 100rpx 4%;
  115. background: #F9FBFF;
  116. // border-radius: 40rpx 40rpx 0 0;
  117. }
  118. .item {
  119. margin-top: 20rpx;
  120. display: flex;
  121. align-items: center;
  122. width: 100%;
  123. min-height: 140rpx;
  124. padding: 26rpx 28rpx;
  125. box-sizing: border-box;
  126. background: #FFFFFF;
  127. box-shadow: 0rpx 18rpx 48rpx -4rpx rgba(150, 176, 220, 0.2);
  128. border-radius: 24rpx;
  129. .item-icon {
  130. width: 82rpx;
  131. height: 82rpx;
  132. margin-right: 32rpx;
  133. // background-image: url("@/static/policy-icon.png");
  134. // background-size: 100% 100%;
  135. }
  136. .item-text {
  137. width: 70%;
  138. height: 100%;
  139. word-break: break-all;
  140. .item-title {
  141. width: 100%;
  142. color: #343437;
  143. font-size: 28rpx;
  144. margin-bottom: 30rpx;
  145. }
  146. .item-kind {
  147. width: fit-content;
  148. min-height: 38rpx;
  149. padding: 10rpx;
  150. box-sizing: border-box;
  151. text-align: center;
  152. color: #1763E7;
  153. font-size: 24rpx;
  154. line-height: 38rpx;
  155. background: #DEEAFF;
  156. border-radius: 12rpx;
  157. }
  158. .item-rptDate{
  159. width: 100%;
  160. color: #343437;
  161. font-size: 28rpx;
  162. margin-bottom: 30rpx;
  163. }
  164. }
  165. .item-btn {
  166. width: 106rpx;
  167. height: 58rpx;
  168. background: #1763E7;
  169. border-radius: 16rpx;
  170. color: #FFF;
  171. font-size: 28rpx;
  172. text-align: center;
  173. line-height: 58rpx;
  174. margin-left: 20rpx;
  175. }
  176. }
  177. </style>