fix: 修复订单管理功能

This commit is contained in:
richarjiang
2026-04-12 18:16:18 +08:00
parent 0810f71250
commit 9639f44698
4 changed files with 78 additions and 20 deletions

View File

@@ -44,7 +44,9 @@
class="list-scroll"
:refresher-enabled="true"
:refresher-triggered="refreshing"
:lower-threshold="120"
@refresherrefresh="onRefresh"
@scrolltolower="loadMore"
>
<!-- Loading skeleton -->
<view v-if="loading && !orders.length" class="order-list">
@@ -120,7 +122,7 @@
</view>
<!-- Load more / no more -->
<view v-if="hasMore" class="load-more" @tap="loadMore">
<view v-if="hasMore" class="load-more">
<text class="load-more-text">{{ loading ? '加载中...' : '加载更多' }}</text>
</view>
<view v-else-if="orders.length > 0" class="no-more">

View File

@@ -20,6 +20,33 @@ import type {
UpdateFlashSaleDto,
} from '@mp-pilates/shared'
interface LegacyPaginatedData<T> {
readonly data: readonly T[]
readonly total: number
readonly page: number
readonly limit: number
}
function normalizePaginatedData<T>(
result: PaginatedData<T> | LegacyPaginatedData<T>,
): PaginatedData<T> {
if ('items' in result) {
return {
items: [...result.items],
total: result.total,
page: result.page,
limit: result.limit,
}
}
return {
items: [...result.data],
total: result.total,
page: result.page,
limit: result.limit,
}
}
export interface AdminStats {
todayBookings: number
totalOrders: number
@@ -82,13 +109,13 @@ export const useAdminStore = defineStore('admin', () => {
}
async function createCardType(dto: CreateCardTypeDto): Promise<CardType> {
const data = await post<CardType>('/admin/card-types', dto)
const data = await post<CardType>('/admin/card-types', dto as unknown as Record<string, unknown>)
await fetchCardTypes()
return data
}
async function updateCardType(id: string, dto: UpdateCardTypeDto): Promise<CardType> {
const data = await put<CardType>(`/admin/card-types/${id}`, dto)
const data = await put<CardType>(`/admin/card-types/${id}`, dto as unknown as Record<string, unknown>)
await fetchCardTypes()
return data
}
@@ -109,7 +136,7 @@ export const useAdminStore = defineStore('admin', () => {
}
async function saveStudioConfig(dto: UpdateStudioConfigDto): Promise<StudioConfig> {
const data = await put<StudioConfig>('/admin/studio/info', dto)
const data = await put<StudioConfig>('/admin/studio/info', dto as unknown as Record<string, unknown>)
studioConfig.value = data
return data
}
@@ -120,10 +147,11 @@ export const useAdminStore = defineStore('admin', () => {
limit?: number
status?: string
}): Promise<PaginatedData<OrderWithDetails>> {
console.log('[admin] fetchAdminOrders params:', params)
const result = await get<PaginatedData<OrderWithDetails>>('/admin/orders', params)
console.log('[admin] fetchAdminOrders result:', result)
return result
const result = await get<PaginatedData<OrderWithDetails> | LegacyPaginatedData<OrderWithDetails>>(
'/admin/orders',
params,
)
return normalizePaginatedData(result)
}
// ── Bookings ─────────────────────────────────────────────────────
@@ -176,7 +204,7 @@ export const useAdminStore = defineStore('admin', () => {
}
async function createManualSlot(dto: CreateManualSlotDto): Promise<TimeSlot> {
return post<TimeSlot>('/admin/time-slot/manual', dto)
return post<TimeSlot>('/admin/time-slot/manual', dto as unknown as Record<string, unknown>)
}
async function closeSlot(id: string): Promise<TimeSlot> {

View File

@@ -1,16 +1,7 @@
import type { ApiResponse, PaginatedData } from '@mp-pilates/shared'
const BASE_URL = (() => {
try {
const { miniProgram } = uni.getAccountInfoSync()
if (miniProgram.envVersion !== 'develop') {
return 'https://focus.richarjiang.com/api'
}
} catch {
// 非小程序环境,使用开发地址
}
return 'http://localhost:3000/api'
})()
// 统一使用线上服务地址
const BASE_URL = 'https://focus.richarjiang.com/api'
interface RequestOptions {
readonly url: string