list.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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.name" :sub-title="item.creditScore">
  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.name }}</text>
  19. </view>
  20. <view class="info-row">
  21. <text class="label">身份证号码:</text>
  22. <text class="value">{{ item.idCardNumber }}</text>
  23. </view>
  24. <view class="info-row">
  25. <text class="label">报告编号:</text>
  26. <text class="value">{{ item.reportNumber }}</text>
  27. </view>
  28. <view class="info-row">
  29. <text class="label">报告时间:</text>
  30. <text class="value">{{ item.reportTime }}</text>
  31. </view>
  32. <view class="info-row">
  33. <text class="label">查询机构:</text>
  34. <text class="value">{{ item.queryOrganization }}</text>
  35. </view>
  36. <view class="info-row">
  37. <text class="label">查询原因:</text>
  38. <text class="value">{{ item.queryReason }}</text>
  39. </view>
  40. </view>
  41. </template>
  42. </u-card>
  43. </view>
  44. </view>
  45. <u-loadmore v-if="list.length > 0" :status="loadMoreStatus" />
  46. </view>
  47. </scroll-view>
  48. </s-layout>
  49. </template>
  50. <script setup>
  51. import { ref, onMounted } from 'vue';
  52. import { onLoad, onShow } from '@dcloudio/uni-app';
  53. import EnterApi from '@/sheep/api/enter/index.js';
  54. import dayjs from 'dayjs';
  55. import sheep from '@/sheep';
  56. const triggered = ref(false);
  57. const list = ref([]);
  58. const page = ref(1);
  59. const loadMoreStatus = ref('loadmore');
  60. // 跳转到添加页面
  61. const goToAdd = () => {
  62. sheep.$router.go('/pages/enter/creditEnter/index', { formType: 'create' })
  63. };
  64. const goToEdit = (item) => {
  65. sheep.$router.go('/pages/enter/creditEnter/index', { formType: 'edit', id: item.id })
  66. };
  67. // 获取列表数据
  68. const getList = async (isRefresh = false) => {
  69. try {
  70. if (isRefresh) {
  71. page.value = 1;
  72. }
  73. const res = await EnterApi.getUserPersonalCreditPage({
  74. page: page.value,
  75. pageSize: 10
  76. });
  77. if (res.code === 0) {
  78. if (isRefresh) {
  79. list.value = res.data.list;
  80. } else {
  81. list.value = [...list.value, ...res.data.list];
  82. }
  83. loadMoreStatus.value = res.data.hasMore ? 'loadmore' : 'nomore';
  84. } else {
  85. uni.showToast({
  86. title: res.msg,
  87. icon: 'none'
  88. });
  89. }
  90. } catch (error) {
  91. console.error(error);
  92. uni.showToast({
  93. title: '获取数据失败',
  94. icon: 'none'
  95. });
  96. }
  97. };
  98. // 下拉刷新
  99. const onRefresh = async () => {
  100. triggered.value = true;
  101. await getList(true);
  102. triggered.value = false;
  103. };
  104. // 加载更多
  105. const loadMore = async () => {
  106. if (loadMoreStatus.value === 'nomore') return;
  107. loadMoreStatus.value = 'loading';
  108. page.value++;
  109. await getList();
  110. };
  111. onLoad(() => {
  112. })
  113. onShow(() => {
  114. // 页面显示时重新加载数据
  115. page.value = 1;
  116. list.value = [];
  117. loadMoreStatus.value = 'loadmore';
  118. loadMore();
  119. })
  120. onMounted(() => {
  121. // // 页面显示时重新加载数据
  122. // page.value = 1;
  123. // list.value = [];
  124. // loadMoreStatus.value = 'loadmore';
  125. // 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>