178 lines
4.5 KiB
TypeScript
178 lines
4.5 KiB
TypeScript
import httpService from './httpService'
|
|
import type { ApiResponse } from './httpService'
|
|
|
|
// 用户接口
|
|
export interface PublishBallData {
|
|
title: string // 球局标题
|
|
image_list: 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?: string[] // 场地描述标签
|
|
venue_description?: string // 场地描述
|
|
venue_image_list?: string[] // 场地图片
|
|
max_players: number // 人数要求
|
|
current_players: number // 人数要求
|
|
skill_level_min: number // 水平要求(NTRP)
|
|
skill_level_max: number // 水平要求(NTRP)
|
|
description: string // 备注
|
|
description_tag: string[] // 备注标签
|
|
is_substitute_supported?: boolean // 是否支持替补
|
|
is_wechat_contact?: boolean // 是否需要微信联系
|
|
wechat_contact?: string // 微信联系
|
|
}
|
|
|
|
export interface createGameData extends PublishBallData {
|
|
status: string,
|
|
created_at: string,
|
|
updated_at: string,
|
|
id?: string | number,
|
|
}
|
|
|
|
// 响应接口
|
|
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
|
|
}
|
|
|
|
// export type SourceType = 'history' | 'preset'
|
|
|
|
export interface getPicturesReq {
|
|
pageOption: {
|
|
page: number,
|
|
pageSize: number,
|
|
},
|
|
seachOption: {
|
|
tag: string,
|
|
resource_type: string,
|
|
dateRange: string[],
|
|
},
|
|
}
|
|
|
|
export interface getPicturesRes {
|
|
code: number,
|
|
message: string,
|
|
data: {
|
|
rows: [
|
|
{
|
|
user_id: string,
|
|
resource_type: string,
|
|
file_name: string,
|
|
original_name: string,
|
|
file_path: string,
|
|
file_url: string,
|
|
file_size: number,
|
|
mime_type: string,
|
|
width: number,
|
|
height: number,
|
|
duration: number,
|
|
thumbnail_url: string,
|
|
is_public: string,
|
|
tags: string[],
|
|
description: string,
|
|
view_count: number,
|
|
download_count: number,
|
|
status: string,
|
|
last_modify_time: string,
|
|
}
|
|
],
|
|
count: number,
|
|
page: number,
|
|
pageSize: number,
|
|
totalPages: number,
|
|
}
|
|
}
|
|
|
|
function delay(ms: number) {
|
|
return new Promise(resolve => setTimeout(resolve, ms))
|
|
}
|
|
// 发布球局类
|
|
class PublishService {
|
|
// 用户登录
|
|
async createPersonal(data: PublishBallData): Promise<ApiResponse<createGameData>> {
|
|
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 })
|
|
}
|
|
// 畅打发布
|
|
async create_play_pmoothlys(data: {rows: PublishBallData[]}): Promise<ApiResponse<Response>> {
|
|
return httpService.post('/games/create_play_pmoothlys', data, {
|
|
showLoading: true,
|
|
loadingText: '发布中...'
|
|
})
|
|
}
|
|
async getHistoryImageList(req: getPicturesReq): Promise<getPicturesRes> {
|
|
return httpService.post('/gallery/list', req, {
|
|
showLoading: false,
|
|
showToast: false,
|
|
})
|
|
}
|
|
async getPresetImageList(req: getPicturesReq): Promise<getPicturesRes> {
|
|
return httpService.post('/gallery/sys_img_list', req, {
|
|
showLoading: false,
|
|
showToast: false,
|
|
})
|
|
}
|
|
async getPictures(req) {
|
|
const { type, tag, otherReq = {} } = req
|
|
if (type === 'history') {
|
|
return this.getHistoryImageList({
|
|
pageOption: {
|
|
page: 1,
|
|
pageSize: 100,
|
|
},
|
|
seachOption: {
|
|
tag,
|
|
resource_type: 'image',
|
|
dateRange: [],
|
|
},
|
|
...otherReq,
|
|
})
|
|
} else {
|
|
return this.getPresetImageList({
|
|
pageOption: {
|
|
page: 1,
|
|
pageSize: 100,
|
|
},
|
|
seachOption: {
|
|
tag: '',
|
|
resource_type: 'image',
|
|
dateRange: [],
|
|
},
|
|
...otherReq,
|
|
})
|
|
}
|
|
}
|
|
}
|
|
|
|
// 导出认证服务实例
|
|
export default new PublishService() |