style: 优化移动端个人中心与订单界面 UI,采用统一白灰色调并去除突兀色块

This commit is contained in:
yml
2026-05-25 09:20:18 +08:00
parent 26ee082b95
commit 5d8a009935
3 changed files with 644 additions and 241 deletions
+190 -141
View File
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { onMounted, ref, computed } from "vue";
import { useRouter } from "vue-router";
import { useRouter, useRoute } from "vue-router";
import { showToast } from "vant";
import MobileBottomNav from "@/components/MobileBottomNav.vue";
@@ -9,13 +9,19 @@ import { useSessionStore } from "@/stores/session";
import { formatDateMinute } from "@/utils/time";
const router = useRouter();
const route = useRoute();
const session = useSessionStore();
const loading = ref(false);
const orders = ref<Order[]>([]);
const activeTab = ref("all");
const payingOrderId = ref<number | null>(null);
onMounted(loadOrders);
onMounted(() => {
loadOrders();
if (route.query.tab) {
activeTab.value = String(route.query.tab);
}
});
async function loadOrders() {
loading.value = true;
@@ -43,26 +49,6 @@ const displayOrders = computed(() => {
return orders.value.filter((o) => o.status === activeTab.value);
});
/* 状态颜色映射 */
function statusColor(status: string) {
const map: Record<string, string> = {
pending_payment: "#ff6a00",
pending_handoff: "#ff9800",
renting: "#1477ff",
overdue: "#e91e63",
pending_return_confirm: "#e91e63",
pending_checkout_confirm: "#e91e63",
pending_checkout_accept: "#9c27b0",
checkout_disputing: "#f44336",
completed: "#4caf50",
cancelled: "#999",
disputing: "#f44336",
abnormal: "#f44336",
closed: "#666",
};
return map[status] || "#999";
}
function statusLabel(status: string) {
const map: Record<string, string> = {
pending_payment: "待支付",
@@ -70,8 +56,8 @@ function statusLabel(status: string) {
renting: "使用中",
overdue: "已逾期",
pending_return_confirm: "待结账",
pending_checkout_confirm: "待号主确认结账",
pending_checkout_accept: "待租客确认修正",
pending_checkout_confirm: "待号主确认",
pending_checkout_accept: "待租客确认",
checkout_disputing: "结账争议中",
completed: "已完成",
cancelled: "已取消",
@@ -120,18 +106,26 @@ function readError(error: unknown, fallback: string) {
<span class="header-spacer"></span>
</header>
<!-- 状态筛选条 -->
<div class="status-tabs">
<button
<!-- 状态筛选条 - Vant 滑动标签页 -->
<van-tabs
v-model:active="activeTab"
class="custom-tabs"
line-width="20px"
line-height="3px"
color="#1477ff"
title-active-color="#1477ff"
title-inactive-color="#6b7280"
:border="false"
swipeable
animated
>
<van-tab
v-for="tab in statusTabs"
:key="tab.key"
class="tab-btn"
:class="{ active: activeTab === tab.key }"
@click="activeTab = tab.key"
>
{{ tab.label }}
</button>
</div>
:title="tab.label"
:name="tab.key"
/>
</van-tabs>
<!-- 订单列表 -->
<section class="order-list">
@@ -139,12 +133,12 @@ function readError(error: unknown, fallback: string) {
加载中...
</van-loading>
<div v-else-if="displayOrders.length === 0" class="empty-state">
<van-icon name="orders-o" :size="48" color="#ccc" />
<p>暂无订单</p>
<div v-else-if="displayOrders.length === 0" class="empty-state-wrap">
<van-empty description="暂无相关订单" image="search" />
</div>
<div
v-else
v-for="order in displayOrders"
:key="order.id"
class="order-card"
@@ -152,11 +146,10 @@ function readError(error: unknown, fallback: string) {
>
<!-- 卡片头:订单号 + 状态 -->
<div class="card-header">
<span class="order-no">{{ order.order_no }}</span>
<span
class="status-badge"
:style="{ background: statusColor(order.status) }"
>
<div class="header-left">
<span class="order-no">{{ order.order_no }}</span>
</div>
<span class="status-badge" :class="'badge-' + order.status">
{{ statusLabel(order.status) }}
</span>
</div>
@@ -164,35 +157,45 @@ function readError(error: unknown, fallback: string) {
<!-- 卡片体:关键信息 -->
<div class="card-body">
<h3 class="order-title">{{ order.title }}</h3>
<div class="info-grid">
<div class="info-item">
<span class="info-label">订单金额</span>
<span class="info-value price">¥{{ order.rent_amount }}</span>
<div class="tag-row">
<span class="info-tag">{{ order.server_region }}</span>
<span class="info-tag">{{ order.login_platform }}</span>
</div>
<div class="price-row">
<div class="price-item">
<span class="price-label">买家实付租金</span>
<span class="price-val">¥{{ order.rent_amount }}</span>
</div>
<div class="info-item">
<span class="info-label">押金</span>
<span class="info-value">¥{{ order.deposit_amount }}</span>
</div>
<div class="info-item">
<span class="info-label">区服</span>
<span class="info-value">{{ order.server_region }}</span>
<div class="price-item">
<span class="price-label">押金金额</span>
<span class="price-val deposit">¥{{ order.deposit_amount }}</span>
</div>
</div>
</div>
<!-- 卡片底:时间 + 操作 -->
<div class="card-footer">
<span class="order-time">{{ formatDateMinute(order.created_at) }}</span>
<van-button
v-if="order.status === 'pending_payment' && order.renter_id === session.userId"
size="mini"
type="primary"
:loading="payingOrderId === order.id"
@click.stop="handlePay(order)"
>
支付
</van-button>
<span v-else class="detail-link">查看详情 ›</span>
<div class="time-box">
<van-icon name="clock-o" class="clock-icon" />
<span class="order-time">{{ formatDateMinute(order.created_at) }}</span>
</div>
<div class="footer-action">
<van-button
v-if="order.status === 'pending_payment' && order.renter_id === session.userId"
size="small"
type="warning"
round
class="pay-btn"
:loading="payingOrderId === order.id"
@click.stop="handlePay(order)"
>
去支付
</van-button>
<span v-else class="detail-link">
查看详情 <van-icon name="arrow" :size="10" />
</span>
</div>
</div>
</div>
</section>
@@ -205,21 +208,22 @@ function readError(error: unknown, fallback: string) {
<style scoped>
.mobile-orders {
min-height: 100dvh;
background: #f5f7fa;
padding-bottom: calc(56px + env(safe-area-inset-bottom));
background: #f6f8fa;
padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
/* ========== 顶部导航 ========== */
.page-header {
position: sticky;
top: 0;
z-index: 10;
z-index: 100;
display: flex;
align-items: center;
height: 48px;
padding: 0 12px;
background: #fff;
border-bottom: 1px solid #eee;
background: rgba(255, 255, 255, 0.94);
backdrop-filter: blur(10px);
border-bottom: 1px solid rgba(243, 244, 246, 0.8);
}
.page-header h1 {
@@ -228,6 +232,7 @@ function readError(error: unknown, fallback: string) {
font-size: 17px;
font-weight: 700;
text-align: center;
color: #111827;
}
.back-btn {
@@ -237,7 +242,7 @@ function readError(error: unknown, fallback: string) {
place-items: center;
border: none;
background: none;
color: #333;
color: #374151;
cursor: pointer;
}
@@ -245,39 +250,29 @@ function readError(error: unknown, fallback: string) {
width: 36px;
}
/* ========== 状态筛选条 ========== */
.status-tabs {
display: flex;
gap: 6px;
padding: 12px 16px;
background: #fff;
border-bottom: 1px solid #f0f0f0;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
/* ========== Vant Tabs 自定义样式 ========== */
.custom-tabs {
position: sticky;
top: 48px;
z-index: 99;
background: rgba(255, 255, 255, 0.94);
backdrop-filter: blur(10px);
border-bottom: 1px solid rgba(243, 244, 246, 0.6);
}
.tab-btn {
flex-shrink: 0;
padding: 6px 14px;
border-radius: 16px;
border: 1px solid #ddd;
background: #fff;
color: #666;
font-size: 12px;
:deep(.van-tabs__nav) {
background: transparent;
padding-bottom: 4px;
}
:deep(.van-tab) {
font-size: 13px;
font-weight: 600;
cursor: pointer;
transition: all 0.15s;
}
.tab-btn.active {
background: #1477ff;
color: #fff;
border-color: #1477ff;
}
/* ========== 订单列表 ========== */
.order-list {
padding: 12px 16px;
padding: 14px 16px;
}
.center-loading {
@@ -286,108 +281,162 @@ function readError(error: unknown, fallback: string) {
padding: 60px 0;
}
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
gap: 8px;
padding: 80px 0;
color: #999;
font-size: 14px;
.empty-state-wrap {
padding: 40px 0;
}
/* ========== 订单卡片 ========== */
.order-card {
background: #fff;
border-radius: 12px;
margin-bottom: 12px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
overflow: hidden;
background: #ffffff;
border-radius: 16px;
margin-bottom: 14px;
padding: 16px;
box-shadow: 0 4px 18px rgba(0, 0, 0, 0.02), 0 1px 4px rgba(0, 0, 0, 0.02);
transition: transform 0.1s ease, box-shadow 0.1s ease;
border: 1px solid rgba(243, 244, 246, 0.9);
cursor: pointer;
transition: box-shadow 0.15s;
}
.order-card:active {
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
transform: scale(0.98);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.card-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 12px 14px 0;
padding-bottom: 10px;
border-bottom: 1px dashed #f3f4f6;
}
.order-no {
font-size: 11px;
color: #999;
color: #9ca3af;
font-family: monospace;
}
.status-badge {
display: inline-block;
padding: 2px 8px;
padding: 4px 8px;
border-radius: 8px;
color: #fff;
font-size: 11px;
font-weight: 600;
font-weight: 700;
line-height: 1;
}
/* 状态徽章颜色 - 现代轻量化配色 */
.badge-pending_payment { color: #ff6a00; background: rgba(255, 106, 0, 0.08); }
.badge-pending_handoff { color: #d97706; background: rgba(217, 119, 6, 0.08); }
.badge-renting { color: #1477ff; background: rgba(20, 119, 255, 0.08); }
.badge-overdue { color: #ef4444; background: rgba(239, 68, 68, 0.08); }
.badge-pending_return_confirm { color: #8b5cf6; background: rgba(139, 92, 246, 0.08); }
.badge-pending_checkout_confirm { color: #8b5cf6; background: rgba(139, 92, 246, 0.08); }
.badge-pending_checkout_accept { color: #a855f7; background: rgba(168, 85, 247, 0.08); }
.badge-checkout_disputing { color: #ef4444; background: rgba(239, 68, 68, 0.08); }
.badge-completed { color: #10b981; background: rgba(16, 185, 129, 0.08); }
.badge-cancelled { color: #9ca3af; background: rgba(156, 163, 175, 0.08); }
.badge-disputing { color: #ef4444; background: rgba(239, 68, 68, 0.08); }
.badge-abnormal { color: #ef4444; background: rgba(239, 68, 68, 0.08); }
.badge-closed { color: #6b7280; background: rgba(107, 114, 128, 0.08); }
.card-body {
padding: 10px 14px;
padding: 12px 0 0;
}
.order-title {
margin: 0 0 8px;
font-size: 15px;
font-weight: 700;
color: #1a1a1a;
line-height: 1.3;
color: #111827;
line-height: 1.4;
}
.info-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 6px 16px;
}
.info-item {
.tag-row {
display: flex;
justify-content: space-between;
font-size: 12px;
gap: 6px;
margin-bottom: 12px;
}
.info-label {
color: #999;
}
.info-value {
color: #333;
.info-tag {
font-size: 11px;
color: #6b7280;
background: #f3f4f6;
padding: 3px 8px;
border-radius: 6px;
font-weight: 500;
}
.info-value.price {
color: #ff5f00;
font-weight: 700;
.price-row {
display: flex;
background: #f9fafb;
border-radius: 12px;
padding: 10px 14px;
justify-content: space-between;
gap: 12px;
}
.price-item {
display: flex;
flex-direction: column;
gap: 2px;
}
.price-label {
font-size: 10px;
color: #9ca3af;
}
.price-val {
font-size: 15px;
font-weight: 800;
color: #ff5f00;
}
.price-val.deposit {
color: #374151;
}
/* ========== 卡片底部 ========== */
.card-footer {
display: flex;
align-items: center;
justify-content: space-between;
padding: 8px 14px 10px;
border-top: 1px solid #f5f5f5;
margin-top: 14px;
padding-top: 12px;
border-top: 1px solid #f3f4f6;
}
.time-box {
display: flex;
align-items: center;
gap: 4px;
color: #9ca3af;
}
.clock-icon {
font-size: 13px;
}
.order-time {
font-size: 11px;
color: #bbb;
}
.detail-link {
font-size: 12px;
color: #1477ff;
font-weight: 600;
display: flex;
align-items: center;
gap: 2px;
}
.pay-btn {
height: 28px !important;
padding: 0 16px !important;
font-size: 12px !important;
font-weight: 700 !important;
background: linear-gradient(135deg, #ff8c00, #ff5f00) !important;
border: none !important;
box-shadow: 0 4px 10px rgba(255, 95, 0, 0.2) !important;
}
</style>