Generating commit message...

This commit is contained in:
2025-08-30 14:33:49 +08:00
parent 4d469e95f0
commit 7f9bfbb381
99 changed files with 69225 additions and 35 deletions

View File

@@ -0,0 +1,160 @@
<template>
<view class="container">
<!-- 用户信息 -->
<view class="user-header">
<image :src="user.avatar" class="avatar"></image>
<view class="user-info">
<text class="username">{{ user.nickname }}</text>
<text class="member-level">{{ user.memberLevel }}</text>
</view>
</view>
<!-- 订单状态 -->
<view class="order-status">
<view
class="status-item"
v-for="item in orderStatus"
:key="item.type"
@click="navigateToOrder(item.type)"
>
<text class="count">{{ item.count }}</text>
<text class="text">{{ item.text }}</text>
</view>
</view>
<!-- 功能列表 -->
<view class="function-list">
<view
class="function-item"
v-for="item in functions"
:key="item.text"
@click="navigateTo(item.url)"
>
<uni-icons :type="item.icon" size="20" color="#666"></uni-icons>
<text class="text">{{ item.text }}</text>
<uni-icons type="arrowright" size="16" color="#999"></uni-icons>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
user: {
avatar: '/static/user/avatar.jpg',
nickname: '旅行爱好者',
memberLevel: '黄金会员'
},
orderStatus: [
{ type: 'all', text: '全部订单', count: 5 },
{ type: 'unpaid', text: '待付款', count: 1 },
{ type: 'undelivered', text: '待发货', count: 1 },
{ type: 'delivered', text: '待收货', count: 2 },
{ type: 'completed', text: '已完成', count: 1 }
],
functions: [
{ icon: 'heart', text: '我的认养', url: '/pages/user/adoptions' },
{ icon: 'map', text: '我的旅行计划', url: '/pages/user/travels' },
{ icon: 'gift', text: '我的送花订单', url: '/pages/user/flowers' },
{ icon: 'star', text: '我的收藏', url: '/pages/user/favorites' },
{ icon: 'settings', text: '账户设置', url: '/pages/user/settings' }
]
}
},
methods: {
navigateTo(url) {
uni.navigateTo({ url })
},
navigateToOrder(type) {
uni.navigateTo({ url: `/pages/user/orders?type=${type}` })
}
}
}
</script>
<style scoped>
.container {
background-color: #f8f9fa;
min-height: 100vh;
}
.user-header {
display: flex;
align-items: center;
padding: 40rpx 30rpx;
background-color: #fff;
margin-bottom: 20rpx;
}
.avatar {
width: 120rpx;
height: 120rpx;
border-radius: 50%;
margin-right: 30rpx;
}
.user-info {
display: flex;
flex-direction: column;
}
.username {
font-size: 36rpx;
font-weight: bold;
margin-bottom: 10rpx;
}
.member-level {
font-size: 24rpx;
color: #ff9500;
background-color: #fff8e6;
padding: 4rpx 16rpx;
border-radius: 20rpx;
align-self: flex-start;
}
.order-status {
display: flex;
background-color: #fff;
padding: 30rpx 0;
margin-bottom: 20rpx;
}
.status-item {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
}
.count {
font-size: 32rpx;
color: #333;
margin-bottom: 10rpx;
}
.text {
font-size: 24rpx;
color: #666;
}
.function-list {
background-color: #fff;
}
.function-item {
display: flex;
align-items: center;
padding: 30rpx;
border-bottom: 1rpx solid #f5f5f5;
}
.function-item .text {
flex: 1;
margin-left: 20rpx;
font-size: 28rpx;
color: #333;
}
</style>

View File

