list.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <s-layout>
  3. <scroll-view scroll-y class="list-container" refresher-enabled :refresher-triggered="triggered"
  4. @refresherrefresh="onRefresh" @scrolltolower="loadMore">
  5. <view>
  6. <view class="add-btn" @click="goToAdd">
  7. <u-icon name="plus" size="28"></u-icon>
  8. <text>添加营业执照</text>
  9. </view>
  10. <u-empty v-if="list.length === 0" text="暂无数据"></u-empty>
  11. <view v-else class="card-list">
  12. <view v-for="(item, index) in list" :key="index" class="card-item">
  13. <u-card :title="item.companyName" :sub-title="item.creditCode">
  14. <template #body>
  15. <view class="card-content" @click="goToEdit(item)">
  16. <view class="info-row">
  17. <text class="label">法定代表人:</text>
  18. <text class="value">{{ item.legalRepresentative }}</text>
  19. </view>
  20. <view class="info-row">
  21. <text class="label">注册资本:</text>
  22. <text class="value">{{ item.registeredCapital }}</text>
  23. </view>
  24. <view class="info-row">
  25. <text class="label">成立日期:</text>
  26. <text class="value">{{ dayjs(item.establishDate).format("YYYY-MM-DD") }}</text>
  27. </view>
  28. <view class="info-row">
  29. <text class="label">营业期限:</text>
  30. <text class="value">{{ dayjs(item.businessTermStart).format("YYYY-MM-DD") }} - {{
  31. dayjs(item.businessTermEnd).format("YYYY-MM-DD") }}</text>
  32. </view>
  33. <view class="info-row">
  34. <text class="label">经营范围:</text>
  35. <text class="value">{{ item.businessScope }}</text>
  36. </view>
  37. <!-- <view class="info-row">
  38. <text class="label">住所:</text>
  39. <text class="value">{{ item.address }}</text>
  40. </view> -->
  41. </view>
  42. </template>
  43. </u-card>
  44. </view>
  45. </view>
  46. <u-loadmore v-if="list.length > 0" :status="loadMoreStatus" />
  47. </view>
  48. </scroll-view>
  49. </s-layout>
  50. </template>
  51. <script setup>
  52. import { ref, onMounted } from 'vue';
  53. import { onLoad, onShow } from '@dcloudio/uni-app';
  54. import EnterApi from '@/sheep/api/enter/index.js';
  55. import dayjs from 'dayjs';
  56. import sheep from '@/sheep';
  57. const triggered = ref(false);
  58. const list = ref([]);
  59. const page = ref(1);
  60. const loadMoreStatus = ref('loadmore');
  61. // 跳转到添加页面
  62. const goToAdd = () => {
  63. sheep.$router.go('/pages/enter/businessLicenseEnter/index', { formType: 'create' })
  64. };
  65. const goToEdit = (item) => {
  66. sheep.$router.go('/pages/enter/businessLicenseEnter/index', { formType: 'edit', id: item.id })
  67. };
  68. // 获取列表数据
  69. const getList = async (isRefresh = false) => {
  70. try {
  71. if (isRefresh) {
  72. page.value = 1;
  73. }
  74. const res = await EnterApi.getUserBusinessLicensePage({
  75. page: page.value,
  76. pageSize: 10
  77. });
  78. if (res.code === 0) {
  79. if (isRefresh) {
  80. list.value = res.data.list;
  81. } else {
  82. list.value = [...list.value, ...res.data.list];
  83. }
  84. loadMoreStatus.value = res.data.hasMore ? 'loadmore' : 'nomore';
  85. } else {
  86. uni.showToast({
  87. title: res.msg,
  88. icon: 'none'
  89. });
  90. }
  91. } catch (error) {
  92. console.error(error);
  93. uni.showToast({
  94. title: '获取数据失败',
  95. icon: 'none'
  96. });
  97. }
  98. };
  99. // 下拉刷新
  100. const onRefresh = async () => {
  101. triggered.value = true;
  102. await getList(true);
  103. triggered.value = false;
  104. };
  105. // 加载更多
  106. const loadMore = async () => {
  107. if (loadMoreStatus.value === 'nomore') return;
  108. loadMoreStatus.value = 'loading';
  109. page.value++;
  110. await getList();
  111. };
  112. onLoad(() => {
  113. })
  114. onShow(() => {
  115. // 页面显示时重新加载数据
  116. page.value = 0;
  117. list.value = [];
  118. loadMoreStatus.value = 'loadmore';
  119. loadMore();
  120. })
  121. onMounted(() => {
  122. // // 页面显示时重新加载数据
  123. // page.value = 1;
  124. // list.value = [];
  125. // loadMoreStatus.value = 'loadmore';
  126. // loadMore();
  127. });
  128. </script>
  129. <style lang="scss" scoped>
  130. .list-container {
  131. width: 100%;
  132. background: #f5f5f5;
  133. .add-btn {
  134. display: flex;
  135. align-items: center;
  136. justify-content: center;
  137. margin: 20rpx;
  138. padding: 20rpx;
  139. background: #fff;
  140. border-radius: 8rpx;
  141. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.1);
  142. text {
  143. margin-left: 10rpx;
  144. font-size: 28rpx;
  145. color: #333;
  146. }
  147. }
  148. .card-list {
  149. .card-item {
  150. margin-bottom: 20rpx;
  151. .card-content {
  152. padding: 20rpx;
  153. .info-row {
  154. display: flex;
  155. margin-bottom: 16rpx;
  156. .label {
  157. width: 160rpx;
  158. color: #666;
  159. font-size: 28rpx;
  160. }
  161. .value {
  162. flex: 1;
  163. color: #333;
  164. font-size: 28rpx;
  165. }
  166. }
  167. }
  168. }
  169. }
  170. }
  171. </style>