feat: 迭代

This commit is contained in:
2026-05-11 12:00:18 +08:00
parent fc47868bdc
commit 2d5598dcad
2 changed files with 1209 additions and 776 deletions
File diff suppressed because it is too large Load Diff
+361 -155
View File
@@ -1,5 +1,7 @@
<template>
<view class="page-order">
<!-- 订单状态Tab -->
<view class="tab-container">
<scroll-view scroll-x class="tab-scroll" :show-scrollbar="false">
@@ -10,11 +12,8 @@
:class="['tab-item', { active: currentTab === tab.value }]"
@tap="switchTab(tab.value)"
>
<view class="tab-content">
<text class="tab-text">{{ tab.label }}</text>
<view v-if="tab.count && tab.count > 0" class="tab-badge">{{ tab.count }}</view>
</view>
<text class="tab-text">{{ tab.label }}</text>
<view v-if="tab.count && tab.count > 0" class="tab-badge">{{ tab.count }}</view>
<view v-if="currentTab === tab.value" class="tab-indicator"></view>
</view>
</view>
@@ -22,109 +21,142 @@
</view>
<!-- 订单列表 -->
<scroll-view scroll-y class="order-list" @scrolltolower="loadMore">
<!-- 订单卡片 -->
<view
v-for="order in displayOrders"
:key="order.id"
class="order-card"
@tap="goDetail(order)"
>
<!-- 订单头部 -->
<view class="order-header">
<view class="merchant-info">
<u-icon name="home-fill" :size="18" color="#FF6B35" />
<text class="merchant-name">{{ order.merchantName }}</text>
</view>
<view class="status-badge" :class="`status-${order.status}`">
<text class="status-text">{{ getStatusText(order.status) }}</text>
</view>
</view>
<!-- 订单内容 -->
<view class="order-body">
<image
v-if="order.roomImage"
:src="order.roomImage"
class="room-image"
mode="aspectFill"
/>
<view class="room-info">
<text class="room-name">{{ order.roomName }}</text>
<view class="room-meta">
<view class="meta-item">
<u-icon name="calendar" :size="14" color="#999" />
<text class="meta-text">{{ formatDateRange(order.checkInDate, order.checkOutDate) }}</text>
<scroll-view
scroll-y
class="order-list"
@scrolltolower="loadMore"
:refresher-enabled="true"
:refresher-triggered="refreshing"
@refresherrefresh="onRefresh"
>
<view class="list-container">
<!-- 订单卡片 -->
<view
v-for="order in displayOrders"
:key="order.id"
class="order-card"
@tap="goDetail(order)"
>
<!-- 订单头部 -->
<view class="order-header">
<view class="header-left">
<view class="merchant-icon">
<u-icon name="home-fill" :size="16" color="#FF6B35" />
</view>
<view class="meta-item">
<u-icon name="moon" :size="14" color="#999" />
<text class="meta-text">{{ order.nights }}</text>
<text class="merchant-name">{{ order.merchantName }}</text>
</view>
<view class="status-badge" :class="`status-${order.status}`">
<view class="status-dot"></view>
<text class="status-text">{{ getStatusText(order.status) }}</text>
</view>
</view>
<!-- 订单内容 -->
<view class="order-body">
<view class="room-image-wrapper">
<image
v-if="order.roomImage"
:src="order.roomImage"
class="room-image"
mode="aspectFill"
/>
<view v-else class="room-image-placeholder">
<u-icon name="photo" :size="40" color="#CCCCCC" />
</view>
</view>
<view class="price-row">
<text class="price-label">实付金额</text>
<view class="price-value">
<text class="price-symbol">¥</text>
<text class="price-amount">{{ order.totalAmount }}</text>
<view class="room-info">
<text class="room-name">{{ order.roomName }}</text>
<view class="room-details">
<view class="detail-row">
<view class="detail-icon">
<u-icon name="calendar" :size="12" color="#999" />
</view>
<text class="detail-text">{{ formatDateRange(order.checkInDate, order.checkOutDate) }}</text>
</view>
<view class="detail-row">
<view class="detail-icon">
<u-icon name="clock" :size="12" color="#999" />
</view>
<text class="detail-text">{{ order.nights }}</text>
</view>
</view>
<view class="price-section">
<view class="price-main">
<text class="price-symbol">¥</text>
<text class="price-amount">{{ order.totalAmount }}</text>
</view>
<text class="price-label">实付</text>
</view>
</view>
</view>
<!-- 订单底部操作 -->
<view v-if="getActions(order.status).length > 0" class="order-footer">
<view class="order-no">
<text class="no-label">订单号</text>
<text class="no-value">{{ order.orderNo }}</text>
</view>
<view class="footer-actions">
<view
v-for="action in getActions(order.status)"
:key="action.type"
:class="['action-btn', `btn-${action.style}`]"
@tap.stop="handleOrderAction(action.type, order)"
>
<text class="btn-text">{{ action.text }}</text>
</view>
</view>
</view>
</view>
<!-- 订单底部操作 -->
<view v-if="getActions(order.status).length > 0" class="order-footer">
<view class="footer-actions">
<view
v-for="action in getActions(order.status)"
:key="action.type"
:class="['action-btn', `btn-${action.style}`]"
@tap.stop="handleOrderAction(action.type, order)"
>
<text class="btn-text">{{ action.text }}</text>
<!-- 加载更多 -->
<view v-if="loading && orderList.length > 0" class="loading-more">
<view class="loading-spinner">
<view class="spinner-dot"></view>
<view class="spinner-dot"></view>
<view class="spinner-dot"></view>
</view>
<text class="loading-text">加载中...</text>
</view>
<!-- 没有更多 -->
<view v-if="!hasMore && orderList.length > 0" class="no-more">
<view class="no-more-line"></view>
<text class="no-more-text">已经到底了</text>
<view class="no-more-line"></view>
</view>
<!-- 空状态 -->
<view v-if="orderList.length === 0 && !loading" class="empty-state">
<view class="empty-icon">
<u-icon name="file-text" :size="80" color="#E5E5E5" />
</view>
<text class="empty-title">{{ getEmptyTitle() }}</text>
<text class="empty-desc">{{ getEmptyDesc() }}</text>
<view v-if="currentTab === ''" class="empty-action" @tap="goHome">
<u-icon name="search" :size="16" color="#ffffff" />
<text class="action-text">去预订房源</text>
</view>
</view>
<!-- 首次加载骨架屏 -->
<view v-if="loading && orderList.length === 0" class="loading-state">
<view v-for="i in 3" :key="i" class="skeleton-card">
<view class="skeleton-header">
<view class="skeleton-line skeleton-merchant"></view>
<view class="skeleton-line skeleton-status"></view>
</view>
</view>
</view>
</view>
<!-- 加载更多 -->
<view v-if="loading && orderList.length > 0" class="loading-more">
<u-icon name="loading" :size="20" color="#999" />
<text class="loading-text">加载中...</text>
</view>
<!-- 没有更多 -->
<view v-if="!hasMore && orderList.length > 0" class="no-more">
<view class="no-more-line"></view>
<text class="no-more-text">没有更多订单了</text>
<view class="no-more-line"></view>
</view>
<!-- 空状态 -->
<view v-if="orderList.length === 0 && !loading" class="empty-state">
<view class="empty-icon">
<u-icon name="file-text" :size="80" color="#CCCCCC" />
</view>
<text class="empty-title">{{ getEmptyTitle() }}</text>
<text class="empty-desc">{{ getEmptyDesc() }}</text>
<view v-if="currentTab === ''" class="empty-action" @tap="goHome">
<text class="action-text">去预订</text>
<u-icon name="arrow-right" :size="14" color="#FF6B35" />
</view>
</view>
<!-- 首次加载 -->
<view v-if="loading && orderList.length === 0" class="loading-state">
<view v-for="i in 3" :key="i" class="skeleton-card">
<view class="skeleton-header">
<view class="skeleton-line skeleton-merchant"></view>
<view class="skeleton-line skeleton-status"></view>
</view>
<view class="skeleton-body">
<view class="skeleton-image"></view>
<view class="skeleton-info">
<view class="skeleton-line skeleton-title"></view>
<view class="skeleton-line skeleton-meta"></view>
<view class="skeleton-line skeleton-price"></view>
<view class="skeleton-body">
<view class="skeleton-image"></view>
<view class="skeleton-info">
<view class="skeleton-line skeleton-title"></view>
<view class="skeleton-line skeleton-meta"></view>
<view class="skeleton-line skeleton-price"></view>
</view>
</view>
</view>
</view>
@@ -156,6 +188,7 @@ const currentTab = ref('');
const page = ref(1);
const loading = ref(false);
const hasMore = ref(true);
const refreshing = ref(false);
// 转换订单数据格式
const displayOrders = computed(() => {
@@ -274,6 +307,7 @@ async function fetchOrders(reset = false) {
uni.showToast({ title: '加载失败,请重试', icon: 'none' });
} finally {
loading.value = false;
refreshing.value = false;
}
}
@@ -290,6 +324,12 @@ function loadMore() {
fetchOrders();
}
// 下拉刷新
function onRefresh() {
refreshing.value = true;
fetchOrders(true);
}
// 跳转订单详情
function goDetail(order: any) {
uni.navigateTo({ url: `/pages/order-detail/index?id=${order.id}` });
@@ -377,7 +417,27 @@ onMounted(() => {
height: 100vh;
display: flex;
flex-direction: column;
background: #F5F7FA;
background: linear-gradient(180deg, #FFF5F0 0%, #F5F7FA 100%);
}
/* ========== 自定义导航栏 ========== */
.custom-navbar {
background: #ffffff;
padding: 0 24rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
}
.navbar-content {
height: 88rpx;
display: flex;
align-items: center;
justify-content: center;
}
.navbar-title {
font-size: 32rpx;
font-weight: 600;
color: #1A1A1A;
}
/* ========== Tab栏 ========== */
@@ -405,7 +465,8 @@ onMounted(() => {
flex-direction: column;
align-items: center;
justify-content: center;
padding: 24rpx 0;
padding: 20rpx 0;
gap: 8rpx;
transition: all 0.3s ease;
&:active {
@@ -413,16 +474,23 @@ onMounted(() => {
}
}
.tab-content {
.tab-icon-wrapper {
width: 48rpx;
height: 48rpx;
border-radius: 50%;
display: flex;
flex-direction: column;
align-items: center;
gap: 8rpx;
position: relative;
justify-content: center;
background: #F5F7FA;
transition: all 0.3s ease;
&.active {
background: linear-gradient(135deg, #FFF5F0 0%, #FFE8DD 100%);
}
}
.tab-text {
font-size: 26rpx;
font-size: 24rpx;
color: #999;
transition: all 0.3s ease;
font-weight: 500;
@@ -435,12 +503,12 @@ onMounted(() => {
.tab-badge {
position: absolute;
top: -8rpx;
right: -24rpx;
top: 0;
right: 8rpx;
min-width: 32rpx;
height: 32rpx;
padding: 0 8rpx;
background: #FF4D4F;
background: linear-gradient(135deg, #FF6B35 0%, #FF4D4F 100%);
border-radius: 16rpx;
display: flex;
align-items: center;
@@ -449,6 +517,7 @@ onMounted(() => {
color: #ffffff;
font-weight: 600;
line-height: 1;
box-shadow: 0 2rpx 8rpx rgba(255, 77, 79, 0.3);
}
.tab-indicator {
@@ -456,7 +525,7 @@ onMounted(() => {
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 40rpx;
width: 32rpx;
height: 6rpx;
background: linear-gradient(135deg, #FF8C5A 0%, #FF6B35 100%);
border-radius: 3rpx;
@@ -469,7 +538,7 @@ onMounted(() => {
opacity: 0;
}
to {
width: 40rpx;
width: 32rpx;
opacity: 1;
}
}
@@ -477,8 +546,11 @@ onMounted(() => {
/* ========== 订单列表 ========== */
.order-list {
flex: 1;
padding: 24rpx 24rpx;
box-sizing: border-box;
overflow-y: auto;
}
.list-container {
padding: 24rpx;
}
/* ========== 订单卡片 ========== */
@@ -489,9 +561,21 @@ onMounted(() => {
overflow: hidden;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
transition: all 0.3s ease;
position: relative;
&::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 6rpx;
height: 100%;
background: linear-gradient(180deg, #FF8C5A 0%, #FF6B35 100%);
}
&:active {
transform: scale(0.98);
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
}
}
@@ -500,11 +584,11 @@ onMounted(() => {
display: flex;
align-items: center;
justify-content: space-between;
padding: 24rpx 28rpx;
border-bottom: 1rpx solid #F0F0F0;
padding: 20rpx 24rpx 20rpx 32rpx;
background: linear-gradient(135deg, #FFFBF8 0%, #FFF5F0 100%);
}
.merchant-info {
.header-left {
display: flex;
align-items: center;
gap: 12rpx;
@@ -512,6 +596,17 @@ onMounted(() => {
min-width: 0;
}
.merchant-icon {
width: 40rpx;
height: 40rpx;
background: linear-gradient(135deg, #FFF5F0 0%, #FFE8DD 100%);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.merchant-name {
font-size: 28rpx;
color: #1A1A1A;
@@ -522,31 +617,57 @@ onMounted(() => {
}
.status-badge {
display: flex;
align-items: center;
gap: 6rpx;
padding: 8rpx 16rpx;
border-radius: 20rpx;
flex-shrink: 0;
}
.status-dot {
width: 12rpx;
height: 12rpx;
border-radius: 50%;
flex-shrink: 0;
}
.status-pending_pay {
background: rgba(255, 140, 0, 0.1);
border: 2rpx solid rgba(255, 140, 0, 0.3);
.status-dot {
background: #FF8C00;
}
}
.status-pending_confirm,
.status-pending_checkin {
background: rgba(74, 144, 226, 0.1);
border: 2rpx solid rgba(74, 144, 226, 0.3);
.status-dot {
background: #4A90E2;
}
}
.status-confirmed,
.status-checked_in {
background: rgba(82, 196, 26, 0.1);
border: 2rpx solid rgba(82, 196, 26, 0.3);
.status-dot {
background: #52C41A;
}
}
.status-completed {
background: rgba(153, 153, 153, 0.1);
border: 2rpx solid rgba(153, 153, 153, 0.3);
.status-dot {
background: #999;
}
}
.status-cancelled,
@@ -554,6 +675,10 @@ onMounted(() => {
.status-refunded {
background: rgba(255, 77, 79, 0.1);
border: 2rpx solid rgba(255, 77, 79, 0.3);
.status-dot {
background: #FF4D4F;
}
}
.status-text {
@@ -589,17 +714,30 @@ onMounted(() => {
.order-body {
display: flex;
gap: 20rpx;
padding: 28rpx;
padding: 24rpx 24rpx 24rpx 32rpx;
}
.room-image-wrapper {
flex-shrink: 0;
}
.room-image {
width: 180rpx;
height: 180rpx;
border-radius: 16rpx;
flex-shrink: 0;
background: #F5F7FA;
}
.room-image-placeholder {
width: 180rpx;
height: 180rpx;
border-radius: 16rpx;
background: linear-gradient(135deg, #F5F7FA 0%, #E8EAED 100%);
display: flex;
align-items: center;
justify-content: center;
}
.room-info {
flex: 1;
display: flex;
@@ -609,7 +747,7 @@ onMounted(() => {
}
.room-name {
font-size: 28rpx;
font-size: 30rpx;
color: #1A1A1A;
font-weight: 600;
line-height: 1.4;
@@ -621,39 +759,41 @@ onMounted(() => {
margin-bottom: 12rpx;
}
.room-meta {
.room-details {
display: flex;
flex-direction: column;
gap: 8rpx;
margin-bottom: 12rpx;
margin-bottom: 16rpx;
}
.meta-item {
.detail-row {
display: flex;
align-items: center;
gap: 8rpx;
}
.meta-text {
.detail-icon {
width: 24rpx;
display: flex;
align-items: center;
justify-content: center;
}
.detail-text {
font-size: 24rpx;
color: #666;
}
.price-row {
.price-section {
display: flex;
align-items: baseline;
justify-content: space-between;
}
.price-label {
font-size: 24rpx;
color: #999;
}
.price-value {
.price-main {
display: flex;
align-items: baseline;
gap: 2rpx;
gap: 4rpx;
}
.price-symbol {
@@ -663,30 +803,62 @@ onMounted(() => {
}
.price-amount {
font-size: 36rpx;
font-size: 40rpx;
color: #FF6B35;
font-weight: 700;
line-height: 1;
}
.price-label {
font-size: 22rpx;
color: #999;
}
/* 订单底部操作 */
.order-footer {
display: flex;
justify-content: flex-end;
padding: 20rpx 28rpx;
align-items: center;
justify-content: space-between;
padding: 16rpx 24rpx 16rpx 32rpx;
background: #FAFBFC;
border-top: 1rpx solid #F0F0F0;
}
.order-no {
flex: 1;
display: flex;
align-items: center;
gap: 4rpx;
min-width: 0;
margin-right: 16rpx;
}
.no-label {
font-size: 22rpx;
color: #999;
flex-shrink: 0;
}
.no-value {
font-size: 22rpx;
color: #666;
font-family: 'Courier New', monospace;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.footer-actions {
display: flex;
gap: 16rpx;
gap: 12rpx;
flex-shrink: 0;
}
.action-btn {
display: flex;
align-items: center;
gap: 6rpx;
padding: 12rpx 24rpx;
padding: 12rpx 20rpx;
border-radius: 32rpx;
transition: all 0.3s ease;
@@ -696,7 +868,7 @@ onMounted(() => {
}
.btn-default {
background: #F5F7FA;
background: #ffffff;
border: 2rpx solid #E5E5E5;
.btn-text {
@@ -704,7 +876,7 @@ onMounted(() => {
}
&:active {
background: #E8EAED;
background: #F5F7FA;
}
}
@@ -723,21 +895,54 @@ onMounted(() => {
}
.btn-text {
font-size: 26rpx;
font-size: 24rpx;
font-weight: 600;
}
/* ========== 加载更多 ========== */
.loading-more {
display: flex;
flex-direction: column;
align-items: center;
gap: 16rpx;
padding: 48rpx 0;
}
.loading-spinner {
display: flex;
align-items: center;
justify-content: center;
gap: 12rpx;
padding: 40rpx 0;
}
.spinner-dot {
width: 12rpx;
height: 12rpx;
background: #FF6B35;
border-radius: 50%;
animation: bounce 1.4s infinite ease-in-out both;
&:nth-child(1) {
animation-delay: -0.32s;
}
&:nth-child(2) {
animation-delay: -0.16s;
}
}
@keyframes bounce {
0%, 80%, 100% {
transform: scale(0.6);
opacity: 0.5;
}
40% {
transform: scale(1);
opacity: 1;
}
}
.loading-text {
font-size: 26rpx;
font-size: 24rpx;
color: #999;
}
@@ -747,18 +952,18 @@ onMounted(() => {
align-items: center;
justify-content: center;
gap: 24rpx;
padding: 40rpx 0;
padding: 48rpx 0;
}
.no-more-line {
flex: 1;
height: 1rpx;
background: #E5E5E5;
width: 80rpx;
height: 2rpx;
background: linear-gradient(90deg, transparent 0%, #E5E5E5 50%, transparent 100%);
}
.no-more-text {
font-size: 24rpx;
color: #999;
color: #CCCCCC;
}
/* ========== 空状态 ========== */
@@ -773,7 +978,7 @@ onMounted(() => {
.empty-icon {
width: 160rpx;
height: 160rpx;
background: #F5F7FA;
background: linear-gradient(135deg, #F5F7FA 0%, #E8EAED 100%);
border-radius: 50%;
display: flex;
align-items: center;
@@ -782,7 +987,7 @@ onMounted(() => {
}
.empty-title {
font-size: 30rpx;
font-size: 32rpx;
color: #666;
font-weight: 600;
margin-bottom: 12rpx;
@@ -791,21 +996,22 @@ onMounted(() => {
.empty-desc {
font-size: 26rpx;
color: #999;
margin-bottom: 40rpx;
margin-bottom: 48rpx;
}
.empty-action {
display: flex;
align-items: center;
gap: 8rpx;
padding: 20rpx 40rpx;
gap: 12rpx;
padding: 24rpx 48rpx;
background: linear-gradient(135deg, #FF8C5A 0%, #FF6B35 100%);
border-radius: 40rpx;
box-shadow: 0 8rpx 24rpx rgba(255, 107, 53, 0.25);
border-radius: 48rpx;
box-shadow: 0 8rpx 24rpx rgba(255, 107, 53, 0.3);
transition: all 0.3s ease;
&:active {
transform: scale(0.95);
transform: scale(0.96);
box-shadow: 0 4rpx 16rpx rgba(255, 107, 53, 0.4);
}
}