@@ -0,0 +1,480 @@
<template>
<view class="container">
<!-- 订单类型选项卡 -->
<view class="tab-bar">
<view
v-for="(tab, index) in tabs"
:key="index"
class="tab-item"
:class="{ active: currentTab === index }"
@click="switchTab(index)"
>
<text>{{ tab.text }}</text>
</view>
</view>
<!-- 订单列表 -->
<scroll-view
class="order-list"
scroll-y="true"
@scrolltolower="loadMore"
>
<view v-if="orders.length === 0" class="empty-tip">
<image src="/static/user/empty-order.png" class="empty-image"></image>
<text>暂无相关订单</text>
</view>
<view
v-for="(order, index) in orders"
:key="index"
class="order-item"
@click="navigateToDetail(order.id)"
>
<!-- 订单头部 -->
<view class="order-header">
<text class="order-type">{{ getOrderTypeName(order.type) }}</text>
<text class="order-status">{{ getStatusText(order.status) }}</text>
</view>
<!-- 订单内容 -->
<view class="order-content">
<image :src="order.image" class="order-image"></image>
<view class="order-info">
<text class="order-title">{{ order.title }}</text>
<text class="order-desc">{{ order.description }}</text>
<view class="order-price-box">
<text class="order-price">¥{{ order.price }}</text>
<text class="order-count">x{{ order.count }}</text>
</view>
</view>
</view>
<!-- 订单底部 -->
<view class="order-footer">
<text class="order-total">{{ order.count }}件商品 合计¥{{ order.price * order.count }}</text>
<view class="order-actions">
<button
v-if="order.status === 'unpaid'"
class="action-btn primary"
@click.stop="payOrder(order.id)"
>立即付款</button>
<button
v-if="order.status === 'delivered'"
class="action-btn primary"
@click.stop="confirmReceive(order.id)"
>确认收货</button>
<button
v-if="order.status === 'completed'"
class="action-btn"
@click.stop="reviewOrder(order.id)"
>评价</button>
<button
class="action-btn"
@click.stop="deleteOrder(order.id)"
>删除订单</button>
</view>
</view>
</view>
<!-- 加载更多 -->
<view v-if="loading" class="loading">
<text>加载中...</text>
</view>
<view v-if="noMore && orders.length > 0" class="no-more">
<text>没有更多订单了</text>
</view>
</scroll-view>
</view>
</template>
<script>
export default {
data() {
return {
tabs: [
{ text: '全部', type: 'all' },
{ text: '待付款', type: 'unpaid' },
{ text: '待发货', type: 'undelivered' },
{ text: '待收货', type: 'delivered' },
{ text: '已完成', type: 'completed' }
],
currentTab: 0,
orders: [],
page: 1,
loading: false,
noMore: false
}
},
onLoad(options) {
// 如果有传入类型参数,切换到对应选项卡
if (options.type) {
const index = this.tabs.findIndex(tab => tab.type === options.type)
if (index !== -1) {
this.currentTab = index
}
}
this.loadOrders()
},
methods: {
switchTab(index) {
if (this.currentTab === index) return
this.currentTab = index
this.page = 1
this.orders = []
this.noMore = false
this.loadOrders()
},
loadOrders() {
if (this.loading || this.noMore) return
this.loading = true
// 模拟API请求
setTimeout(() => {
const type = this.tabs[this.currentTab].type
const newOrders = this.getMockOrders(type, this.page)
if (newOrders.length === 0) {
this.noMore = true
} else {
this.orders = [...this.orders, ...newOrders]
this.page++
}
this.loading = false
}, 1000)
},
loadMore() {
this.loadOrders()
},
getMockOrders(type, page) {
// 模拟数据实际应从API获取
const allOrders = [
{
id: '1001',
type: 'travel',
status: 'unpaid',
title: '西藏旅行计划',
description: '10月1日-10月7日',
price: 5000,
count: 1,
image: '/static/travel/tibet.jpg'
},
{
id: '1002',
type: 'animal',
status: 'undelivered',
title: '小羊驼认养',
description: '认养期限1年',
price: 1000,
count: 1,
image: '/static/animals/alpaca.jpg'
},
{
id: '1003',
type: 'flower',
status: 'delivered',
title: '浪漫玫瑰花束',
description: '11朵红玫瑰',
price: 199,
count: 1,
image: '/static/flowers/rose.jpg'
},
{
id: '1004',
type: 'flower',
status: 'completed',
title: '向日葵花束',
description: '9朵向日葵',
price: 179,
count: 1,
image: '/static/flowers/sunflower.jpg'
}
]
// 根据类型筛选
let filteredOrders = allOrders
if (type !== 'all') {
filteredOrders = allOrders.filter(order => order.status === type)
}
// 分页
const pageSize = 5
const start = (page - 1) * pageSize
const end = page * pageSize
return filteredOrders.slice(start, end)
},
getOrderTypeName(type) {
const typeMap = {
travel: '旅行计划',
animal: '动物认养',
flower: '送花服务'
}
return typeMap[type] || '订单'
},
getStatusText(status) {
const statusMap = {
unpaid: '待付款',
undelivered: '待发货',
delivered: '待收货',
completed: '已完成'
}
return statusMap[status] || '未知状态'
},
navigateToDetail(id) {
uni.navigateTo({
url: `/pages/user/order-detail?id=${id}`
})
},
payOrder(id) {
uni.showModal({
title: '支付提示',
content: '确定要支付此订单吗?',
success: (res) => {
if (res.confirm) {
// 模拟支付流程
uni.showLoading({
title: '支付中...'
})
setTimeout(() => {
uni.hideLoading()
uni.showToast({
title: '支付成功',
icon: 'success'
})
// 更新订单状态
this.updateOrderStatus(id, 'undelivered')
}, 1500)
}
}
})
},
confirmReceive(id) {
uni.showModal({
title: '确认收货',
content: '确认已收到商品吗?',
success: (res) => {
if (res.confirm) {
uni.showToast({
title: '确认成功',
icon: 'success'
})
// 更新订单状态
this.updateOrderStatus(id, 'completed')
}
}
})
},
reviewOrder(id) {
uni.navigateTo({
url: `/pages/user/review?id=${id}`
})
},
deleteOrder(id) {
uni.showModal({
title: '删除订单',
content: '确定要删除此订单吗?',
success: (res) => {
if (res.confirm) {
// 从列表中移除
const index = this.orders.findIndex(order => order.id === id)
if (index !== -1) {
this.orders.splice(index, 1)
uni.showToast({
title: '删除成功',
icon: 'success'
})
}
}
}
})
},
updateOrderStatus(id, newStatus) {
const order = this.orders.find(order => order.id === id)
if (order) {
order.status = newStatus
}
}
}
}
</script>
<style scoped>
.container {
display: flex;
flex-direction: column;
height: 100vh;
background-color: #f8f9fa;
}
.tab-bar {
display: flex;
background-color: #fff;
border-bottom: 1rpx solid #eee;
position: sticky;
top: 0;
z-index: 10;
}
.tab-item {
flex: 1;
height: 80rpx;
display: flex;
justify-content: center;
align-items: center;
font-size: 28rpx;
color: #666;
position: relative;
}
.tab-item.active {
color: #007aff;
}
.tab-item.active::after {
content: '';
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 40rpx;
height: 4rpx;
background-color: #007aff;
}
.order-list {
flex: 1;
padding: 20rpx;
}
.empty-tip {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 100rpx 0;
}
.empty-image {
width: 200rpx;
height: 200rpx;
margin-bottom: 20rpx;
}
.order-item {
background-color: #fff;
border-radius: 10rpx;
margin-bottom: 20rpx;
overflow: hidden;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
}
.order-header {
display: flex;
justify-content: space-between;
padding: 20rpx;
border-bottom: 1rpx solid #f5f5f5;
}
.order-type {
font-size: 28rpx;
color: #333;
}
.order-status {
font-size: 28rpx;
color: #ff9500;
}
.order-content {
display: flex;
padding: 20rpx;
border-bottom: 1rpx solid #f5f5f5;
}
.order-image {
width: 160rpx;
height: 160rpx;
border-radius: 8rpx;
margin-right: 20rpx;
}
.order-info {
flex: 1;
display: flex;
flex-direction: column;
}
.order-title {
font-size: 28rpx;
color: #333;
margin-bottom: 10rpx;
}
.order-desc {
font-size: 24rpx;
color: #999;
margin-bottom: 10rpx;
}
.order-price-box {
display: flex;
justify-content: space-between;
margin-top: auto;
}
.order-price {
font-size: 28rpx;
color: #ff2d55;
}
.order-count {
font-size: 24rpx;
color: #999;
}
.order-footer {
padding: 20rpx;
}
.order-total {
font-size: 24rpx;
color: #666;
text-align: right;
margin-bottom: 20rpx;
}
.order-actions {
display: flex;
justify-content: flex-end;
}
.action-btn {
margin-left: 20rpx;
font-size: 24rpx;
padding: 0 30rpx;
height: 60rpx;
line-height: 60rpx;
border: 1rpx solid #ddd;
background-color: #fff;
color: #666;
}
.action-btn.primary {
background-color: #007aff;
color: #fff;
border: none;
}
.loading, .no-more {
text-align: center;
padding: 20rpx 0;
font-size: 24rpx;
color: #999;
}
</style>