index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  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 class="footer-btn-area">
  54. <button class="export-btn" @click="handleExport">导出至邮箱</button>
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. import EmptyView from "../../../wigets/empty.vue";
  60. import request from "../../../request/index.js";
  61. import { formatDate } from "../../../utils/utils.js";
  62. export default {
  63. components: {
  64. EmptyView,
  65. },
  66. data() {
  67. return {
  68. isRefreshing: false,
  69. loading: false,
  70. rows: [],
  71. totalCount: 60, // Simulated total count
  72. hasMore: true,
  73. pageNum: 1,
  74. pageSize: 20,
  75. };
  76. },
  77. created() {
  78. this.resetFetch();
  79. },
  80. methods: {
  81. formatDate,
  82. getLevelClass(level) {
  83. if (level === "VIP") return "tag-vip";
  84. if (level === "二级") return "tag-l2";
  85. if (level === "三级") return "tag-l3";
  86. return "tag-default";
  87. },
  88. generateFakeData() {
  89. const newRows = [];
  90. const provinces = [
  91. "91370104771001730R",
  92. "91420105783155681H",
  93. "91330110MA2CCJE32Y",
  94. "91441581761581268X",
  95. "91510106768621824L",
  96. ];
  97. const startIdx = (this.pageNum - 1) * this.pageSize;
  98. const endIdx = Math.min(startIdx + this.pageSize, this.totalCount);
  99. if (startIdx >= this.totalCount) {
  100. this.hasMore = false;
  101. return [];
  102. }
  103. for (let i = startIdx; i < endIdx; i++) {
  104. newRows.push({
  105. id: i,
  106. receiverName: `测试收货企业${i + 1}有限公司`,
  107. companyCode: provinces[i % provinces.length],
  108. });
  109. }
  110. return newRows;
  111. },
  112. async onRefresh() {
  113. this.isRefreshing = true;
  114. this.pageNum = 1;
  115. this.hasMore = true;
  116. // Simulate network request
  117. setTimeout(() => {
  118. this.rows = this.generateFakeData();
  119. this.isRefreshing = false;
  120. }, 1000);
  121. },
  122. onLoadMore() {
  123. if (this.loading || !this.hasMore) return;
  124. this.loading = true;
  125. this.pageNum++;
  126. // Simulate network request
  127. setTimeout(() => {
  128. const more = this.generateFakeData();
  129. if (more.length > 0) {
  130. this.rows = [...this.rows, ...more];
  131. } else {
  132. this.hasMore = false;
  133. }
  134. this.loading = false;
  135. }, 800);
  136. },
  137. resetFetch() {
  138. this.loading = true;
  139. this.pageNum = 1;
  140. this.hasMore = true;
  141. // Simulate initial load
  142. setTimeout(() => {
  143. this.rows = this.generateFakeData();
  144. this.loading = false;
  145. }, 500);
  146. },
  147. toDetail(item) {
  148. uni.navigateTo({
  149. url: `/traceCodePackages/traceabilityReport/pages/blacklist/detail/index?id=${item.id}&name=${encodeURIComponent(item.receiverName)}`,
  150. });
  151. },
  152. handleExport() {
  153. uni.showModal({
  154. title: "导出至邮箱",
  155. editable: true,
  156. placeholderText: "请输入邮箱地址",
  157. success: (res) => {
  158. if (res.confirm) {
  159. if (!res.content) {
  160. uni.showToast({
  161. title: "请输入邮箱",
  162. icon: "none",
  163. });
  164. return;
  165. }
  166. uni.showToast({
  167. title: "导出请求已发送",
  168. icon: "success",
  169. });
  170. }
  171. },
  172. });
  173. },
  174. },
  175. };
  176. </script>
  177. <style scoped>
  178. .detail-page {
  179. display: flex;
  180. flex-direction: column;
  181. height: calc(100vh - 116rpx - env(safe-area-inset-bottom));
  182. box-sizing: border-box;
  183. background: #f3f6f9;
  184. }
  185. .tip {
  186. font-size: 24rpx;
  187. color: #999;
  188. padding: 24rpx;
  189. background: #f3f6f9;
  190. }
  191. .list-scroll {
  192. flex: 1;
  193. height: 0; /* Important for flex expansion */
  194. padding: 0 24rpx;
  195. box-sizing: border-box;
  196. }
  197. .list-container {
  198. padding-bottom: calc(50rpx + env(safe-area-inset-bottom));
  199. }
  200. .card-item {
  201. display: flex;
  202. justify-content: space-between;
  203. align-items: flex-start; /* Align top */
  204. background: #fff;
  205. border-radius: 16rpx;
  206. padding: 30rpx;
  207. margin-bottom: 20rpx;
  208. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  209. }
  210. .left-info {
  211. flex: 1;
  212. margin-right: 20rpx;
  213. }
  214. .row1-name {
  215. font-size: 30rpx;
  216. font-weight: bold;
  217. color: #1890ff;
  218. margin-bottom: 16rpx;
  219. text-decoration: underline;
  220. }
  221. .row2-info {
  222. display: flex;
  223. align-items: center;
  224. margin-bottom: 12rpx;
  225. }
  226. .province {
  227. font-size: 26rpx;
  228. color: #666;
  229. margin-right: 20rpx;
  230. }
  231. .level-tag {
  232. font-size: 22rpx;
  233. padding: 4rpx 12rpx;
  234. border-radius: 6rpx;
  235. background: #f0f0f0;
  236. color: #666;
  237. }
  238. .tag-vip {
  239. background: #e6f7ff;
  240. color: #1890ff;
  241. }
  242. .tag-l2 {
  243. background: #f6ffed;
  244. color: #52c41a;
  245. }
  246. .tag-l3 {
  247. background: #fff7e6;
  248. color: #fa8c16;
  249. }
  250. .row3-nature {
  251. font-size: 26rpx;
  252. color: #666;
  253. margin-bottom: 12rpx;
  254. }
  255. .row4-manager {
  256. font-size: 26rpx;
  257. color: #666;
  258. }
  259. .right-info {
  260. display: flex;
  261. align-items: center;
  262. align-self: center; /* Center vertically relative to card */
  263. }
  264. .alert-count {
  265. background: #fff2f0;
  266. color: #ff4d4f;
  267. font-size: 24rpx;
  268. padding: 8rpx 20rpx;
  269. border-radius: 30rpx;
  270. font-weight: bold;
  271. }
  272. .loading-more {
  273. display: flex;
  274. justify-content: center;
  275. align-items: center;
  276. padding: 20rpx 0;
  277. }
  278. .loading-icon {
  279. width: 32rpx;
  280. height: 32rpx;
  281. margin-right: 10rpx;
  282. animation: spin 1s linear infinite;
  283. }
  284. .empty-data {
  285. display: flex;
  286. justify-content: center;
  287. padding-top: 100rpx;
  288. }
  289. .no-more {
  290. text-align: center;
  291. color: #999;
  292. font-size: 24rpx;
  293. padding: 20rpx 0;
  294. }
  295. @keyframes spin {
  296. from {
  297. transform: rotate(0deg);
  298. }
  299. to {
  300. transform: rotate(360deg);
  301. }
  302. }
  303. .footer-btn-area {
  304. padding: 24rpx 32rpx calc(24rpx + env(safe-area-inset-bottom));
  305. background: #fff;
  306. box-shadow: 0 -4rpx 16rpx rgba(0, 0, 0, 0.05);
  307. position: fixed;
  308. z-index: 10;
  309. bottom: 0;
  310. width: 100%;
  311. box-sizing: border-box;
  312. }
  313. .export-btn {
  314. background: linear-gradient(135deg, #1890ff 0%, #096dd9 100%);
  315. color: #fff;
  316. border-radius: 44rpx;
  317. font-size: 32rpx;
  318. font-weight: 500;
  319. height: 88rpx;
  320. line-height: 88rpx;
  321. border: none;
  322. box-shadow: 0 6rpx 16rpx rgba(24, 144, 255, 0.35);
  323. transition: all 0.3s;
  324. }
  325. .export-btn:active {
  326. transform: scale(0.98);
  327. box-shadow: 0 2rpx 8rpx rgba(24, 144, 255, 0.35);
  328. }
  329. .export-btn::after {
  330. border: none;
  331. }
  332. </style>