index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <view class="detail-page">
  3. <view class="tip"
  4. >数据更新时间:{{
  5. formatDate(
  6. new Date().setDate(new Date().getDate() - 1),
  7. "YYYY-MM-DD",
  8. ) || "--"
  9. }}</view
  10. >
  11. <scroll-view
  12. class="list-scroll"
  13. scroll-y="true"
  14. refresher-enabled
  15. :refresher-triggered="isRefreshing"
  16. @refresherrefresh="onRefresh"
  17. @scrolltolower="onLoadMore"
  18. >
  19. <view class="list-container">
  20. <view
  21. class="card-item"
  22. v-for="(item, index) in rows"
  23. :key="index"
  24. @click="toDetail(item)"
  25. >
  26. <view class="left-info">
  27. <view class="row1-name">{{ item.receiverName }}</view>
  28. <view class="row4-manager">信用代码:{{ item.companyCode }}</view>
  29. </view>
  30. </view>
  31. <view class="loading-more" v-if="loading">
  32. <image
  33. class="loading-icon"
  34. src="../../../static/images/loading.png"
  35. />
  36. </view>
  37. <view v-if="!loading && rows.length === 0" class="empty-data">
  38. <EmptyView text="无相关数据" />
  39. </view>
  40. <view v-if="!hasMore && rows.length > 0" class="no-more">
  41. <text>没有更多数据了</text>
  42. </view>
  43. </view>
  44. </scroll-view>
  45. </view>
  46. </template>
  47. <script>
  48. import EmptyView from "../../../wigets/empty.vue";
  49. import request from "../../../request/index.js";
  50. import { formatDate } from "../../../utils/utils.js";
  51. export default {
  52. components: {
  53. EmptyView,
  54. },
  55. data() {
  56. return {
  57. isRefreshing: false,
  58. loading: false,
  59. rows: [],
  60. totalCount: 60, // Simulated total count
  61. hasMore: true,
  62. pageNum: 1,
  63. pageSize: 20,
  64. };
  65. },
  66. created() {
  67. this.resetFetch();
  68. },
  69. methods: {
  70. formatDate,
  71. getLevelClass(level) {
  72. if (level === "VIP") return "tag-vip";
  73. if (level === "二级") return "tag-l2";
  74. if (level === "三级") return "tag-l3";
  75. return "tag-default";
  76. },
  77. generateFakeData() {
  78. const newRows = [];
  79. const provinces = [
  80. "91370104771001730R",
  81. "91420105783155681H",
  82. "91330110MA2CCJE32Y",
  83. "91441581761581268X",
  84. "91510106768621824L",
  85. ];
  86. const startIdx = (this.pageNum - 1) * this.pageSize;
  87. const endIdx = Math.min(startIdx + this.pageSize, this.totalCount);
  88. if (startIdx >= this.totalCount) {
  89. this.hasMore = false;
  90. return [];
  91. }
  92. for (let i = startIdx; i < endIdx; i++) {
  93. newRows.push({
  94. id: i,
  95. receiverName: `测试收货企业${i + 1}有限公司`,
  96. companyCode: provinces[i % provinces.length],
  97. });
  98. }
  99. return newRows;
  100. },
  101. async onRefresh() {
  102. this.isRefreshing = true;
  103. this.pageNum = 1;
  104. this.hasMore = true;
  105. // Simulate network request
  106. setTimeout(() => {
  107. this.rows = this.generateFakeData();
  108. this.isRefreshing = false;
  109. }, 1000);
  110. },
  111. onLoadMore() {
  112. if (this.loading || !this.hasMore) return;
  113. this.loading = true;
  114. this.pageNum++;
  115. // Simulate network request
  116. setTimeout(() => {
  117. const more = this.generateFakeData();
  118. if (more.length > 0) {
  119. this.rows = [...this.rows, ...more];
  120. } else {
  121. this.hasMore = false;
  122. }
  123. this.loading = false;
  124. }, 800);
  125. },
  126. resetFetch() {
  127. this.loading = true;
  128. this.pageNum = 1;
  129. this.hasMore = true;
  130. // Simulate initial load
  131. setTimeout(() => {
  132. this.rows = this.generateFakeData();
  133. this.loading = false;
  134. }, 500);
  135. },
  136. toDetail(item) {
  137. uni.navigateTo({
  138. url: `/traceCodePackages/traceabilityReport/pages/blacklist/detail/index?id=${item.id}&name=${encodeURIComponent(item.receiverName)}`,
  139. });
  140. },
  141. },
  142. };
  143. </script>
  144. <style scoped>
  145. .detail-page {
  146. display: flex;
  147. flex-direction: column;
  148. height: calc(100vh - 116rpx - env(safe-area-inset-bottom));
  149. box-sizing: border-box;
  150. background: #f3f6f9;
  151. }
  152. .tip {
  153. font-size: 24rpx;
  154. color: #999;
  155. padding: 24rpx;
  156. background: #f3f6f9;
  157. }
  158. .list-scroll {
  159. flex: 1;
  160. height: 0; /* Important for flex expansion */
  161. padding: 0 24rpx;
  162. box-sizing: border-box;
  163. }
  164. .list-container {
  165. padding-bottom: calc(50rpx + env(safe-area-inset-bottom));
  166. }
  167. .card-item {
  168. display: flex;
  169. justify-content: space-between;
  170. align-items: flex-start; /* Align top */
  171. background: #fff;
  172. border-radius: 16rpx;
  173. padding: 30rpx;
  174. margin-bottom: 20rpx;
  175. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  176. }
  177. .left-info {
  178. flex: 1;
  179. margin-right: 20rpx;
  180. }
  181. .row1-name {
  182. font-size: 30rpx;
  183. font-weight: bold;
  184. color: #1890ff;
  185. margin-bottom: 16rpx;
  186. }
  187. .row2-info {
  188. display: flex;
  189. align-items: center;
  190. margin-bottom: 12rpx;
  191. }
  192. .province {
  193. font-size: 26rpx;
  194. color: #666;
  195. margin-right: 20rpx;
  196. }
  197. .level-tag {
  198. font-size: 22rpx;
  199. padding: 4rpx 12rpx;
  200. border-radius: 6rpx;
  201. background: #f0f0f0;
  202. color: #666;
  203. }
  204. .tag-vip {
  205. background: #e6f7ff;
  206. color: #1890ff;
  207. }
  208. .tag-l2 {
  209. background: #f6ffed;
  210. color: #52c41a;
  211. }
  212. .tag-l3 {
  213. background: #fff7e6;
  214. color: #fa8c16;
  215. }
  216. .row3-nature {
  217. font-size: 26rpx;
  218. color: #666;
  219. margin-bottom: 12rpx;
  220. }
  221. .row4-manager {
  222. font-size: 26rpx;
  223. color: #666;
  224. }
  225. .right-info {
  226. display: flex;
  227. align-items: center;
  228. align-self: center; /* Center vertically relative to card */
  229. }
  230. .alert-count {
  231. background: #fff2f0;
  232. color: #ff4d4f;
  233. font-size: 24rpx;
  234. padding: 8rpx 20rpx;
  235. border-radius: 30rpx;
  236. font-weight: bold;
  237. }
  238. .loading-more {
  239. display: flex;
  240. justify-content: center;
  241. align-items: center;
  242. padding: 20rpx 0;
  243. }
  244. .loading-icon {
  245. width: 32rpx;
  246. height: 32rpx;
  247. margin-right: 10rpx;
  248. animation: spin 1s linear infinite;
  249. }
  250. .empty-data {
  251. display: flex;
  252. justify-content: center;
  253. padding-top: 100rpx;
  254. }
  255. .no-more {
  256. text-align: center;
  257. color: #999;
  258. font-size: 24rpx;
  259. padding: 20rpx 0;
  260. }
  261. @keyframes spin {
  262. from {
  263. transform: rotate(0deg);
  264. }
  265. to {
  266. transform: rotate(360deg);
  267. }
  268. }
  269. </style>