index.vue
10.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
<!--
* @Date: 2022-09-19 14:11:06
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-07-03 15:55:17
* @FilePath: /jgdl/src/pages/myOrders/index.vue
* @Description: 订单管理页面
-->
<template>
<view class="order-management-page">
<nut-sticky>
<!-- 买车/卖车切换 -->
<view class="view-mode-toggle">
<view class="toggle-container">
<view
class="toggle-option"
:class="{ active: viewMode === 'bought' }"
@click="setViewMode('bought')"
>
我买的车
</view>
<view
class="toggle-option"
:class="{ active: viewMode === 'sold' }"
@click="setViewMode('sold')"
>
我卖的车
</view>
</view>
</view>
<!-- 状态筛选标签 -->
<view class="status-tabs">
<view
class="tab-item"
:class="{ active: activeTab === 'all' }"
@click="setActiveTab('all')"
>
全部
</view>
<view
v-if="viewMode === 'bought'"
class="tab-item"
:class="{ active: activeTab === 'pending' }"
@click="setActiveTab('pending')"
>
待支付
</view>
<view
class="tab-item"
:class="{ active: activeTab === 'completed' }"
@click="setActiveTab('completed')"
>
已完成
</view>
<view
class="tab-item"
:class="{ active: activeTab === 'cancelled' }"
@click="setActiveTab('cancelled')"
>
已取消
</view>
</view>
</nut-sticky>
<!-- 订单列表 -->
<view class="order-list">
<!-- 滚动列表 -->
<scroll-view
class="order-scroll-view"
:style="scrollStyle"
:scroll-y="true"
@scrolltolower="loadMore"
@scroll="scroll"
:lower-threshold="50"
:enable-flex="false"
>
<!-- 空状态 -->
<view v-if="filteredOrders.length === 0" class="empty-state">
<text class="empty-text">暂无订单</text>
</view>
<!-- 订单卡片 -->
<view v-else>
<view
v-for="order in filteredOrders"
:key="order.id"
class="order-card"
>
<!-- 订单头部信息 -->
<view class="order-header">
<text class="order-date">{{ order.date }}</text>
<text class="order-status" :class="getStatusClass(order.status)">
{{ getStatusText(order.status) }}
</text>
</view>
<!-- 车辆信息 -->
<nut-row :gutter="12" class="vehicle-info">
<nut-col :span="6">
<image
:src="order.vehicle.imageUrl"
:alt="order.vehicle.name"
class="vehicle-image"
mode="aspectFill"
/>
</nut-col>
<nut-col :span="18">
<view class="vehicle-details">
<text class="vehicle-name">{{ order.vehicle.name }}</text>
<text class="vehicle-specs">
{{ order.vehicle.year }} | {{ order.vehicle.mileage }}
</text>
<text class="vehicle-battery">{{ order.vehicle.batteryCapacity }}</text>
<text class="vehicle-price">¥{{ order.vehicle.price }}</text>
</view>
</nut-col>
</nut-row>
<!-- 操作按钮 -->
<view class="order-actions">
<!-- 买车模式:待支付状态 -->
<template v-if="viewMode === 'bought' && order.status === 'pending'">
<nut-button
type="primary"
size="small"
@click="handlePayment(order.id)"
>
去支付
</nut-button>
</template>
<!-- 已完成状态 -->
<template v-if="order.status === 'completed'">
<nut-button
type="default"
size="small"
@click="viewOrderDetail(order.id)"
>
查看详情
</nut-button>
<nut-button
type="primary"
size="small"
@click="rateOrder(order.id)"
class="ml-2"
>
评价
</nut-button>
</template>
<!-- 已取消状态 -->
<template v-if="order.status === 'cancelled'">
<nut-button
type="default"
size="small"
@click="deleteOrder(order.id)"
>
删除订单
</nut-button>
</template>
</view>
</view>
</view>
<!-- 加载更多指示器 -->
<view v-if="loading" class="loading-container">
<text class="loading-text">加载中...</text>
</view>
<!-- 没有更多数据 -->
<view v-if="!hasMore && filteredOrders.length > 0" class="no-more">
<text class="no-more-text">没有更多订单了</text>
</view>
</scroll-view>
</view>
</view>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue'
import Taro from '@tarojs/taro'
import './index.less'
// 页面状态
const activeTab = ref('all')
const viewMode = ref('bought')
const loading = ref(false)
const hasMore = ref(true)
// 模拟订单数据
const boughtOrders = ref([
{
id: '1',
date: '2023-11-15 14:30',
status: 'pending',
vehicle: {
name: '小牛 U1 Pro',
year: '2022年',
mileage: '续航120km',
batteryCapacity: '电池容量:1.5kWh',
price: 3999,
imageUrl: 'https://images.unsplash.com/photo-1558981285-6f0c94958bb6?ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60'
}
},
{
id: '2',
date: '2023-10-28 09:15',
status: 'completed',
vehicle: {
name: '雅迪 G5',
year: '2021年',
mileage: '续航80km',
batteryCapacity: '电池容量:1.2kWh',
price: 2599,
imageUrl: 'https://images.unsplash.com/photo-1558981403-c5f9899a28bc?ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60'
}
},
{
id: '3',
date: '2023-09-05 16:45',
status: 'cancelled',
vehicle: {
name: '绿源 MN5',
year: '2023年',
mileage: '续航100km',
batteryCapacity: '电池容量:1.8kWh',
price: 4299,
imageUrl: 'https://images.unsplash.com/photo-1567922045116-2a00fae2ed03?ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60'
}
}
])
const soldOrders = ref([
{
id: '4',
date: '2023-11-10 11:20',
status: 'pending',
vehicle: {
name: '爱玛 A3',
year: '2022年',
mileage: '续航90km',
batteryCapacity: '电池容量:1.3kWh',
price: 3299,
imageUrl: 'https://images.unsplash.com/photo-1591637333184-19aa84b3e01f?ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60'
}
},
{
id: '5',
date: '2023-10-15 13:45',
status: 'completed',
vehicle: {
name: '台铃 战速',
year: '2023年',
mileage: '续航110km',
batteryCapacity: '电池容量:1.6kWh',
price: 3599,
imageUrl: 'https://images.unsplash.com/photo-1558980664-3a031cf67ea8?ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60'
}
}
])
/**
* 根据当前视图模式和筛选条件获取过滤后的订单列表
*/
const filteredOrders = computed(() => {
const orders = viewMode.value === 'bought' ? boughtOrders.value : soldOrders.value
if (activeTab.value === 'all') {
return orders
}
return orders.filter(order => {
if (activeTab.value === 'pending') return order.status === 'pending'
if (activeTab.value === 'completed') return order.status === 'completed'
if (activeTab.value === 'cancelled') return order.status === 'cancelled'
return true
})
})
// 滚动样式
const scrollStyle = computed(() => {
return {
height: 'calc(100vh - 320rpx)' // 减去头部和标签的高度
}
})
/**
* 设置视图模式(买车/卖车)
*/
const setViewMode = (mode) => {
viewMode.value = mode
// 重置列表加载状态
resetListState()
}
/**
* 设置活跃的状态标签
*/
const setActiveTab = (tab) => {
activeTab.value = tab
// 重置列表加载状态
resetListState()
}
/**
* 重置列表加载状态
*/
const resetListState = () => {
loading.value = false
hasMore.value = true
}
/**
* 滚动事件处理
*/
const scroll = (e) => {
// 可以在这里处理滚动事件
}
/**
* 加载更多数据
*/
const loadMore = () => {
if (loading.value || !hasMore.value) return
loading.value = true
// 模拟加载更多数据
setTimeout(() => {
loading.value = false
// 这里可以添加实际的加载更多逻辑
// 如果没有更多数据,设置 hasMore.value = false
}, 1000)
}
/**
* 获取订单状态文本
*/
const getStatusText = (status) => {
switch (status) {
case 'pending':
return '待支付'
case 'completed':
return '已完成'
case 'cancelled':
return '已取消'
default:
return ''
}
}
/**
* 获取订单状态样式类
*/
const getStatusClass = (status) => {
switch (status) {
case 'pending':
return 'status-pending'
case 'completed':
return 'status-completed'
case 'cancelled':
return 'status-cancelled'
default:
return ''
}
}
// 页面导航相关方法可以在需要时添加
/**
* 处理支付
*/
const handlePayment = (orderId) => {
Taro.showToast({
title: '跳转到支付页面',
icon: 'none'
})
// TODO: 实现支付逻辑
}
/**
* 查看订单详情
*/
const viewOrderDetail = (orderId) => {
Taro.navigateTo({
url: `/pages/orderDetail/index?id=${orderId}`
})
}
/**
* 评价订单
*/
const rateOrder = (orderId) => {
Taro.showToast({
title: '跳转到评价页面',
icon: 'none'
})
// TODO: 实现评价逻辑
}
/**
* 删除订单
*/
const deleteOrder = (orderId) => {
Taro.showModal({
title: '确认删除',
content: '确定要删除这个订单吗?',
success: (res) => {
if (res.confirm) {
// TODO: 实现删除订单逻辑
Taro.showToast({
title: '订单已删除',
icon: 'success'
})
}
}
})
}
// 页面加载时的初始化
onMounted(() => {
// TODO: 加载订单数据
})
</script>
<script>
export default {
name: "OrderManagementPage",
};
</script>
<style lang="less">
/* 样式已移至 index.less 文件 */
</style>