index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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. console.log(policyList.value);
  40. }).catch(() => {
  41. loading.value = false;
  42. })
  43. };
  44. //跳转详情
  45. const showDetail = function(title, id) {
  46. uni.navigateTo({
  47. url: `/pages/policy/detail/index?title=${title}&id=${id}`,
  48. });
  49. }
  50. // 触底加载flag
  51. let moreListFlag = true
  52. onLoad(options => {
  53. pageName = options.title;
  54. searchInfo.value.columnId = options.id;
  55. getList();
  56. });
  57. //图片预览
  58. // function viewImg(e){
  59. // let imglist = [e]
  60. // uni.previewImage({
  61. // longPressActions:true,
  62. // urls:imglist
  63. // })
  64. // }
  65. onPullDownRefresh(() => {
  66. searchInfo.value.pageNo = 1;
  67. policyList.value = [];
  68. moreListFlag = true;
  69. try {
  70. getList();
  71. } finally {
  72. uni.stopPullDownRefresh();
  73. }
  74. });
  75. onReachBottom(() => {
  76. if (!moreListFlag) {
  77. return uni.showToast({
  78. title: "已经到底了。",
  79. icon: "none",
  80. duration: 2000
  81. })
  82. }
  83. searchInfo.value.pageNo++;
  84. getList();
  85. });
  86. onPageScroll((e) => {
  87. scrollTop.value = e.scrollTop
  88. })
  89. </script>
  90. <template>
  91. <view class="container">
  92. <page-title>{{pageName}}</page-title>
  93. <view class="items-list" style="padding-top: 0 !important;">
  94. <view class="item" v-for="(item,index) in policyList" :key="index" @click="showDetail(item.title,item.id)">
  95. <view class="item-title">{{item.title?? "--"}}</view>
  96. <view class="item-text">
  97. <view class="item-kind">{{item.columnName??"--"}}
  98. </view>
  99. <view class="item-coverimg">
  100. <img :src="item.coverImg" alt="" class="item-icon-img" @click='viewImg(item.coverImg)' v-if="item.coverImg">
  101. <img src="../../static/images/noImgVideo.svg" alt="" class="item-icon" v-else>
  102. </view>
  103. <!-- <view class="item-rptDate">{{item.rptDate?? "--"}}</view> -->
  104. </view>
  105. <!-- <view class="item-btn">查看</view> -->
  106. </view>
  107. </view>
  108. <u-back-top :scroll-top="scrollTop"></u-back-top>
  109. <u-loading-page :loading="loading"></u-loading-page>
  110. </view>
  111. </template>
  112. <style lang="scss" scoped>
  113. .items-list {
  114. position: absolute;
  115. margin-top: calc(var(--status-bar-height) + 0rpx);
  116. left: 0;
  117. width: 100%;
  118. min-height: 95%;
  119. padding: 50rpx 4%;
  120. // background: #F9FBFF;
  121. display: flex;
  122. flex-direction: column;
  123. flex-wrap: wrap;
  124. gap: 20rpx;
  125. // border-radius: 40rpx 40rpx 0 0;
  126. }
  127. .item {
  128. position: relative;
  129. margin-top: 20rpx;
  130. display: flex;
  131. align-items: center;
  132. justify-content: space-between;
  133. width: 100%;
  134. // min-height: 140rpx;
  135. // padding: 26rpx 28rpx;
  136. // box-sizing: border-box;
  137. // background: #FFFFFF;
  138. // box-shadow: 0rpx 18rpx 48rpx -4rpx rgba(150, 176, 220, 0.2);
  139. // border-radius: 24rpx;
  140. // width: 694rpx;
  141. height: auto;
  142. min-height: 216rpx;
  143. background: #FFFFFF;
  144. box-shadow: 0px 0px 8rpx 0px #D8EEFF;
  145. border-radius: 12rpx;
  146. padding: 36rpx;
  147. .item-title {
  148. width: 75%;
  149. height: auto;
  150. font-weight: 500;
  151. font-size: 28rpx;
  152. color: #333333;
  153. line-height: 48rpx;
  154. display: flex;
  155. justify-content: flex-start;
  156. align-items: center;
  157. }
  158. .item-text {
  159. display: flex;
  160. flex-direction: column;
  161. align-items: center;
  162. width: 70%;
  163. height: 100%;
  164. word-break: break-all;
  165. position: absolute;
  166. right: -132rpx;
  167. top: 0rpx;
  168. .item-coverimg {
  169. width: 128rpx;
  170. height: 128rpx;
  171. background: #F6F6F6;
  172. border-radius: 4rpx;
  173. border: 2rpx solid #EBEBEB;
  174. display: flex;
  175. justify-content: center;
  176. align-items: center;
  177. .item-icon-img {
  178. width: 100%;
  179. height: 100%;
  180. border-radius: 4rpx;
  181. }
  182. .item-icon {
  183. width: 72rpx;
  184. height: 72rpx;
  185. // margin-right: 32rpx;
  186. // background-image: url("@/static/policy-icon.png");
  187. // background-size: 100% 100%;
  188. }
  189. }
  190. .item-kind {
  191. // width: fit-content;
  192. // min-height: 38rpx;
  193. // padding: 10rpx;
  194. // box-sizing: border-box;
  195. // text-align: center;
  196. // color: #1763E7;
  197. // font-size: 24rpx;
  198. // line-height: 38rpx;
  199. // background: #DEEAFF;
  200. // border-radius: 12rpx;
  201. width: auto;
  202. height: 48rpx;
  203. line-height: 48rpx;
  204. text-align: center;
  205. margin-bottom: 12rpx;
  206. background: #F2F7FF;
  207. border-radius: 0px 0px 32rpx 32rpx;
  208. font-weight: 500;
  209. font-size: 24rpx;
  210. color: #6C90C1;
  211. white-space: nowrap;
  212. padding-left: 14rpx;
  213. padding-right: 14rpx;
  214. }
  215. .item-rptDate {
  216. width: 100%;
  217. color: #343437;
  218. font-size: 28rpx;
  219. margin-bottom: 30rpx;
  220. }
  221. }
  222. .item-btn {
  223. width: 106rpx;
  224. height: 58rpx;
  225. background: #1763E7;
  226. border-radius: 16rpx;
  227. color: #FFF;
  228. font-size: 28rpx;
  229. text-align: center;
  230. line-height: 58rpx;
  231. margin-left: 20rpx;
  232. }
  233. }
  234. </style>