|
|
@@ -1,45 +1,34 @@
|
|
|
<template>
|
|
|
<view class="container">
|
|
|
- <view class="title">我的订单</view>
|
|
|
- <view class="order-tabs">
|
|
|
- <view class="tab-item active">全部</view>
|
|
|
- <view class="tab-item">待支付</view>
|
|
|
- <view class="tab-item">已完成</view>
|
|
|
- <view class="tab-item">退款/售后</view>
|
|
|
- </view>
|
|
|
+ <!-- 订单列表 -->
|
|
|
<view class="order-list">
|
|
|
- <view class="order-item">
|
|
|
+ <view v-for="order in orders" :key="order.id" class="order-item">
|
|
|
<view class="order-header">
|
|
|
- <view class="order-time">2026-01-23 10:30:00</view>
|
|
|
- <view class="order-status">已完成</view>
|
|
|
- </view>
|
|
|
- <view class="order-products">
|
|
|
- <view class="product-item">
|
|
|
- <view class="product-name">可口可乐</view>
|
|
|
- <view class="product-price">¥3.50</view>
|
|
|
- <view class="product-quantity">×2</view>
|
|
|
+ <view class="time-invoice-container">
|
|
|
+ <text class="order-time">{{ order.createTime }}</text>
|
|
|
+ <text class="invoice-status">未开票</text>
|
|
|
</view>
|
|
|
+ <text :class="['order-status', order.status]">{{ getStatusText(order.status) }}</text>
|
|
|
</view>
|
|
|
- <view class="order-footer">
|
|
|
- <view class="order-total">共2件商品 合计:¥7.00</view>
|
|
|
- <button class="order-button">查看详情</button>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- <view class="order-item">
|
|
|
- <view class="order-header">
|
|
|
- <view class="order-time">2026-01-23 09:15:00</view>
|
|
|
- <view class="order-status">待支付</view>
|
|
|
- </view>
|
|
|
- <view class="order-products">
|
|
|
- <view class="product-item">
|
|
|
- <view class="product-name">雪碧</view>
|
|
|
- <view class="product-price">¥3.50</view>
|
|
|
- <view class="product-quantity">×1</view>
|
|
|
+ <view class="order-content">
|
|
|
+ <view class="product-image">
|
|
|
+ <image v-if="order.products && order.products[0] && order.products[0].image" :src="order.products[0].image" mode="aspectFill"></image>
|
|
|
+ <view v-else class="image-placeholder"></view>
|
|
|
+ </view>
|
|
|
+ <view class="order-info">
|
|
|
+ <view class="product-name" v-if="order.products && order.products[0]">
|
|
|
+ {{ order.products[0].name }}{{ order.products.length > 1 ? ' 等' : '' }}
|
|
|
+ </view>
|
|
|
+ <view class="price-info">
|
|
|
+ <text class="price-label">实付:</text>
|
|
|
+ <text class="price-value">¥{{ order.amount.toFixed(2) }}</text>
|
|
|
+ </view>
|
|
|
+ <view class="quantity-info">共{{ getQuantity(order) }}件</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="order-footer">
|
|
|
- <view class="order-total">共1件商品 合计:¥3.50</view>
|
|
|
- <button class="order-button">立即支付</button>
|
|
|
+ <button v-if="canRefund(order)" class="action-btn refund-btn" @click.stop="applyRefund(order)">申请退款</button>
|
|
|
+ <button class="action-btn detail-btn" @click.stop="viewOrderDetail(order)">订单详情</button>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -52,135 +41,211 @@ import { mockApi } from '../../utils/mock';
|
|
|
|
|
|
const orders = ref<any[]>([]);
|
|
|
|
|
|
+const getStatusText = (status: string) => {
|
|
|
+ const statusMap: any = {
|
|
|
+ 'completed': '已完成',
|
|
|
+ 'pending': '识别中',
|
|
|
+ 'paid': '已支付',
|
|
|
+ 'refunded': '已退款'
|
|
|
+ };
|
|
|
+ return statusMap[status] || status;
|
|
|
+};
|
|
|
+
|
|
|
+const getQuantity = (order: any) => {
|
|
|
+ if (!order.products) return 0;
|
|
|
+ return order.products.reduce((acc: number, p: any) => acc + p.quantity, 0);
|
|
|
+};
|
|
|
+
|
|
|
+const canRefund = (order: any) => {
|
|
|
+ return order.status === 'completed' || order.status === 'paid';
|
|
|
+};
|
|
|
+
|
|
|
onMounted(async () => {
|
|
|
- const response = await mockApi.getOrders();
|
|
|
+ const response: any = await mockApi.getOrders();
|
|
|
if (response.success) {
|
|
|
orders.value = response.data;
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+const applyRefund = (order: any) => {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/pages/refund/refund?id=' + order.id
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+const viewOrderDetail = () => {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/pages/orderDetail/orderDetail'
|
|
|
+ });
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style>
|
|
|
.container {
|
|
|
min-height: 100vh;
|
|
|
background-color: #f5f5f5;
|
|
|
-}
|
|
|
-
|
|
|
-.title {
|
|
|
- font-size: 36rpx;
|
|
|
- font-weight: bold;
|
|
|
- padding: 30rpx;
|
|
|
- background-color: #fff;
|
|
|
- border-bottom: 1rpx solid #eee;
|
|
|
-}
|
|
|
-
|
|
|
-.order-tabs {
|
|
|
- display: flex;
|
|
|
- background-color: #fff;
|
|
|
- margin: 20rpx 0;
|
|
|
- padding: 0 30rpx;
|
|
|
-}
|
|
|
-
|
|
|
-.tab-item {
|
|
|
- flex: 1;
|
|
|
- text-align: center;
|
|
|
- padding: 20rpx 0;
|
|
|
- font-size: 28rpx;
|
|
|
- color: #666;
|
|
|
position: relative;
|
|
|
+ padding-top: 0;
|
|
|
}
|
|
|
|
|
|
-.tab-item.active {
|
|
|
- color: #FFD700;
|
|
|
- font-weight: bold;
|
|
|
-}
|
|
|
-
|
|
|
-.tab-item.active::after {
|
|
|
- content: '';
|
|
|
- position: absolute;
|
|
|
- bottom: 0;
|
|
|
- left: 25%;
|
|
|
- width: 50%;
|
|
|
- height: 4rpx;
|
|
|
- background-color: #FFD700;
|
|
|
-}
|
|
|
-
|
|
|
+/* 订单列表 */
|
|
|
.order-list {
|
|
|
- padding: 0 30rpx 30rpx;
|
|
|
+ padding: 10rpx 0 30rpx;
|
|
|
}
|
|
|
|
|
|
+/* 订单项 */
|
|
|
.order-item {
|
|
|
- background-color: #fff;
|
|
|
- border-radius: 10rpx;
|
|
|
- margin-bottom: 20rpx;
|
|
|
+ background-color: #ffffff;
|
|
|
+ border-radius: 0;
|
|
|
+ margin-bottom: 10rpx;
|
|
|
overflow: hidden;
|
|
|
+ box-shadow: none;
|
|
|
}
|
|
|
|
|
|
+/* 订单头部 */
|
|
|
.order-header {
|
|
|
display: flex;
|
|
|
justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
padding: 20rpx;
|
|
|
border-bottom: 1rpx solid #f0f0f0;
|
|
|
}
|
|
|
|
|
|
.order-time {
|
|
|
font-size: 24rpx;
|
|
|
- color: #999;
|
|
|
+ color: #666666;
|
|
|
+}
|
|
|
+
|
|
|
+.time-invoice-container {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ flex: 1;
|
|
|
+}
|
|
|
+
|
|
|
+.invoice-status {
|
|
|
+ font-size: 24rpx;
|
|
|
+ color: #ff6666;
|
|
|
+ margin-left: 20rpx;
|
|
|
}
|
|
|
|
|
|
.order-status {
|
|
|
font-size: 24rpx;
|
|
|
- color: #FF6B6B;
|
|
|
}
|
|
|
|
|
|
-.order-products {
|
|
|
+.order-status.paid,
|
|
|
+.order-status.completed {
|
|
|
+ color: #00cc66;
|
|
|
+}
|
|
|
+
|
|
|
+.order-status.refunded {
|
|
|
+ color: #999999;
|
|
|
+}
|
|
|
+
|
|
|
+.order-status.pending {
|
|
|
+ color: #FF9100;
|
|
|
+}
|
|
|
+
|
|
|
+/* 订单内容 */
|
|
|
+.order-content {
|
|
|
+ display: flex;
|
|
|
padding: 20rpx;
|
|
|
+ border-bottom: 1rpx solid #f0f0f0;
|
|
|
+}
|
|
|
+
|
|
|
+.product-image {
|
|
|
+ width: 100rpx;
|
|
|
+ height: 100rpx;
|
|
|
+ margin-right: 20rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.image-placeholder {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ background-color: #f5f5f5;
|
|
|
}
|
|
|
|
|
|
-.product-item {
|
|
|
+.order-info {
|
|
|
+ flex: 1;
|
|
|
display: flex;
|
|
|
+ flex-direction: column;
|
|
|
justify-content: space-between;
|
|
|
- align-items: center;
|
|
|
- padding: 10rpx 0;
|
|
|
+ align-items: flex-end;
|
|
|
}
|
|
|
|
|
|
.product-name {
|
|
|
font-size: 28rpx;
|
|
|
- color: #333;
|
|
|
- flex: 1;
|
|
|
+ color: #333333;
|
|
|
+ font-weight: 500;
|
|
|
+ width: 100%;
|
|
|
+ text-align: left;
|
|
|
+ margin-bottom: 10rpx;
|
|
|
}
|
|
|
|
|
|
-.product-price {
|
|
|
+.price-info {
|
|
|
font-size: 28rpx;
|
|
|
- color: #333;
|
|
|
- margin: 0 20rpx;
|
|
|
}
|
|
|
|
|
|
-.product-quantity {
|
|
|
- font-size: 28rpx;
|
|
|
- color: #666;
|
|
|
+.price-label {
|
|
|
+ color: #666666;
|
|
|
+}
|
|
|
+
|
|
|
+.price-value {
|
|
|
+ color: #333333;
|
|
|
+ font-weight: 500;
|
|
|
+}
|
|
|
+
|
|
|
+.quantity-info {
|
|
|
+ font-size: 24rpx;
|
|
|
+ color: #999999;
|
|
|
}
|
|
|
|
|
|
+/* 订单底部 */
|
|
|
.order-footer {
|
|
|
display: flex;
|
|
|
- justify-content: space-between;
|
|
|
- align-items: center;
|
|
|
+ justify-content: flex-end;
|
|
|
padding: 20rpx;
|
|
|
- border-top: 1rpx solid #f0f0f0;
|
|
|
- background-color: #f9f9f9;
|
|
|
+ width: 100%;
|
|
|
+ box-sizing: border-box;
|
|
|
}
|
|
|
|
|
|
-.order-total {
|
|
|
- font-size: 28rpx;
|
|
|
- color: #333;
|
|
|
+/* 重置按钮默认样式 */
|
|
|
+.action-btn {
|
|
|
+ background-color: #ffffff;
|
|
|
+ color: #333333;
|
|
|
+ border: 1rpx solid #dddddd;
|
|
|
+ padding: 12rpx 24rpx;
|
|
|
+ border-radius: 30rpx;
|
|
|
+ font-size: 24rpx;
|
|
|
+ flex-shrink: 0;
|
|
|
+ text-align: center;
|
|
|
+ white-space: nowrap;
|
|
|
+ min-width: 160rpx;
|
|
|
+ line-height: 1;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ margin: 0; /* 彻底移除默认 margin */
|
|
|
+ width: auto;
|
|
|
}
|
|
|
|
|
|
-.order-button {
|
|
|
- background-color: #FFD700;
|
|
|
- color: #333;
|
|
|
+/* 按钮之间的间距 */
|
|
|
+.action-btn + .action-btn {
|
|
|
+ margin-left: 20rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.action-btn::after {
|
|
|
border: none;
|
|
|
- padding: 10rpx 30rpx;
|
|
|
- border-radius: 20rpx;
|
|
|
- font-size: 24rpx;
|
|
|
+}
|
|
|
+
|
|
|
+/* 详情按钮高亮 */
|
|
|
+.detail-btn {
|
|
|
+ background-color: #FFD700;
|
|
|
+ border-color: #FFD700;
|
|
|
+ color: #000000;
|
|
|
+ font-weight: 500;
|
|
|
+}
|
|
|
+
|
|
|
+.refund-btn {
|
|
|
+ color: #666666;
|
|
|
}
|
|
|
</style>
|