| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- <template>
- <view class="detail-page">
- <view class="tip"
- >数据更新时间:{{
- formatDate(
- new Date().setDate(new Date().getDate() - 1),
- "YYYY-MM-DD",
- ) || "--"
- }}</view
- >
- <scroll-view
- class="list-scroll"
- scroll-y="true"
- refresher-enabled
- :refresher-triggered="isRefreshing"
- @refresherrefresh="onRefresh"
- @scrolltolower="onLoadMore"
- >
- <view class="list-container">
- <view
- class="card-item"
- v-for="(item, index) in rows"
- :key="index"
- @click="toDetail(item)"
- >
- <view class="left-info">
- <view class="row1-name">{{ item.receiverName }}</view>
- <view class="row4-manager">信用代码:{{ item.companyCode }}</view>
- </view>
- </view>
- <view class="loading-more" v-if="loading">
- <image
- class="loading-icon"
- src="../../../static/images/loading.png"
- />
- </view>
- <view v-if="!loading && rows.length === 0" class="empty-data">
- <EmptyView text="无相关数据" />
- </view>
- <view v-if="!hasMore && rows.length > 0" class="no-more">
- <text>没有更多数据了</text>
- </view>
- </view>
- </scroll-view>
- </view>
- </template>
- <script>
- import EmptyView from "../../../wigets/empty.vue";
- import request from "../../../request/index.js";
- import { formatDate } from "../../../utils/utils.js";
- export default {
- components: {
- EmptyView,
- },
- data() {
- return {
- isRefreshing: false,
- loading: false,
- rows: [],
- totalCount: 60, // Simulated total count
- hasMore: true,
- pageNum: 1,
- pageSize: 20,
- };
- },
- created() {
- this.resetFetch();
- },
- methods: {
- formatDate,
- getLevelClass(level) {
- if (level === "VIP") return "tag-vip";
- if (level === "二级") return "tag-l2";
- if (level === "三级") return "tag-l3";
- return "tag-default";
- },
- generateFakeData() {
- const newRows = [];
- const provinces = [
- "91370104771001730R",
- "91420105783155681H",
- "91330110MA2CCJE32Y",
- "91441581761581268X",
- "91510106768621824L",
- ];
- const startIdx = (this.pageNum - 1) * this.pageSize;
- const endIdx = Math.min(startIdx + this.pageSize, this.totalCount);
- if (startIdx >= this.totalCount) {
- this.hasMore = false;
- return [];
- }
- for (let i = startIdx; i < endIdx; i++) {
- newRows.push({
- id: i,
- receiverName: `测试收货企业${i + 1}有限公司`,
- companyCode: provinces[i % provinces.length],
- });
- }
- return newRows;
- },
- async onRefresh() {
- this.isRefreshing = true;
- this.pageNum = 1;
- this.hasMore = true;
- // Simulate network request
- setTimeout(() => {
- this.rows = this.generateFakeData();
- this.isRefreshing = false;
- }, 1000);
- },
- onLoadMore() {
- if (this.loading || !this.hasMore) return;
- this.loading = true;
- this.pageNum++;
- // Simulate network request
- setTimeout(() => {
- const more = this.generateFakeData();
- if (more.length > 0) {
- this.rows = [...this.rows, ...more];
- } else {
- this.hasMore = false;
- }
- this.loading = false;
- }, 800);
- },
- resetFetch() {
- this.loading = true;
- this.pageNum = 1;
- this.hasMore = true;
- // Simulate initial load
- setTimeout(() => {
- this.rows = this.generateFakeData();
- this.loading = false;
- }, 500);
- },
- toDetail(item) {
- uni.navigateTo({
- url: `/traceCodePackages/traceabilityReport/pages/blacklist/detail/index?id=${item.id}&name=${encodeURIComponent(item.receiverName)}`,
- });
- },
- },
- };
- </script>
- <style scoped>
- .detail-page {
- display: flex;
- flex-direction: column;
- height: calc(100vh - 116rpx - env(safe-area-inset-bottom));
- box-sizing: border-box;
- background: #f3f6f9;
- }
- .tip {
- font-size: 24rpx;
- color: #999;
- padding: 24rpx;
- background: #f3f6f9;
- }
- .list-scroll {
- flex: 1;
- height: 0; /* Important for flex expansion */
- padding: 0 24rpx;
- box-sizing: border-box;
- }
- .list-container {
- padding-bottom: calc(50rpx + env(safe-area-inset-bottom));
- }
- .card-item {
- display: flex;
- justify-content: space-between;
- align-items: flex-start; /* Align top */
- background: #fff;
- border-radius: 16rpx;
- padding: 30rpx;
- margin-bottom: 20rpx;
- box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
- }
- .left-info {
- flex: 1;
- margin-right: 20rpx;
- }
- .row1-name {
- font-size: 30rpx;
- font-weight: bold;
- color: #1890ff;
- margin-bottom: 16rpx;
- }
- .row2-info {
- display: flex;
- align-items: center;
- margin-bottom: 12rpx;
- }
- .province {
- font-size: 26rpx;
- color: #666;
- margin-right: 20rpx;
- }
- .level-tag {
- font-size: 22rpx;
- padding: 4rpx 12rpx;
- border-radius: 6rpx;
- background: #f0f0f0;
- color: #666;
- }
- .tag-vip {
- background: #e6f7ff;
- color: #1890ff;
- }
- .tag-l2 {
- background: #f6ffed;
- color: #52c41a;
- }
- .tag-l3 {
- background: #fff7e6;
- color: #fa8c16;
- }
- .row3-nature {
- font-size: 26rpx;
- color: #666;
- margin-bottom: 12rpx;
- }
- .row4-manager {
- font-size: 26rpx;
- color: #666;
- }
- .right-info {
- display: flex;
- align-items: center;
- align-self: center; /* Center vertically relative to card */
- }
- .alert-count {
- background: #fff2f0;
- color: #ff4d4f;
- font-size: 24rpx;
- padding: 8rpx 20rpx;
- border-radius: 30rpx;
- font-weight: bold;
- }
- .loading-more {
- display: flex;
- justify-content: center;
- align-items: center;
- padding: 20rpx 0;
- }
- .loading-icon {
- width: 32rpx;
- height: 32rpx;
- margin-right: 10rpx;
- animation: spin 1s linear infinite;
- }
- .empty-data {
- display: flex;
- justify-content: center;
- padding-top: 100rpx;
- }
- .no-more {
- text-align: center;
- color: #999;
- font-size: 24rpx;
- padding: 20rpx 0;
- }
- @keyframes spin {
- from {
- transform: rotate(0deg);
- }
- to {
- transform: rotate(360deg);
- }
- }
- </style>
|