index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <template>
  2. <view class="history-page">
  3. <view class="header-section">
  4. <view class="header-title">历史记录</view>
  5. <view class="filter-tabs">
  6. <view
  7. class="tab-item"
  8. v-for="(tab, index) in timeFilters"
  9. :key="index"
  10. :class="{ active: currentFilter === tab.value }"
  11. @click="switchFilter(tab.value)"
  12. >
  13. {{ tab.label }}
  14. </view>
  15. </view>
  16. </view>
  17. <scroll-view
  18. class="list-scroll"
  19. scroll-y="true"
  20. refresher-enabled
  21. :refresher-triggered="isRefreshing"
  22. @refresherrefresh="onRefresh"
  23. @scrolltolower="onLoadMore"
  24. >
  25. <view class="list-container">
  26. <view
  27. class="card-item"
  28. v-for="(item, index) in displayRows"
  29. :key="index"
  30. >
  31. <view class="card-header">
  32. <view class="header-left">
  33. <text class="date-text">{{ item.date }}</text>
  34. </view>
  35. <view class="header-right">
  36. <text class="status-tag">黑名单</text>
  37. </view>
  38. </view>
  39. <view class="card-body">
  40. <view class="row">
  41. <text class="label">公司名称:</text>
  42. <text class="value">{{ item.receiverName }}</text>
  43. </view>
  44. <view class="code-row">
  45. <text class="label">信用代码:</text>
  46. <text class="value code-text">{{ item.companyCode }}</text>
  47. </view>
  48. <view class="info-grid">
  49. <view class="info-item">
  50. <text class="label">省份</text>
  51. <text class="value">{{ item.receiverProvince }}</text>
  52. </view>
  53. <view class="info-item">
  54. <text class="label">性质</text>
  55. <text class="value">{{ item.customerNature }}</text>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="loading-more" v-if="loading">
  61. <image
  62. class="loading-icon"
  63. src="../../../../static/images/loading.png"
  64. />
  65. <text class="loading-text">加载中...</text>
  66. </view>
  67. <view v-if="!loading && displayRows.length === 0" class="empty-data">
  68. <EmptyView text="暂无历史记录" />
  69. </view>
  70. <view v-if="!hasMore && displayRows.length > 0" class="no-more">
  71. <text>没有更多数据了</text>
  72. </view>
  73. </view>
  74. </scroll-view>
  75. </view>
  76. </template>
  77. <script>
  78. import EmptyView from "../../../../wigets/empty.vue";
  79. import { formatDate } from "../../../../utils/utils.js";
  80. const PROVINCES = ["北京市", "上海市", "广东省", "浙江省", "江苏省"];
  81. const NATURES = ["协议客户", "非协议客户", "商业客户", "终端客户"];
  82. export default {
  83. components: {
  84. EmptyView,
  85. },
  86. data() {
  87. return {
  88. isRefreshing: false,
  89. loading: false,
  90. rows: [],
  91. hasMore: true,
  92. pageNum: 1,
  93. pageSize: 20,
  94. currentFilter: "all",
  95. timeFilters: [
  96. { label: "全部", value: "all" },
  97. { label: "近7天", value: "7" },
  98. { label: "近15天", value: "15" },
  99. { label: "近30天", value: "30" },
  100. ],
  101. };
  102. },
  103. computed: {
  104. displayRows() {
  105. return this.rows;
  106. },
  107. },
  108. created() {
  109. this.resetFetch();
  110. },
  111. methods: {
  112. formatDate,
  113. switchFilter(value) {
  114. if (this.currentFilter === value) return;
  115. this.currentFilter = value;
  116. this.resetFetch();
  117. },
  118. generateFakeData() {
  119. const newRows = [];
  120. const count = 15;
  121. const today = new Date();
  122. const codes = [
  123. "91370104771001730R",
  124. "91420105783155681H",
  125. "91330110MA2CCJE32Y",
  126. "91441581761581268X",
  127. "91510106768621824L",
  128. ];
  129. for (let i = 0; i < count; i++) {
  130. const date = new Date(today);
  131. const daysBack = Math.floor(Math.random() * 30);
  132. if (this.currentFilter !== "all") {
  133. const limit = parseInt(this.currentFilter);
  134. if (daysBack > limit) continue;
  135. }
  136. date.setDate(date.getDate() - daysBack);
  137. newRows.push({
  138. id: Math.random().toString(36).substr(2, 9),
  139. date: formatDate(date, "YYYY-MM-DD"),
  140. receiverName: `黑名单企业${Math.floor(Math.random() * 100)}有限公司`,
  141. companyCode: codes[Math.floor(Math.random() * codes.length)],
  142. receiverProvince:
  143. PROVINCES[Math.floor(Math.random() * PROVINCES.length)],
  144. customerNature: NATURES[Math.floor(Math.random() * NATURES.length)],
  145. });
  146. }
  147. newRows.sort((a, b) => new Date(b.date) - new Date(a.date));
  148. return newRows;
  149. },
  150. async onRefresh() {
  151. this.isRefreshing = true;
  152. this.pageNum = 1;
  153. this.hasMore = true;
  154. setTimeout(() => {
  155. this.rows = this.generateFakeData();
  156. this.isRefreshing = false;
  157. }, 1000);
  158. },
  159. onLoadMore() {
  160. if (this.loading || !this.hasMore) return;
  161. this.loading = true;
  162. this.pageNum++;
  163. setTimeout(() => {
  164. const more = this.generateFakeData();
  165. if (more.length > 0) {
  166. this.rows = [...this.rows, ...more];
  167. } else {
  168. this.hasMore = false;
  169. }
  170. this.loading = false;
  171. }, 800);
  172. },
  173. resetFetch() {
  174. this.loading = true;
  175. this.pageNum = 1;
  176. this.hasMore = true;
  177. this.rows = [];
  178. setTimeout(() => {
  179. this.rows = this.generateFakeData();
  180. this.loading = false;
  181. }, 500);
  182. },
  183. },
  184. };
  185. </script>
  186. <style scoped>
  187. .history-page {
  188. display: flex;
  189. flex-direction: column;
  190. height: 100vh;
  191. background: #f5f7fa;
  192. }
  193. .header-section {
  194. background: linear-gradient(135deg, #2b32b2 0%, #1488cc 100%);
  195. padding: 30rpx 30rpx 60rpx;
  196. color: #fff;
  197. border-bottom-left-radius: 40rpx;
  198. border-bottom-right-radius: 40rpx;
  199. box-shadow: 0 10rpx 30rpx rgba(20, 136, 204, 0.2);
  200. z-index: 10;
  201. position: relative;
  202. }
  203. .header-title {
  204. font-size: 36rpx;
  205. font-weight: bold;
  206. text-align: center;
  207. margin-bottom: 30rpx;
  208. }
  209. .filter-tabs {
  210. display: flex;
  211. background: rgba(255, 255, 255, 0.2);
  212. border-radius: 16rpx;
  213. padding: 8rpx;
  214. }
  215. .tab-item {
  216. flex: 1;
  217. text-align: center;
  218. font-size: 26rpx;
  219. padding: 12rpx 0;
  220. border-radius: 12rpx;
  221. color: rgba(255, 255, 255, 0.8);
  222. transition: all 0.3s;
  223. }
  224. .tab-item.active {
  225. background: #fff;
  226. color: #2b32b2;
  227. font-weight: 600;
  228. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
  229. }
  230. .list-scroll {
  231. flex: 1;
  232. height: 0;
  233. margin-top: -40rpx;
  234. z-index: 11;
  235. padding: 0 24rpx;
  236. box-sizing: border-box;
  237. }
  238. .list-container {
  239. padding-bottom: 40rpx;
  240. }
  241. .card-item {
  242. background: #fff;
  243. border-radius: 20rpx;
  244. padding: 30rpx;
  245. margin-bottom: 24rpx;
  246. box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.05);
  247. }
  248. .card-header {
  249. display: flex;
  250. justify-content: space-between;
  251. align-items: center;
  252. margin-bottom: 20rpx;
  253. padding-bottom: 20rpx;
  254. border-bottom: 1rpx solid #f5f5f5;
  255. }
  256. .date-text {
  257. font-size: 28rpx;
  258. font-weight: 600;
  259. color: #333;
  260. }
  261. .status-tag {
  262. font-size: 20rpx;
  263. padding: 4rpx 12rpx;
  264. border-radius: 8rpx;
  265. background: #fff1f0;
  266. color: #f5222d;
  267. font-weight: 500;
  268. }
  269. .card-body {
  270. font-size: 26rpx;
  271. }
  272. .row {
  273. display: flex;
  274. margin-bottom: 16rpx;
  275. }
  276. .code-row {
  277. display: flex;
  278. align-items: center;
  279. margin-bottom: 16rpx;
  280. }
  281. .code-text {
  282. font-family: monospace;
  283. color: #333 !important;
  284. font-weight: 600 !important;
  285. }
  286. .info-grid {
  287. display: flex;
  288. justify-content: space-between;
  289. }
  290. .info-item {
  291. display: flex;
  292. align-items: center;
  293. width: 48%;
  294. }
  295. .label {
  296. color: #999;
  297. margin-right: 12rpx;
  298. }
  299. .value {
  300. color: #666;
  301. font-weight: 500;
  302. }
  303. .loading-more,
  304. .no-more,
  305. .empty-data {
  306. display: flex;
  307. justify-content: center;
  308. align-items: center;
  309. padding: 30rpx 0;
  310. color: #999;
  311. font-size: 24rpx;
  312. }
  313. .loading-icon {
  314. width: 32rpx;
  315. height: 32rpx;
  316. margin-right: 12rpx;
  317. animation: spin 1s linear infinite;
  318. }
  319. @keyframes spin {
  320. from {
  321. transform: rotate(0deg);
  322. }
  323. to {
  324. transform: rotate(360deg);
  325. }
  326. }
  327. </style>