Files
mini-programs/src/services/publishService.ts
2025-08-24 16:04:31 +08:00

72 lines
2.0 KiB
TypeScript

import httpService from './httpService'
import type { ApiResponse } from './httpService'
// 用户接口
export interface PublishBallData {
title: string // 球局标题
image_list: Array<string>[] // 球局封面
start_time: string,
end_time: string
play_type: string // 玩法类型
price: number | string // 价格
venue_id?: number | null // 场地id
location_name?: string // 场地名称
location?: string // 场地地址
latitude?: string // 纬度
longitude?: string // 经度
court_type?: string // 场地类型 1: 室内 2: 室外
court_surface?: string // 场地表面 1: 硬地 2: 红土 3: 草地
venue_description_tag?: Array<string>[] // 场地描述标签
venue_description?: string // 场地描述
venue_image_list?: Array<string>[] // 场地图片
max_players: number // 人数要求
current_players: number // 人数要求
skill_level_min: number // 水平要求(NTRP)
skill_level_max: number // 水平要求(NTRP)
description: string // 备注
description_tag: Array<string>[] // 备注标签
is_substitute_supported: boolean // 是否支持替补
is_wechat_contact: boolean // 是否需要微信联系
wechat_contact?: string // 微信联系
}
// 响应接口
export interface Response {
code: string
message: string
data: any
}
// 响应接口
export interface StadiumListResponse {
rows: Stadium[]
}
export interface Stadium {
id?: string
name: string
address?: string
istance?: string
longitude?: number
latitude?: number
}
// 发布球局类
class PublishService {
// 发布
async createPersonal(data: PublishBallData): Promise<ApiResponse<Response>> {
return httpService.post('/games/create', data, {
showLoading: true,
loadingText: '发布中...'
})
}
// 获取球场列表
async getStadiumList(data: { seachOption: { latitude: number, longitude: number }}): Promise<ApiResponse<StadiumListResponse>> {
return httpService.post('/venues/list', data, {
showLoading: false })
}
}
// 导出认证服务实例
export default new PublishService()