index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <view class="container">
  3. <page-title @searchClick='searchClick' :showSearch='true'>企业信息</page-title>
  4. <!-- <view class="back-btn">
  5. <u-icon name="arrow-left" color="#fff" size="20" customStyle="margin:0 auto" @click="backToBefore()"></u-icon>
  6. <text class="back-text" @click="backToBefore()">企业信息</text>
  7. <u-icon name="search" color="#fff" size="30" customStyle="position:absolute;top:0;right:0"
  8. @click="goToPage('/pages/enterpriseInfo/search/index')"></u-icon>
  9. </view> -->
  10. <view class="cards-list">
  11. <view class="card" v-for="(item,index) in enterpriseList" :key="index">
  12. <card-title :numerator="index+1" :denominator="listTotal"></card-title>
  13. <view class="card-name">
  14. <view class="card-name-title">
  15. <text class="card-name-description">企业名称</text>
  16. </view>
  17. <text class="card-name-text">{{item.title || "--"}}</text>
  18. </view>
  19. <view class="card-item">
  20. <view class="card-item-name">所在地</view>
  21. <view class="card-item-content">{{item.area || "--"}}</view>
  22. </view>
  23. <view class="card-item">
  24. <view class="card-item-name">当前状态</view>
  25. <view class="card-item-content">{{item.status || "--"}}</view>
  26. </view>
  27. <view class="card-item">
  28. <view class="card-item-name">注册资金</view>
  29. <view class="card-item-content">{{(item.amt!= null)? item.amt : "--"}}</view>
  30. </view>
  31. <view class="card-item">
  32. <view class="card-btn fat-btn" @click="gotoDetail(item.id,item.title)">企业查看</view>
  33. </view>
  34. </view>
  35. <empty-show v-if="enterpriseList.length===0"></empty-show>
  36. </view>
  37. <u-back-top :scroll-top="scrollTop"></u-back-top>
  38. <u-loading-page :loading="loading"></u-loading-page>
  39. </view>
  40. </template>
  41. <script setup>
  42. import {
  43. ref
  44. } from 'vue'
  45. import {
  46. onLoad,
  47. onUnload,
  48. onPullDownRefresh,
  49. onReachBottom,
  50. onPageScroll
  51. } from "@dcloudio/uni-app"
  52. import {
  53. getEnterpriseInfoList,
  54. } from "@/api/work/enterpriseInfo.js"
  55. // 返回上一级
  56. function backToBefore() {
  57. uni.reLaunch({
  58. url: "/pages/index"
  59. });
  60. };
  61. function goToPage(url) {
  62. uni.navigateTo({
  63. url
  64. })
  65. }
  66. let scrollTop = ref(0);
  67. let loading = ref(true);
  68. // 参数
  69. let searchInfo = ref({
  70. pageNo: 1,
  71. pageSize: 10,
  72. })
  73. function searchClick () {
  74. goToPage('/pages/enterpriseInfo/search/index')
  75. }
  76. // 获取列表
  77. function getList() {
  78. let params = {
  79. pageNo: searchInfo.value.pageNo,
  80. pageSize: searchInfo.value.pageSize,
  81. title: searchInfo.value.title,
  82. status: searchInfo.value.status
  83. }
  84. if(searchInfo.value.pageNo == 1){
  85. loading.value = true
  86. }
  87. getEnterpriseInfoList(params).then(res => {
  88. loading.value = false
  89. enterpriseList.value = enterpriseList.value.concat(res.data.list)
  90. listTotal.value = res.data.total
  91. if (res.data.total == searchInfo.value.pageNo*searchInfo.value.pageSize-(10 - res.data.list.length)) moreListFlag = false;
  92. }).catch(() => {
  93. loading.value = false
  94. })
  95. }
  96. // 主要列表
  97. let enterpriseList = ref([]);
  98. let listTotal = ref(0);
  99. // 去详情
  100. function gotoDetail(id, subName) {
  101. uni.navigateTo({
  102. url: `/pages/enterpriseInfo/detail/index?id=${id}&subName=${subName}`
  103. })
  104. }
  105. // 触底加载flag
  106. let moreListFlag = true
  107. onLoad(options => {
  108. // searchInfo.value = Object.assign(searchInfo.value, options)
  109. // let filterArr = ["null", "undefined", ""]
  110. // for (let i in searchInfo.value) {
  111. // if (filterArr.includes(searchInfo.value[i])) {
  112. // searchInfo.value[i] = null
  113. // }
  114. // }
  115. uni.$on('enterpriseInfoSearch', resolve => {
  116. searchInfo.value = Object.assign(searchInfo.value, resolve);
  117. searchInfo.value.pageNo = 1;
  118. enterpriseList.value = [];
  119. listTotal.value = 0;
  120. moreListFlag = true;
  121. getList();
  122. })
  123. getList();
  124. })
  125. onUnload(() => {
  126. uni.$off('enterpriseInfoSearch');
  127. });
  128. onPageScroll((e) => {
  129. scrollTop.value = e.scrollTop
  130. })
  131. onPullDownRefresh(() => {
  132. searchInfo.value.pageNo = 1;
  133. enterpriseList.value = [];
  134. moreListFlag = true;
  135. try {
  136. getList();
  137. } finally {
  138. uni.stopPullDownRefresh()
  139. }
  140. })
  141. onReachBottom(() => {
  142. if (!moreListFlag) {
  143. return uni.showToast({
  144. title: "已经到底了。",
  145. icon: "none",
  146. duration: 2000
  147. })
  148. }
  149. searchInfo.value.pageNo++;
  150. getList();
  151. })
  152. </script>
  153. <style lang="scss" scoped>
  154. // .back-btn {
  155. // position: absolute;
  156. // top: 8%;
  157. // left: 4%;
  158. // display: flex;
  159. // width: 92%;
  160. // font-size: 40rpx;
  161. // font-weight: 500;
  162. // color: #FFF;
  163. // .back-text {
  164. // margin-left: 28rpx;
  165. // }
  166. // }
  167. </style>