hookehuyr

feat(订单页面): 添加订单状态筛选功能

在订单页面中添加了订单状态筛选功能,用户可以通过选择器筛选不同状态的订单。同时更新了 vant 配置以支持选择器的样式调整。
...@@ -39,6 +39,7 @@ declare module 'vue' { ...@@ -39,6 +39,7 @@ declare module 'vue' {
39 VanImage: typeof import('vant/es')['Image'] 39 VanImage: typeof import('vant/es')['Image']
40 VanList: typeof import('vant/es')['List'] 40 VanList: typeof import('vant/es')['List']
41 VanNavBar: typeof import('vant/es')['NavBar'] 41 VanNavBar: typeof import('vant/es')['NavBar']
42 + VanPicker: typeof import('vant/es')['Picker']
42 VanPickerGroup: typeof import('vant/es')['PickerGroup'] 43 VanPickerGroup: typeof import('vant/es')['PickerGroup']
43 VanPopup: typeof import('vant/es')['Popup'] 44 VanPopup: typeof import('vant/es')['Popup']
44 VanProgress: typeof import('vant/es')['Progress'] 45 VanProgress: typeof import('vant/es')['Progress']
......
1 /* 1 /*
2 * @Date: 2025-03-24 13:44:27 2 * @Date: 2025-03-24 13:44:27
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-03-24 13:54:49 4 + * @LastEditTime: 2025-04-16 18:28:45
5 * @FilePath: /mlaj/src/vant.config.js 5 * @FilePath: /mlaj/src/vant.config.js
6 * @Description: 文件描述 6 * @Description: 文件描述
7 */ 7 */
...@@ -48,5 +48,8 @@ export const themeVars = { ...@@ -48,5 +48,8 @@ export const themeVars = {
48 // 弹出层 48 // 弹出层
49 popupBackgroundColor: '#ffffff', 49 popupBackgroundColor: '#ffffff',
50 popupCloseIconColor: '#9ca3af', 50 popupCloseIconColor: '#9ca3af',
51 - popupCloseIconActiveColor: '#6b7280' 51 + popupCloseIconActiveColor: '#6b7280',
52 +
53 + // Picker 选择器
54 + pickerConfirmActionColor: '#22c55e',
52 }; 55 };
......
...@@ -5,6 +5,35 @@ ...@@ -5,6 +5,35 @@
5 <template> 5 <template>
6 <AppLayout title="我的订单"> 6 <AppLayout title="我的订单">
7 <div class="bg-gradient-to-b from-green-50/70 to-white/90 min-h-screen"> 7 <div class="bg-gradient-to-b from-green-50/70 to-white/90 min-h-screen">
8 + <!-- 状态筛选 -->
9 + <div class="px-4 py-3">
10 + <div
11 + class="flex items-center justify-between p-3 bg-white rounded-lg shadow-sm"
12 + @click="showStatusPicker = true"
13 + >
14 + <span class="text-gray-600">订单状态</span>
15 + <div class="flex items-center text-gray-500">
16 + <span>{{ selectedStatusText }}</span>
17 + <van-icon name="arrow" class="ml-1" />
18 + </div>
19 + </div>
20 + </div>
21 +
22 + <van-popup
23 + v-model:show="showStatusPicker"
24 + position="bottom"
25 + round
26 + >
27 + <van-picker
28 + :columns="statusColumns"
29 + @confirm="onStatusConfirm"
30 + @cancel="showStatusPicker = false"
31 + :default-index="currentStatusIndex"
32 + show-toolbar
33 + title="选择订单状态"
34 + />
35 + </van-popup>
36 +
8 <!-- 订单列表 --> 37 <!-- 订单列表 -->
9 <van-list 38 <van-list
10 v-model:loading="loading" 39 v-model:loading="loading"
...@@ -194,9 +223,46 @@ const statusMap = { ...@@ -194,9 +223,46 @@ const statusMap = {
194 223
195 // 初始化加载订单列表 224 // 初始化加载订单列表
196 // 加载更多 225 // 加载更多
226 +// 状态筛选相关
227 +const showStatusPicker = ref(false)
228 +const selectedStatus = ref('')
229 +const selectedStatusText = ref('全部')
230 +
231 +// 构建状态选项
232 +const statusColumns = [
233 + { text: '全部', value: '' },
234 + ...Object.entries(statusMap).map(([key, value]) => ({
235 + text: value.text,
236 + value: key
237 + }))
238 +]
239 +
240 +// 获取当前状态在选项中的索引
241 +const currentStatusIndex = computed(() => {
242 + return statusColumns.findIndex(item => item.value === selectedStatus.value)
243 +})
244 +
245 +// 状态选择确认
246 +const onStatusConfirm = ({ selectedValues, selectedOptions }) => {
247 + selectedStatus.value = selectedValues[0]
248 + selectedStatusText.value = selectedOptions[0].text
249 + showStatusPicker.value = false
250 + // 重置分页参数
251 + page.value = 0
252 + orders.value = []
253 + finished.value = false
254 + // 重新加载数据
255 + onLoad()
256 +}
257 +
258 +// 修改加载更多函数
197 const onLoad = async () => { 259 const onLoad = async () => {
198 const nextPage = page.value; 260 const nextPage = page.value;
199 - const res = await getOrderListAPI({ limit: limit.value, page: nextPage, status: '' }); 261 + const res = await getOrderListAPI({
262 + limit: limit.value,
263 + page: nextPage,
264 + status: selectedStatus.value
265 + });
200 if (res.code) { 266 if (res.code) {
201 orders.value = [...orders.value, ...res.data]; 267 orders.value = [...orders.value, ...res.data];
202 finished.value = res.data.length < limit.value; 268 finished.value = res.data.length < limit.value;
......