b06cf69942
- 商城页改为Tab切换(储值卡/会员卡)+卡片列表,新增商品详情页 - 约课页合并会员卡/团课/门票三Tab,日期横滑选择器 - 会员卡预约新增详情页+二次确认弹窗 - 课程列表已预约状态改为后端返回booked/booking_id/booking_type - 前端移除冗余的loadBookings调用,直接读session.booked字段 - 导航栏仅首页custom,其余页面恢复原生导航栏 - membership API支持date参数筛选
62 lines
2.0 KiB
JavaScript
62 lines
2.0 KiB
JavaScript
import { request } from './request'
|
|
import { compactParams, toArray, toNumber, toPageQuery, toPagination } from './mappers'
|
|
|
|
const toCourseCourt = (backendCourt = {}) => ({
|
|
id: backendCourt.id ?? null,
|
|
name: backendCourt.name || '',
|
|
court_type: backendCourt.court_type || '',
|
|
court_type_label: backendCourt.court_type_label || ''
|
|
})
|
|
|
|
export const toSession = (backendSession = {}) => ({
|
|
id: backendSession.id ?? null,
|
|
course_id: backendSession.course_id ?? null,
|
|
title: backendSession.title || '',
|
|
cover_image: backendSession.cover_image || '',
|
|
coach_id: backendSession.coach_id ?? null,
|
|
coach_name: backendSession.coach_name || '',
|
|
start_at: backendSession.start_at || '',
|
|
end_at: backendSession.end_at || '',
|
|
capacity: toNumber(backendSession.capacity),
|
|
booked_count: toNumber(backendSession.booked_count),
|
|
remaining_count: toNumber(backendSession.remaining_count),
|
|
price: backendSession.price || '0.00',
|
|
status: backendSession.status || '',
|
|
status_label: backendSession.status_label || backendSession.status || '',
|
|
courts: toArray(backendSession.courts).map(toCourseCourt),
|
|
detail_html: backendSession.detail_html || '',
|
|
booked: backendSession.booked === true,
|
|
booking_id: backendSession.booking_id ?? null,
|
|
booking_type: backendSession.booking_type || null,
|
|
created_at: backendSession.created_at || '',
|
|
updated_at: backendSession.updated_at || ''
|
|
})
|
|
|
|
const toSessionQuery = (params = {}) => compactParams({
|
|
...toPageQuery(params),
|
|
date: params.date,
|
|
coach_id: params.coachId || params.coach_id,
|
|
court_type: params.courtType || params.court_type
|
|
})
|
|
|
|
export const courseApi = {
|
|
getSessions(params = {}) {
|
|
return request({
|
|
url: '/api/sessions',
|
|
data: toSessionQuery(params)
|
|
}).then((data) => toPagination(data, toSession))
|
|
},
|
|
getSessionDetail(id) {
|
|
return request({
|
|
url: `/api/sessions/${id}`
|
|
}).then(toSession)
|
|
},
|
|
createCourseBooking(sessionId) {
|
|
return request({
|
|
url: '/api/bookings/course',
|
|
method: 'POST',
|
|
data: { session_id: sessionId }
|
|
})
|
|
}
|
|
}
|