index.vue 6.4 KB

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