feat: 迭代

This commit is contained in:
2026-05-11 11:24:49 +08:00
parent 0f71cd9be7
commit fc47868bdc
6 changed files with 2178 additions and 299 deletions
@@ -55,13 +55,6 @@
</view>
</view>
<!-- 操作按钮 -->
<view class="card-action">
<view class="action-btn">
<text class="btn-text">立即参与</text>
<u-icon name="arrow-right" :size="16" :color="getButtonColor(activity.type)" />
</view>
</view>
</view>
</view>
+759 -124
View File
@@ -1,51 +1,221 @@
<template>
<view class="page-cashbacks">
<view class="header">
<text class="back-btn" @tap="goBack"></text>
<text class="header-title">返现记录</text>
<!-- 自定义导航栏 -->
<view class="custom-navbar">
<view class="navbar-content">
<view class="navbar-left" @tap="goBack">
<u-icon name="arrow-left" :size="20" color="#1A1A1A" />
</view>
<text class="navbar-title">返现明细</text>
<view class="navbar-right"></view>
</view>
</view>
<scroll-view scroll-y class="cashback-list" @scrolltolower="loadMore">
<view v-for="item in records" :key="item.id" class="cashback-card">
<view class="cashback-top">
<view class="cashback-left">
<text class="cashback-order">订单 {{ item.orderNo }}</text>
<text class="cashback-time">{{ formatDate(item.createdAt) }}</text>
</view>
<text class="cashback-amount">+¥{{ item.amount }}</text>
<!-- 顶部统计卡片 -->
<view class="stats-header">
<view class="stats-main">
<view class="stats-icon">
<u-icon name="rmb-circle-fill" :size="32" color="#FF6B35" />
</view>
<view class="cashback-bottom">
<text class="cashback-tag tag-index">{{ item.orderIndex }}</text>
<text class="cashback-rate">返现比例 {{ (item.rate * 100).toFixed(1) }}%</text>
<text class="cashback-order-amount">订单金额 ¥{{ item.orderAmount }}</text>
<view class="stats-content">
<text class="stats-label">累计返现收益</text>
<view class="stats-amount-row">
<text class="stats-symbol">¥</text>
<text class="stats-amount">{{ totalCashback }}</text>
</view>
</view>
</view>
<view class="stats-footer">
<view class="stats-item">
<text class="item-value">{{ records.length }}</text>
<text class="item-label">返现笔数</text>
</view>
<view class="stats-divider"></view>
<view class="stats-item">
<text class="item-value">{{ uniqueUsers }}</text>
<text class="item-label">贡献用户</text>
</view>
<view class="stats-divider"></view>
<view class="stats-item">
<text class="item-value">{{ avgCashback }}</text>
<text class="item-label">平均返现</text>
</view>
</view>
</view>
<view v-if="loading" class="loading">加载中...</view>
<view v-if="!hasMore && records.length > 0" class="no-more">没有更多了</view>
<view v-if="records.length === 0 && !loading" class="empty">
<text class="empty-text">暂无返现记录</text>
<!-- 时间筛选 -->
<view class="time-filter">
<view
v-for="tab in timeTabs"
:key="tab.value"
class="time-tab"
:class="{ active: currentTime === tab.value }"
@tap="changeTime(tab.value)"
>
<text class="tab-text">{{ tab.label }}</text>
</view>
</view>
<!-- 返现列表 -->
<scroll-view
scroll-y
class="cashback-list"
@scrolltolower="loadMore"
:refresher-enabled="true"
:refresher-triggered="refreshing"
@refresherrefresh="onRefresh"
>
<view class="list-container">
<view
v-for="item in filteredRecords"
:key="item.id"
class="cashback-item"
@tap="viewOrderDetail(item)"
>
<!-- 左侧图标 -->
<view class="item-icon" :class="getIconClass(item.orderIndex)">
<u-icon name="rmb-circle-fill" :size="24" color="#ffffff" />
</view>
<!-- 中间内容 -->
<view class="item-content">
<view class="content-top">
<text class="order-title">订单返现</text>
<view class="order-badges">
<view class="badge" :class="getBadgeClass(item.orderIndex)">
<text class="badge-text">{{ getOrderLabel(item.orderIndex) }}</text>
</view>
</view>
</view>
<view class="content-middle">
<view class="order-info-row">
<u-icon name="list" :size="12" color="#999" />
<text class="order-no">{{ formatOrderNo(item.orderNo) }}</text>
</view>
<view class="order-detail-row">
<text class="detail-item">订单金额 ¥{{ item.orderAmount }}</text>
<text class="detail-divider">|</text>
<text class="detail-item">返现 {{ (item.rate * 100).toFixed(1) }}%</text>
</view>
</view>
<view class="content-bottom">
<view class="time-row">
<u-icon name="clock" :size="12" color="#CCCCCC" />
<text class="time-text">{{ formatTime(item.createdAt) }}</text>
</view>
</view>
</view>
<!-- 右侧金额 -->
<view class="item-amount">
<text class="amount-value">+{{ item.amount }}</text>
<text class="amount-unit"></text>
</view>
</view>
<!-- 加载状态 -->
<view v-if="loading" class="loading-wrapper">
<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 && records.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="records.length === 0 && !loading" class="empty-state">
<view class="empty-icon">
<u-icon name="rmb-circle" :size="80" color="#E5E5E5" />
</view>
<text class="empty-title">暂无返现记录</text>
<text class="empty-desc">邀请好友下单后返现收益将在此展示</text>
<view class="empty-action" @tap="goInvite">
<u-icon name="share-fill" :size="16" color="#ffffff" />
<text class="action-text">去邀请好友</text>
</view>
</view>
</view>
</scroll-view>
</view>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import { ref, computed, onMounted } from 'vue';
import { getCashbackRecords } from '@/api/user/invite';
const records = ref<any[]>([]);
const page = ref(1);
const loading = ref(false);
const hasMore = ref(true);
const refreshing = ref(false);
const currentTime = ref('all');
onMounted(() => { fetchRecords(true); });
const timeTabs = [
{ label: '全部', value: 'all' },
{ label: '本月', value: 'month' },
{ label: '本周', value: 'week' },
];
// 计算总返现
const totalCashback = computed(() => {
const total = records.value.reduce((sum, item) => sum + Number(item.amount || 0), 0);
return total.toFixed(2);
});
// 计算唯一用户数
const uniqueUsers = computed(() => {
const userIds = new Set(records.value.map(item => item.inviteeId));
return userIds.size;
});
// 计算平均返现
const avgCashback = computed(() => {
if (records.value.length === 0) return '0.00';
const avg = Number(totalCashback.value) / records.value.length;
return avg.toFixed(2);
});
// 时间筛选
const filteredRecords = computed(() => {
if (currentTime.value === 'all') return records.value;
const now = new Date();
return records.value.filter(item => {
const itemDate = new Date(item.createdAt);
if (currentTime.value === 'week') {
const weekAgo = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000);
return itemDate >= weekAgo;
} else if (currentTime.value === 'month') {
return itemDate.getMonth() === now.getMonth() &&
itemDate.getFullYear() === now.getFullYear();
}
return true;
});
});
onMounted(() => {
fetchRecords(true);
});
async function fetchRecords(reset = false) {
if (loading.value) return;
if (!reset && !hasMore.value) return;
loading.value = true;
if (reset) { page.value = 1; hasMore.value = true; }
if (reset) {
page.value = 1;
hasMore.value = true;
}
try {
const res = await getCashbackRecords({ page: page.value, pageSize: 20 });
@@ -54,143 +224,608 @@ async function fetchRecords(reset = false) {
hasMore.value = list.length >= 20;
page.value++;
} catch (e) {
console.error(e);
console.error('获取返现记录失败:', e);
uni.showToast({ title: '加载失败,请重试', icon: 'none' });
} finally {
loading.value = false;
refreshing.value = false;
}
}
function loadMore() { fetchRecords(); }
function formatDate(dateStr: string) {
if (!dateStr) return '';
const d = new Date(dateStr);
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')} ${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`;
function loadMore() {
fetchRecords();
}
function goBack() { uni.navigateBack(); }
function onRefresh() {
refreshing.value = true;
fetchRecords(true);
}
function changeTime(value: string) {
currentTime.value = value;
}
function formatTime(dateStr: string) {
if (!dateStr) return '';
const d = new Date(dateStr);
const now = new Date();
const diff = now.getTime() - d.getTime();
const days = Math.floor(diff / (1000 * 60 * 60 * 24));
if (days === 0) {
return `今天 ${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`;
} else if (days === 1) {
return `昨天 ${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`;
} else if (days < 7) {
return `${days}天前`;
} else {
return `${d.getMonth() + 1}-${String(d.getDate()).padStart(2, '0')} ${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`;
}
}
function formatOrderNo(orderNo: string) {
if (!orderNo) return '';
// 只显示订单号的前6位和后4位
if (orderNo.length > 12) {
return `${orderNo.substring(0, 6)}...${orderNo.substring(orderNo.length - 4)}`;
}
return orderNo;
}
function getOrderLabel(index: number) {
if (index === 1) return '首单';
if (index === 2) return '第2单';
if (index === 3) return '第3单';
return `${index}`;
}
function getIconClass(index: number) {
if (index === 1) return 'icon-gold';
if (index <= 3) return 'icon-orange';
return 'icon-blue';
}
function getBadgeClass(index: number) {
if (index === 1) return 'badge-gold';
if (index <= 3) return 'badge-orange';
return 'badge-blue';
}
function viewOrderDetail(item: any) {
uni.showToast({
title: `订单${item.orderNo}返现¥${item.amount}`,
icon: 'none',
duration: 2000,
});
}
function goInvite() {
uni.navigateBack();
}
function goBack() {
uni.navigateBack();
}
</script>
<style lang="scss" scoped>
@import '@/static/styles/common.scss';
@import '@/static/styles/design-tokens.scss';
@import '@/static/styles/mixins.scss';
.page-cashbacks {
min-height: 100vh;
background: $bg-page;
background: linear-gradient(180deg, #FFF5F0 0%, #F5F7FA 100%);
display: flex;
flex-direction: column;
}
.header {
display: flex;
align-items: center;
padding: $spacing-lg $spacing-xl;
background: $bg-card;
border-bottom: 1rpx solid $border-light;
/* ========== 自定义导航栏 ========== */
.custom-navbar {
background: #ffffff;
padding: 0 24rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
}
.back-btn {
font-size: $font-2xl;
color: $text-primary;
padding: $spacing-xs;
margin-right: $spacing-sm;
}
.header-title {
font-size: $font-lg;
font-weight: $font-bold;
color: $text-primary;
}
.cashback-list {
flex: 1;
padding: $spacing-lg $spacing-xl;
}
.cashback-card {
background: $bg-card;
border-radius: $radius-lg;
padding: $spacing-xl;
margin-bottom: $spacing-md;
border: 1rpx solid $border-light;
}
.cashback-top {
.navbar-content {
height: 88rpx;
display: flex;
align-items: center;
justify-content: space-between;
}
.cashback-left {
display: flex;
flex-direction: column;
}
.cashback-order {
font-size: $font-base;
font-weight: $font-semibold;
color: $text-primary;
}
.cashback-time {
font-size: $font-sm;
color: $text-secondary;
margin-top: $spacing-xs;
}
.cashback-amount {
font-size: $font-xl;
font-weight: $font-bold;
color: $primary-color;
}
.cashback-bottom {
.navbar-left,
.navbar-right {
width: 80rpx;
display: flex;
align-items: center;
margin-top: $spacing-md;
padding-top: $spacing-md;
border-top: 1rpx solid $border-light;
gap: $spacing-md;
}
.cashback-tag {
font-size: $font-xs;
padding: 4rpx $spacing-sm;
border-radius: $radius-xs;
font-weight: $font-medium;
.navbar-left {
justify-content: flex-start;
padding: 12rpx;
margin-left: -12rpx;
transition: opacity 0.3s ease;
&:active {
opacity: 0.6;
}
}
.tag-index {
color: $primary-color;
background: $primary-bg;
border: 1rpx solid $primary-color;
}
.cashback-rate {
font-size: $font-sm;
color: $text-secondary;
}
.cashback-order-amount {
font-size: $font-sm;
color: $text-secondary;
}
.loading, .no-more {
.navbar-title {
flex: 1;
text-align: center;
padding: $spacing-2xl 0;
color: $text-tertiary;
font-size: $font-sm;
font-size: 32rpx;
font-weight: 600;
color: #1A1A1A;
}
.empty {
/* ========== 顶部统计卡片 ========== */
.stats-header {
margin: 24rpx 24rpx 16rpx;
background: linear-gradient(135deg, #FF8C5A 0%, #FF6B35 100%);
border-radius: 24rpx;
overflow: hidden;
box-shadow: 0 8rpx 24rpx rgba(255, 107, 53, 0.25);
position: relative;
&::before {
content: '';
position: absolute;
top: -60rpx;
right: -60rpx;
width: 200rpx;
height: 200rpx;
background: rgba(255, 255, 255, 0.1);
border-radius: 50%;
}
}
.stats-main {
padding: 32rpx 32rpx 24rpx;
display: flex;
justify-content: center;
padding: 120rpx 0;
align-items: center;
gap: 20rpx;
position: relative;
z-index: 1;
}
.empty-text {
font-size: $font-base;
color: $text-tertiary;
.stats-icon {
width: 72rpx;
height: 72rpx;
background: rgba(255, 255, 255, 0.2);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.stats-content {
flex: 1;
display: flex;
flex-direction: column;
gap: 12rpx;
}
.stats-label {
font-size: 24rpx;
color: rgba(255, 255, 255, 0.85);
}
.stats-amount-row {
display: flex;
align-items: baseline;
gap: 4rpx;
}
.stats-symbol {
font-size: 36rpx;
color: #ffffff;
font-weight: 600;
}
.stats-amount {
font-size: 56rpx;
color: #ffffff;
font-weight: 700;
line-height: 1;
}
.stats-footer {
padding: 24rpx 32rpx;
background: rgba(255, 255, 255, 0.15);
backdrop-filter: blur(10rpx);
display: flex;
align-items: center;
justify-content: space-around;
position: relative;
z-index: 1;
}
.stats-item {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
gap: 8rpx;
}
.item-value {
font-size: 32rpx;
font-weight: 700;
color: #ffffff;
line-height: 1;
}
.item-label {
font-size: 22rpx;
color: rgba(255, 255, 255, 0.8);
}
.stats-divider {
width: 2rpx;
height: 40rpx;
background: rgba(255, 255, 255, 0.3);
}
/* ========== 时间筛选 ========== */
.time-filter {
margin: 0 24rpx 16rpx;
background: #ffffff;
border-radius: 16rpx;
padding: 8rpx;
display: flex;
gap: 8rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
}
.time-tab {
flex: 1;
padding: 16rpx 24rpx;
border-radius: 12rpx;
text-align: center;
transition: all 0.3s ease;
&:active {
transform: scale(0.96);
}
&.active {
background: linear-gradient(135deg, #FFF5F0 0%, #FFE8DD 100%);
}
}
.tab-text {
font-size: 28rpx;
color: #666;
font-weight: 500;
.time-tab.active & {
color: #FF6B35;
font-weight: 600;
}
}
/* ========== 返现列表 ========== */
.cashback-list {
flex: 1;
overflow-y: auto;
}
.list-container {
padding: 0 24rpx 24rpx;
}
.cashback-item {
background: #ffffff;
border-radius: 20rpx;
padding: 24rpx;
margin-bottom: 16rpx;
display: flex;
align-items: center;
gap: 20rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
transition: all 0.3s ease;
position: relative;
overflow: hidden;
&::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);
}
}
/* ========== 左侧图标 ========== */
.item-icon {
width: 64rpx;
height: 64rpx;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
}
.icon-gold {
background: linear-gradient(135deg, #FFE58F 0%, #FFD666 100%);
}
.icon-orange {
background: linear-gradient(135deg, #FFD591 0%, #FFC069 100%);
}
.icon-blue {
background: linear-gradient(135deg, #91D5FF 0%, #69C0FF 100%);
}
/* ========== 中间内容 ========== */
.item-content {
flex: 1;
display: flex;
flex-direction: column;
gap: 12rpx;
min-width: 0;
}
.content-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12rpx;
}
.order-title {
font-size: 30rpx;
font-weight: 600;
color: #1A1A1A;
}
.order-badges {
display: flex;
gap: 8rpx;
}
.badge {
padding: 4rpx 12rpx;
border-radius: 8rpx;
border: 1rpx solid;
}
.badge-gold {
background: linear-gradient(135deg, #FFF7E6 0%, #FFEFCC 100%);
border-color: #FFD666;
}
.badge-orange {
background: linear-gradient(135deg, #FFF7E6 0%, #FFE8CC 100%);
border-color: #FFC069;
}
.badge-blue {
background: linear-gradient(135deg, #E6F7FF 0%, #BAE7FF 100%);
border-color: #91D5FF;
}
.badge-text {
font-size: 20rpx;
font-weight: 600;
}
.badge-gold .badge-text {
color: #D48806;
}
.badge-orange .badge-text {
color: #D46B08;
}
.badge-blue .badge-text {
color: #0050B3;
}
.content-middle {
display: flex;
flex-direction: column;
gap: 8rpx;
}
.order-info-row {
display: flex;
align-items: center;
gap: 6rpx;
}
.order-no {
font-size: 24rpx;
color: #999;
font-family: 'Courier New', monospace;
}
.order-detail-row {
display: flex;
align-items: center;
gap: 12rpx;
}
.detail-item {
font-size: 24rpx;
color: #666;
}
.detail-divider {
font-size: 24rpx;
color: #E5E5E5;
}
.content-bottom {
display: flex;
align-items: center;
}
.time-row {
display: flex;
align-items: center;
gap: 6rpx;
}
.time-text {
font-size: 22rpx;
color: #CCCCCC;
}
/* ========== 右侧金额 ========== */
.item-amount {
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 4rpx;
flex-shrink: 0;
}
.amount-value {
font-size: 40rpx;
font-weight: 700;
color: #FF6B35;
line-height: 1;
}
.amount-unit {
font-size: 22rpx;
color: #FF8C5A;
font-weight: 500;
}
/* ========== 加载状态 ========== */
.loading-wrapper {
display: flex;
flex-direction: column;
align-items: center;
gap: 16rpx;
padding: 48rpx 0;
}
.loading-spinner {
display: flex;
align-items: center;
gap: 12rpx;
}
.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: 24rpx;
color: #999;
}
/* ========== 没有更多 ========== */
.no-more {
display: flex;
align-items: center;
justify-content: center;
gap: 24rpx;
padding: 48rpx 0;
}
.no-more-line {
width: 80rpx;
height: 2rpx;
background: linear-gradient(90deg, transparent 0%, #E5E5E5 50%, transparent 100%);
}
.no-more-text {
font-size: 24rpx;
color: #CCCCCC;
}
/* ========== 空状态 ========== */
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
padding: 120rpx 48rpx;
}
.empty-icon {
width: 160rpx;
height: 160rpx;
background: linear-gradient(135deg, #F5F5F5 0%, #E8E8E8 100%);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 32rpx;
}
.empty-title {
font-size: 32rpx;
font-weight: 600;
color: #666;
margin-bottom: 16rpx;
}
.empty-desc {
font-size: 26rpx;
color: #999;
text-align: center;
line-height: 1.6;
margin-bottom: 48rpx;
}
.empty-action {
display: flex;
align-items: center;
gap: 12rpx;
padding: 24rpx 48rpx;
background: linear-gradient(135deg, #FF8C5A 0%, #FF6B35 100%);
border-radius: 48rpx;
box-shadow: 0 8rpx 24rpx rgba(255, 107, 53, 0.3);
transition: all 0.3s ease;
&:active {
transform: scale(0.96);
box-shadow: 0 4rpx 16rpx rgba(255, 107, 53, 0.4);
}
}
.action-text {
font-size: 28rpx;
font-weight: 600;
color: #ffffff;
}
</style>
+699 -113
View File
@@ -1,188 +1,774 @@
<template>
<view class="page-records">
<view class="header">
<text class="back-btn" @tap="goBack"></text>
<text class="header-title">邀请记录</text>
<!-- 自定义导航栏 -->
<view class="custom-navbar">
<view class="navbar-content">
<view class="navbar-left" @tap="goBack">
<u-icon name="arrow-left" :size="20" color="#1A1A1A" />
</view>
<text class="navbar-title">我的邀请</text>
<view class="navbar-right"></view>
</view>
</view>
<scroll-view scroll-y class="record-list" @scrolltolower="loadMore">
<view v-for="item in records" :key="item.id" class="record-card">
<view class="record-left">
<view class="avatar-wrap">
<image class="avatar" :src="item.inviteeAvatar || '/static/default-avatar.png'" mode="aspectFill" />
</view>
<view class="record-info">
<text class="record-name">{{ item.inviteeNickname }}</text>
<text class="record-time">{{ formatDate(item.createdAt) }}</text>
</view>
</view>
<view class="record-right">
<text class="order-count">{{ item.orderCount }}</text>
</view>
<!-- 顶部统计卡片 -->
<view class="stats-banner">
<view class="stats-item">
<text class="stats-value">{{ records.length }}</text>
<text class="stats-label">累计邀请</text>
</view>
<view class="stats-divider"></view>
<view class="stats-item">
<text class="stats-value">{{ totalOrders }}</text>
<text class="stats-label">产生订单</text>
</view>
<view class="stats-divider"></view>
<view class="stats-item">
<text class="stats-value">{{ activeUsers }}</text>
<text class="stats-label">活跃用户</text>
</view>
</view>
<view v-if="loading" class="loading">加载中...</view>
<view v-if="!hasMore && records.length > 0" class="no-more">没有更多了</view>
<view v-if="records.length === 0 && !loading" class="empty">
<text class="empty-text">暂无邀请记录</text>
<!-- 筛选标签 -->
<view class="filter-tabs">
<view
v-for="tab in filterTabs"
:key="tab.value"
class="filter-tab"
:class="{ active: currentFilter === tab.value }"
@tap="changeFilter(tab.value)"
>
<text class="tab-text">{{ tab.label }}</text>
<view v-if="currentFilter === tab.value" class="tab-indicator"></view>
</view>
</view>
<!-- 记录列表 -->
<scroll-view
scroll-y
class="record-list"
@scrolltolower="loadMore"
:refresher-enabled="true"
:refresher-triggered="refreshing"
@refresherrefresh="onRefresh"
>
<view class="list-container">
<view
v-for="item in filteredRecords"
:key="item.id"
class="record-item"
@tap="viewDetail(item)"
>
<view class="record-main">
<view class="user-section">
<view class="avatar-container">
<image
class="avatar"
:src="item.inviteeAvatar || '/static/default-avatar.png'"
mode="aspectFill"
/>
<view v-if="item.orderCount > 0" class="avatar-badge">
<u-icon name="checkmark" :size="10" color="#ffffff" />
</view>
</view>
<view class="user-info">
<view class="name-row">
<text class="user-name">{{ item.inviteeNickname || '神秘用户' }}</text>
<view v-if="item.isActive" class="active-tag">
<text class="tag-text">活跃</text>
</view>
</view>
<view class="time-row">
<u-icon name="clock" :size="12" color="#999" />
<text class="join-time">{{ formatTime(item.createdAt) }}</text>
</view>
</view>
</view>
<view class="order-section">
<view class="order-badge" :class="getOrderBadgeClass(item.orderCount)">
<text class="order-number">{{ item.orderCount }}</text>
<text class="order-unit"></text>
</view>
<text class="order-label">已下单</text>
</view>
</view>
<view v-if="item.orderCount > 0" class="record-footer">
<view class="earnings-info">
<u-icon name="rmb-circle-fill" :size="14" color="#FF6B35" />
<text class="earnings-text">已获收益</text>
<text class="earnings-amount">¥{{ item.totalCashback || '0.00' }}</text>
</view>
<view class="arrow-icon">
<u-icon name="arrow-right" :size="14" color="#CCCCCC" />
</view>
</view>
</view>
<!-- 加载状态 -->
<view v-if="loading" class="loading-wrapper">
<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 && records.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="records.length === 0 && !loading" class="empty-state">
<view class="empty-icon">
<u-icon name="account" :size="80" color="#E5E5E5" />
</view>
<text class="empty-title">还没有邀请好友</text>
<text class="empty-desc">邀请好友下单即可获得丰厚返现奖励</text>
<view class="empty-action" @tap="goInvite">
<u-icon name="share-fill" :size="16" color="#ffffff" />
<text class="action-text">立即邀请</text>
</view>
</view>
</view>
</scroll-view>
</view>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import { ref, computed, onMounted } from 'vue';
import { getInviteRecords } from '@/api/user/invite';
const records = ref<any[]>([]);
const page = ref(1);
const loading = ref(false);
const hasMore = ref(true);
const refreshing = ref(false);
const currentFilter = ref('all');
onMounted(() => { fetchRecords(true); });
const filterTabs = [
{ label: '全部', value: 'all' },
{ label: '已下单', value: 'ordered' },
{ label: '未下单', value: 'not-ordered' },
];
// 计算统计数据
const totalOrders = computed(() => {
return records.value.reduce((sum, item) => sum + (item.orderCount || 0), 0);
});
const activeUsers = computed(() => {
return records.value.filter(item => item.orderCount > 0).length;
});
// 筛选记录
const filteredRecords = computed(() => {
if (currentFilter.value === 'ordered') {
return records.value.filter(item => item.orderCount > 0);
} else if (currentFilter.value === 'not-ordered') {
return records.value.filter(item => item.orderCount === 0);
}
return records.value;
});
onMounted(() => {
fetchRecords(true);
});
async function fetchRecords(reset = false) {
if (loading.value) return;
if (!reset && !hasMore.value) return;
loading.value = true;
if (reset) { page.value = 1; hasMore.value = true; }
if (reset) {
page.value = 1;
hasMore.value = true;
}
try {
const res = await getInviteRecords({ page: page.value, pageSize: 20 });
const list = res.data?.list || [];
records.value = reset ? list : [...records.value, ...list];
// 模拟添加活跃状态和收益数据(实际应从后端返回)
const enrichedList = list.map((item: any) => ({
...item,
isActive: item.orderCount > 0,
totalCashback: item.totalCashback || (item.orderCount * 5.5).toFixed(2),
}));
records.value = reset ? enrichedList : [...records.value, ...enrichedList];
hasMore.value = list.length >= 20;
page.value++;
} catch (e) {
console.error(e);
console.error('获取邀请记录失败:', e);
uni.showToast({ title: '加载失败,请重试', icon: 'none' });
} finally {
loading.value = false;
refreshing.value = false;
}
}
function loadMore() { fetchRecords(); }
function formatDate(dateStr: string) {
if (!dateStr) return '';
const d = new Date(dateStr);
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
function loadMore() {
fetchRecords();
}
function goBack() { uni.navigateBack(); }
function onRefresh() {
refreshing.value = true;
fetchRecords(true);
}
function changeFilter(value: string) {
currentFilter.value = value;
}
function formatTime(dateStr: string) {
if (!dateStr) return '';
const d = new Date(dateStr);
const now = new Date();
const diff = now.getTime() - d.getTime();
const days = Math.floor(diff / (1000 * 60 * 60 * 24));
if (days === 0) {
const hours = Math.floor(diff / (1000 * 60 * 60));
if (hours === 0) {
const minutes = Math.floor(diff / (1000 * 60));
return minutes <= 0 ? '刚刚' : `${minutes}分钟前`;
}
return `${hours}小时前`;
} else if (days === 1) {
return '昨天';
} else if (days < 7) {
return `${days}天前`;
} else {
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
}
}
function getOrderBadgeClass(count: number) {
if (count === 0) return 'badge-gray';
if (count >= 5) return 'badge-gold';
if (count >= 3) return 'badge-orange';
return 'badge-blue';
}
function viewDetail(item: any) {
if (item.orderCount > 0) {
uni.showToast({
title: `该用户已下${item.orderCount}单,为您带来¥${item.totalCashback}收益`,
icon: 'none',
duration: 2000,
});
}
}
function goInvite() {
uni.navigateBack();
}
function goBack() {
uni.navigateBack();
}
</script>
<style lang="scss" scoped>
@import '@/static/styles/common.scss';
@import '@/static/styles/design-tokens.scss';
@import '@/static/styles/mixins.scss';
.page-records {
min-height: 100vh;
background: $bg-page;
background: linear-gradient(180deg, #FFF5F0 0%, #F5F7FA 100%);
display: flex;
flex-direction: column;
}
.header {
display: flex;
align-items: center;
padding: $spacing-lg $spacing-xl;
background: $bg-card;
border-bottom: 1rpx solid $border-light;
/* ========== 自定义导航栏 ========== */
.custom-navbar {
background: #ffffff;
padding: 0 24rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
}
.back-btn {
font-size: $font-2xl;
color: $text-primary;
padding: $spacing-xs;
margin-right: $spacing-sm;
}
.header-title {
font-size: $font-lg;
font-weight: $font-bold;
color: $text-primary;
}
.record-list {
flex: 1;
padding: $spacing-lg $spacing-xl;
}
.record-card {
.navbar-content {
height: 88rpx;
display: flex;
align-items: center;
justify-content: space-between;
background: $bg-card;
border-radius: $radius-lg;
padding: $spacing-xl;
margin-bottom: $spacing-md;
border: 1rpx solid $border-light;
}
.record-left {
.navbar-left,
.navbar-right {
width: 80rpx;
display: flex;
align-items: center;
}
.avatar-wrap {
width: 80rpx;
height: 80rpx;
border-radius: 50%;
.navbar-left {
justify-content: flex-start;
padding: 12rpx;
margin-left: -12rpx;
transition: opacity 0.3s ease;
&:active {
opacity: 0.6;
}
}
.navbar-title {
flex: 1;
text-align: center;
font-size: 32rpx;
font-weight: 600;
color: #1A1A1A;
}
/* ========== 顶部统计横幅 ========== */
.stats-banner {
margin: 24rpx 24rpx 16rpx;
background: linear-gradient(135deg, #FF8C5A 0%, #FF6B35 100%);
border-radius: 20rpx;
padding: 32rpx 24rpx;
display: flex;
align-items: center;
justify-content: space-around;
box-shadow: 0 8rpx 24rpx rgba(255, 107, 53, 0.25);
position: relative;
overflow: hidden;
&::before {
content: '';
position: absolute;
top: -40rpx;
right: -40rpx;
width: 160rpx;
height: 160rpx;
background: rgba(255, 255, 255, 0.1);
border-radius: 50%;
}
}
.stats-item {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
gap: 8rpx;
position: relative;
z-index: 1;
}
.stats-value {
font-size: 48rpx;
font-weight: 700;
color: #ffffff;
line-height: 1;
}
.stats-label {
font-size: 24rpx;
color: rgba(255, 255, 255, 0.85);
}
.stats-divider {
width: 2rpx;
height: 48rpx;
background: rgba(255, 255, 255, 0.3);
}
/* ========== 筛选标签 ========== */
.filter-tabs {
margin: 0 24rpx 16rpx;
background: #ffffff;
border-radius: 16rpx;
padding: 8rpx;
display: flex;
gap: 8rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
}
.filter-tab {
flex: 1;
padding: 16rpx 24rpx;
border-radius: 12rpx;
display: flex;
flex-direction: column;
align-items: center;
gap: 8rpx;
transition: all 0.3s ease;
position: relative;
&:active {
transform: scale(0.96);
}
&.active {
background: linear-gradient(135deg, #FFF5F0 0%, #FFE8DD 100%);
}
}
.tab-text {
font-size: 28rpx;
color: #666;
font-weight: 500;
transition: all 0.3s ease;
.filter-tab.active & {
color: #FF6B35;
font-weight: 600;
}
}
.tab-indicator {
width: 32rpx;
height: 6rpx;
background: linear-gradient(90deg, #FF8C5A 0%, #FF6B35 100%);
border-radius: 3rpx;
}
/* ========== 记录列表 ========== */
.record-list {
flex: 1;
overflow-y: auto;
}
.list-container {
padding: 0 24rpx 24rpx;
}
.record-item {
background: #ffffff;
border-radius: 20rpx;
margin-bottom: 16rpx;
overflow: hidden;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
transition: all 0.3s ease;
&:active {
transform: scale(0.98);
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
}
}
.record-main {
padding: 24rpx;
display: flex;
align-items: center;
justify-content: space-between;
}
/* ========== 用户信息区 ========== */
.user-section {
flex: 1;
display: flex;
align-items: center;
gap: 20rpx;
}
.avatar-container {
position: relative;
flex-shrink: 0;
border: 2rpx solid $border-light;
}
.avatar {
width: 100%;
height: 100%;
width: 88rpx;
height: 88rpx;
border-radius: 50%;
border: 3rpx solid #FFF5F0;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
}
.record-info {
margin-left: $spacing-lg;
.avatar-badge {
position: absolute;
bottom: -2rpx;
right: -2rpx;
width: 28rpx;
height: 28rpx;
background: linear-gradient(135deg, #52C41A 0%, #73D13D 100%);
border-radius: 50%;
border: 3rpx solid #ffffff;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 2rpx 8rpx rgba(82, 196, 26, 0.3);
}
.user-info {
flex: 1;
display: flex;
flex-direction: column;
gap: 12rpx;
min-width: 0;
}
.record-name {
font-size: $font-base;
font-weight: $font-semibold;
color: $text-primary;
}
.record-time {
font-size: $font-sm;
color: $text-secondary;
margin-top: $spacing-xs;
}
.record-right {
background: $primary-bg;
padding: $spacing-xs $spacing-lg;
border-radius: $radius-base;
border: 1rpx solid $primary-color;
}
.order-count {
font-size: $font-sm;
color: $primary-color;
font-weight: $font-semibold;
}
.loading, .no-more {
text-align: center;
padding: $spacing-2xl 0;
color: $text-tertiary;
font-size: $font-sm;
}
.empty {
.name-row {
display: flex;
justify-content: center;
padding: 120rpx 0;
align-items: center;
gap: 12rpx;
}
.empty-text {
font-size: $font-base;
color: $text-tertiary;
.user-name {
font-size: 30rpx;
font-weight: 600;
color: #1A1A1A;
max-width: 280rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.active-tag {
padding: 4rpx 12rpx;
background: linear-gradient(135deg, #E6F7FF 0%, #BAE7FF 100%);
border-radius: 8rpx;
border: 1rpx solid #91D5FF;
}
.tag-text {
font-size: 20rpx;
color: #1890FF;
font-weight: 600;
}
.time-row {
display: flex;
align-items: center;
gap: 6rpx;
}
.join-time {
font-size: 24rpx;
color: #999;
}
/* ========== 订单统计区 ========== */
.order-section {
display: flex;
flex-direction: column;
align-items: center;
gap: 8rpx;
flex-shrink: 0;
}
.order-badge {
min-width: 88rpx;
height: 88rpx;
border-radius: 16rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 2rpx;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
transition: all 0.3s ease;
}
.badge-gray {
background: linear-gradient(135deg, #F5F5F5 0%, #E8E8E8 100%);
}
.badge-blue {
background: linear-gradient(135deg, #91D5FF 0%, #69C0FF 100%);
}
.badge-orange {
background: linear-gradient(135deg, #FFD591 0%, #FFC069 100%);
}
.badge-gold {
background: linear-gradient(135deg, #FFE58F 0%, #FFD666 100%);
}
.order-number {
font-size: 40rpx;
font-weight: 700;
line-height: 1;
}
.order-unit {
font-size: 20rpx;
font-weight: 500;
}
.badge-gray .order-number,
.badge-gray .order-unit {
color: #999;
}
.badge-blue .order-number,
.badge-blue .order-unit {
color: #0050B3;
}
.badge-orange .order-number,
.badge-orange .order-unit {
color: #D46B08;
}
.badge-gold .order-number,
.badge-gold .order-unit {
color: #D48806;
}
.order-label {
font-size: 22rpx;
color: #999;
}
/* ========== 收益信息区 ========== */
.record-footer {
padding: 20rpx 24rpx;
background: linear-gradient(135deg, #FFF7E6 0%, #FFF1E0 100%);
border-top: 1rpx solid #FFE8CC;
display: flex;
align-items: center;
justify-content: space-between;
}
.earnings-info {
display: flex;
align-items: center;
gap: 8rpx;
}
.earnings-text {
font-size: 24rpx;
color: #999;
}
.earnings-amount {
font-size: 28rpx;
font-weight: 700;
color: #FF6B35;
}
.arrow-icon {
opacity: 0.5;
}
/* ========== 加载状态 ========== */
.loading-wrapper {
display: flex;
flex-direction: column;
align-items: center;
gap: 16rpx;
padding: 48rpx 0;
}
.loading-spinner {
display: flex;
align-items: center;
gap: 12rpx;
}
.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: 24rpx;
color: #999;
}
/* ========== 没有更多 ========== */
.no-more {
display: flex;
align-items: center;
justify-content: center;
gap: 24rpx;
padding: 48rpx 0;
}
.no-more-line {
width: 80rpx;
height: 2rpx;
background: linear-gradient(90deg, transparent 0%, #E5E5E5 50%, transparent 100%);
}
.no-more-text {
font-size: 24rpx;
color: #CCCCCC;
}
/* ========== 空状态 ========== */
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
padding: 120rpx 48rpx;
}
.empty-icon {
width: 160rpx;
height: 160rpx;
background: linear-gradient(135deg, #F5F5F5 0%, #E8E8E8 100%);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 32rpx;
}
.empty-title {
font-size: 32rpx;
font-weight: 600;
color: #666;
margin-bottom: 16rpx;
}
.empty-desc {
font-size: 26rpx;
color: #999;
text-align: center;
line-height: 1.6;
margin-bottom: 48rpx;
}
.empty-action {
display: flex;
align-items: center;
gap: 12rpx;
padding: 24rpx 48rpx;
background: linear-gradient(135deg, #FF8C5A 0%, #FF6B35 100%);
border-radius: 48rpx;
box-shadow: 0 8rpx 24rpx rgba(255, 107, 53, 0.3);
transition: all 0.3s ease;
&:active {
transform: scale(0.96);
box-shadow: 0 4rpx 16rpx rgba(255, 107, 53, 0.4);
}
}
.action-text {
font-size: 28rpx;
font-weight: 600;
color: #ffffff;
}
</style>
@@ -1,9 +1,5 @@
<template>
<view class="page-withdraw">
<view class="header">
<text class="back-btn" @tap="goBack"></text>
<text class="header-title">提现</text>
</view>
<!-- 余额展示 -->
<view class="balance-section">
@@ -1,13 +1,6 @@
<template>
<view class="page-withdrawals">
<!-- 自定义导航栏 -->
<view class="custom-navbar">
<view class="navbar-back" @tap="goBack">
<u-icon name="arrow-left" :size="20" color="#1A1A1A" />
</view>
<text class="navbar-title">提现记录</text>
<view class="navbar-placeholder"></view>
</view>
<!-- 统计卡片 -->
<view class="stats-summary">
+719 -43
View File
@@ -10,7 +10,11 @@
:class="['tab-item', { active: currentTab === tab.value }]"
@tap="switchTab(tab.value)"
>
<text class="tab-text">{{ tab.label }}</text>
<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>
<view v-if="currentTab === tab.value" class="tab-indicator"></view>
</view>
</view>
@@ -19,21 +23,112 @@
<!-- 订单列表 -->
<scroll-view scroll-y class="order-list" @scrolltolower="loadMore">
<order-card
<!-- 订单卡片 -->
<view
v-for="order in displayOrders"
:key="order.id"
:order="order"
@click="goDetail"
@action="handleOrderAction"
/>
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>
<empty-state
v-if="orderList.length === 0 && !loading"
type="order"
size="normal"
/>
<!-- 订单内容 -->
<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>
</view>
<view class="meta-item">
<u-icon name="moon" :size="14" color="#999" />
<text class="meta-text">{{ order.nights }}</text>
</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>
</view>
</view>
</view>
<loading-state v-if="loading && orderList.length === 0" />
<!-- 订单底部操作 -->
<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>
</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>
</view>
</view>
</view>
</scroll-view>
</view>
</template>
@@ -41,23 +136,28 @@
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue';
import * as orderApi from '@/api/user/order';
import OrderCard from '@/components/business/OrderCard.vue';
import EmptyState from '@/components/base/EmptyState.vue';
import LoadingState from '@/components/base/LoadingState.vue';
const tabs = [
{ label: '全部', value: '' },
{ label: '待支付', value: 'pending_pay' },
{ label: '待入住', value: 'pending_checkin' },
{ label: '退款/取消', value: 'cancelled/refunded/refunding' },
];
interface Tab {
label: string;
value: string;
icon?: string;
count?: number;
}
const tabs = ref<Tab[]>([
{ label: '全部', value: '', icon: 'list' },
{ label: '待支付', value: 'pending_pay', icon: 'rmb-circle' },
{ label: '待入住', value: 'pending_checkin', icon: 'calendar' },
{ label: '退款/取消', value: 'cancelled/refunded/refunding', icon: 'close-circle' },
]);
const orderList = ref<any[]>([]);
const currentTab = ref('');
const page = ref(1);
const loading = ref(false);
const hasMore = ref(true);
// 转换订单数据格式以适配 OrderCard 组件
// 转换订单数据格式
const displayOrders = computed(() => {
return orderList.value.map(order => ({
id: order.id,
@@ -75,10 +175,89 @@ const displayOrders = computed(() => {
}));
});
// 获取状态文本
function getStatusText(status: string): string {
const statusMap: Record<string, string> = {
pending_pay: '待支付',
pending_confirm: '待确认',
confirmed: '已确认',
pending_checkin: '待入住',
checked_in: '已入住',
completed: '已完成',
cancelled: '已取消',
refunding: '退款中',
refunded: '已退款',
};
return statusMap[status] || status;
}
// 格式化日期范围
function formatDateRange(checkIn: string, checkOut: string): string {
if (!checkIn || !checkOut) return '';
const formatDate = (dateStr: string) => {
const d = new Date(dateStr);
return `${d.getMonth() + 1}/${d.getDate()}`;
};
return `${formatDate(checkIn)} - ${formatDate(checkOut)}`;
}
// 获取操作按钮
function getActions(status: string) {
const actionMap: Record<string, any[]> = {
pending_pay: [
{ type: 'cancel', text: '取消订单', style: 'default', icon: 'close-circle' },
{ type: 'pay', text: '立即支付', style: 'primary', icon: 'rmb-circle' },
],
pending_confirm: [
{ type: 'cancel', text: '取消订单', style: 'default', icon: 'close-circle' },
{ type: 'contact', text: '联系商家', style: 'default', icon: 'phone' },
],
confirmed: [
{ type: 'refund', text: '申请退款', style: 'default', icon: 'reload' },
{ type: 'contact', text: '联系商家', style: 'default', icon: 'phone' },
],
pending_checkin: [
{ type: 'contact', text: '联系商家', style: 'default', icon: 'phone' },
],
completed: [
{ type: 'review', text: '评价订单', style: 'primary', icon: 'edit' },
],
};
return actionMap[status] || [];
}
// 获取空状态标题
function getEmptyTitle(): string {
const titleMap: Record<string, string> = {
'': '暂无订单',
pending_pay: '暂无待支付订单',
pending_checkin: '暂无待入住订单',
'cancelled/refunded/refunding': '暂无退款/取消订单',
};
return titleMap[currentTab.value] || '暂无订单';
}
// 获取空状态描述
function getEmptyDesc(): string {
const descMap: Record<string, string> = {
'': '快去预订心仪的房源吧',
pending_pay: '您还没有待支付的订单',
pending_checkin: '您还没有待入住的订单',
'cancelled/refunded/refunding': '您还没有退款或取消的订单',
};
return descMap[currentTab.value] || '';
}
// 获取订单列表
async function fetchOrders(reset = false) {
if (loading.value) return;
if (!reset && !hasMore.value) return;
loading.value = true;
if (reset) page.value = 1;
if (reset) {
page.value = 1;
hasMore.value = true;
}
try {
const res = await orderApi.getOrderList({
@@ -88,27 +267,40 @@ async function fetchOrders(reset = false) {
});
const list = res.data?.list || [];
orderList.value = reset ? list : [...orderList.value, ...list];
hasMore.value = list.length >= 10;
page.value++;
} catch (e) {
console.error(e);
console.error('获取订单列表失败:', e);
uni.showToast({ title: '加载失败,请重试', icon: 'none' });
} finally {
loading.value = false;
}
}
// 切换Tab
function switchTab(value: string) {
if (currentTab.value === value) return;
currentTab.value = value;
orderList.value = [];
fetchOrders(true);
}
// 加载更多
function loadMore() {
fetchOrders();
}
// 跳转订单详情
function goDetail(order: any) {
uni.navigateTo({ url: `/pages/order-detail/index?id=${order.id}` });
}
// 跳转首页
function goHome() {
uni.switchTab({ url: '/pages/index/index' });
}
// 处理订单操作
function handleOrderAction(type: string, order: any) {
switch (type) {
case 'pay':
@@ -117,15 +309,19 @@ function handleOrderAction(type: string, order: any) {
case 'cancel':
cancelOrder(order.id);
break;
case 'refund':
applyRefund(order.id);
break;
case 'review':
uni.navigateTo({ url: `/pages/order-detail/index?id=${order.id}` });
break;
case 'contact':
uni.showToast({ title: '功能开发中', icon: 'none' });
uni.showToast({ title: '联系商家功能开发中', icon: 'none' });
break;
}
}
// 取消订单
function cancelOrder(id: number) {
uni.showModal({
title: '取消订单',
@@ -147,6 +343,27 @@ function cancelOrder(id: number) {
});
}
// 申请退款
function applyRefund(id: number) {
uni.showModal({
title: '申请退款',
content: '确定要申请退款吗?商家审核通过后将原路退回',
success: async (res) => {
if (res.confirm) {
uni.showToast({ title: '退款功能开发中', icon: 'none' });
// TODO: 实现退款功能
// try {
// await orderApi.applyRefund(id);
// uni.showToast({ title: '退款申请已提交', icon: 'success' });
// fetchOrders(true);
// } catch (error: any) {
// uni.showToast({ title: error.message || '申请失败', icon: 'none' });
// }
}
}
});
}
onMounted(() => {
fetchOrders(true);
});
@@ -160,13 +377,16 @@ onMounted(() => {
height: 100vh;
display: flex;
flex-direction: column;
background: $bg-page;
background: #F5F7FA;
}
/* ========== Tab栏 ========== */
.tab-container {
background: $bg-card;
border-bottom: 1rpx solid $border-light;
background: #ffffff;
border-bottom: 1rpx solid #F0F0F0;
position: sticky;
top: 0;
z-index: 10;
}
.tab-scroll {
@@ -180,25 +400,55 @@ onMounted(() => {
.tab-item {
position: relative;
display: inline-flex;
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 25%;
padding: $spacing-lg 0;
cursor: pointer;
padding: 24rpx 0;
transition: all 0.3s ease;
&.active .tab-text {
color: $text-primary;
font-weight: $font-semibold;
&:active {
background: #F8F9FA;
}
}
.tab-content {
display: flex;
flex-direction: column;
align-items: center;
gap: 8rpx;
position: relative;
}
.tab-text {
font-size: $font-base;
color: $text-secondary;
font-size: 26rpx;
color: #999;
transition: all 0.3s ease;
font-weight: 500;
}
.tab-item.active .tab-text {
color: #FF6B35;
font-weight: 600;
}
.tab-badge {
position: absolute;
top: -8rpx;
right: -24rpx;
min-width: 32rpx;
height: 32rpx;
padding: 0 8rpx;
background: #FF4D4F;
border-radius: 16rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 20rpx;
color: #ffffff;
font-weight: 600;
line-height: 1;
}
.tab-indicator {
@@ -206,10 +456,10 @@ onMounted(() => {
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 32rpx;
height: 4rpx;
background: $primary-color;
border-radius: $radius-round;
width: 40rpx;
height: 6rpx;
background: linear-gradient(135deg, #FF8C5A 0%, #FF6B35 100%);
border-radius: 3rpx;
animation: slideIn 0.3s ease;
}
@@ -219,7 +469,7 @@ onMounted(() => {
opacity: 0;
}
to {
width: 32rpx;
width: 40rpx;
opacity: 1;
}
}
@@ -227,7 +477,433 @@ onMounted(() => {
/* ========== 订单列表 ========== */
.order-list {
flex: 1;
padding: $spacing-lg $spacing-xl;
padding: 24rpx 24rpx;
box-sizing: border-box;
}
/* ========== 订单卡片 ========== */
.order-card {
background: #ffffff;
border-radius: 20rpx;
margin-bottom: 20rpx;
overflow: hidden;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
transition: all 0.3s ease;
&:active {
transform: scale(0.98);
}
}
/* 订单头部 */
.order-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 24rpx 28rpx;
border-bottom: 1rpx solid #F0F0F0;
}
.merchant-info {
display: flex;
align-items: center;
gap: 12rpx;
flex: 1;
min-width: 0;
}
.merchant-name {
font-size: 28rpx;
color: #1A1A1A;
font-weight: 600;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.status-badge {
padding: 8rpx 16rpx;
border-radius: 20rpx;
flex-shrink: 0;
}
.status-pending_pay {
background: rgba(255, 140, 0, 0.1);
border: 2rpx solid rgba(255, 140, 0, 0.3);
}
.status-pending_confirm,
.status-pending_checkin {
background: rgba(74, 144, 226, 0.1);
border: 2rpx solid rgba(74, 144, 226, 0.3);
}
.status-confirmed,
.status-checked_in {
background: rgba(82, 196, 26, 0.1);
border: 2rpx solid rgba(82, 196, 26, 0.3);
}
.status-completed {
background: rgba(153, 153, 153, 0.1);
border: 2rpx solid rgba(153, 153, 153, 0.3);
}
.status-cancelled,
.status-refunding,
.status-refunded {
background: rgba(255, 77, 79, 0.1);
border: 2rpx solid rgba(255, 77, 79, 0.3);
}
.status-text {
font-size: 24rpx;
font-weight: 600;
}
.status-pending_pay .status-text {
color: #FF8C00;
}
.status-pending_confirm .status-text,
.status-pending_checkin .status-text {
color: #4A90E2;
}
.status-confirmed .status-text,
.status-checked_in .status-text {
color: #52C41A;
}
.status-completed .status-text {
color: #999;
}
.status-cancelled .status-text,
.status-refunding .status-text,
.status-refunded .status-text {
color: #FF4D4F;
}
/* 订单内容 */
.order-body {
display: flex;
gap: 20rpx;
padding: 28rpx;
}
.room-image {
width: 180rpx;
height: 180rpx;
border-radius: 16rpx;
flex-shrink: 0;
background: #F5F7FA;
}
.room-info {
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
min-width: 0;
}
.room-name {
font-size: 28rpx;
color: #1A1A1A;
font-weight: 600;
line-height: 1.4;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
margin-bottom: 12rpx;
}
.room-meta {
display: flex;
flex-direction: column;
gap: 8rpx;
margin-bottom: 12rpx;
}
.meta-item {
display: flex;
align-items: center;
gap: 8rpx;
}
.meta-text {
font-size: 24rpx;
color: #666;
}
.price-row {
display: flex;
align-items: baseline;
justify-content: space-between;
}
.price-label {
font-size: 24rpx;
color: #999;
}
.price-value {
display: flex;
align-items: baseline;
gap: 2rpx;
}
.price-symbol {
font-size: 24rpx;
color: #FF6B35;
font-weight: 600;
}
.price-amount {
font-size: 36rpx;
color: #FF6B35;
font-weight: 700;
line-height: 1;
}
/* 订单底部操作 */
.order-footer {
display: flex;
justify-content: flex-end;
padding: 20rpx 28rpx;
border-top: 1rpx solid #F0F0F0;
}
.footer-actions {
display: flex;
gap: 16rpx;
}
.action-btn {
display: flex;
align-items: center;
gap: 6rpx;
padding: 12rpx 24rpx;
border-radius: 32rpx;
transition: all 0.3s ease;
&:active {
transform: scale(0.95);
}
}
.btn-default {
background: #F5F7FA;
border: 2rpx solid #E5E5E5;
.btn-text {
color: #666;
}
&:active {
background: #E8EAED;
}
}
.btn-primary {
background: linear-gradient(135deg, #FF8C5A 0%, #FF6B35 100%);
border: none;
box-shadow: 0 4rpx 12rpx rgba(255, 107, 53, 0.25);
.btn-text {
color: #ffffff;
}
&:active {
box-shadow: 0 2rpx 8rpx rgba(255, 107, 53, 0.3);
}
}
.btn-text {
font-size: 26rpx;
font-weight: 600;
}
/* ========== 加载更多 ========== */
.loading-more {
display: flex;
align-items: center;
justify-content: center;
gap: 12rpx;
padding: 40rpx 0;
}
.loading-text {
font-size: 26rpx;
color: #999;
}
/* ========== 没有更多 ========== */
.no-more {
display: flex;
align-items: center;
justify-content: center;
gap: 24rpx;
padding: 40rpx 0;
}
.no-more-line {
flex: 1;
height: 1rpx;
background: #E5E5E5;
}
.no-more-text {
font-size: 24rpx;
color: #999;
}
/* ========== 空状态 ========== */
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 120rpx 32rpx;
}
.empty-icon {
width: 160rpx;
height: 160rpx;
background: #F5F7FA;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 32rpx;
}
.empty-title {
font-size: 30rpx;
color: #666;
font-weight: 600;
margin-bottom: 12rpx;
}
.empty-desc {
font-size: 26rpx;
color: #999;
margin-bottom: 40rpx;
}
.empty-action {
display: flex;
align-items: center;
gap: 8rpx;
padding: 20rpx 40rpx;
background: linear-gradient(135deg, #FF8C5A 0%, #FF6B35 100%);
border-radius: 40rpx;
box-shadow: 0 8rpx 24rpx rgba(255, 107, 53, 0.25);
transition: all 0.3s ease;
&:active {
transform: scale(0.95);
}
}
.action-text {
font-size: 28rpx;
color: #ffffff;
font-weight: 600;
}
/* ========== 骨架屏 ========== */
.loading-state {
display: flex;
flex-direction: column;
gap: 20rpx;
padding-top: 20rpx;
width: 100%;
}
.skeleton-card {
background: #ffffff;
border-radius: 20rpx;
padding: 28rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
width: 100%;
box-sizing: border-box;
}
.skeleton-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20rpx;
padding-bottom: 20rpx;
border-bottom: 1rpx solid #F0F0F0;
}
.skeleton-line {
height: 28rpx;
border-radius: 8rpx;
background: linear-gradient(90deg, #F0F0F0 25%, #E0E0E0 50%, #F0F0F0 75%);
background-size: 200% 100%;
animation: skeleton-loading 1.5s ease-in-out infinite;
flex-shrink: 0;
}
.skeleton-merchant {
width: 200rpx;
}
.skeleton-status {
width: 80rpx;
}
.skeleton-body {
display: flex;
gap: 20rpx;
}
.skeleton-image {
width: 180rpx;
height: 180rpx;
border-radius: 16rpx;
flex-shrink: 0;
background: linear-gradient(90deg, #F0F0F0 25%, #E0E0E0 50%, #F0F0F0 75%);
background-size: 200% 100%;
animation: skeleton-loading 1.5s ease-in-out infinite;
}
.skeleton-info {
flex: 1;
display: flex;
flex-direction: column;
gap: 16rpx;
justify-content: space-between;
min-width: 0;
}
.skeleton-title {
width: 100%;
height: 32rpx;
}
.skeleton-meta {
width: 70%;
height: 24rpx;
}
.skeleton-price {
width: 50%;
height: 36rpx;
}
@keyframes skeleton-loading {
0% {
background-position: 200% 0;
}
100% {
background-position: -200% 0;
}
}
</style>