import { get, getL, post } from './http'; const apis = { LIST: '/api/luckRoom', DETAIL: '/api/luckRoom/detail', JOIN: '/api/luckRoom/participate', RECORD: '/api/luckRoom/participateRecordMy', LIST_CREATE: '/api/luckRoom/myCreate', CREATE: '/api/luckRoom/create', ROOM_AUDIT_RECORD: '/api/luckRoom/roomParticipateRecord', ROOM_AUDIT_PASS: '/api/luckRoom/auditPass', ROOM_AUDIT_UNPASS: '/api/luckRoom/auditUnpass', WINNINGRECORD: '/api/luckRoom/winningTheLotteryRecord', LUCKNUMLIST: '/api/luckRoom/mySign', ROOM_TYPE: '/api/luckRoom/roomType', DATE_TIME_SCOPE: '/api/wallet/dateTimeScope', // 用于首页活动时间判断 }; export const getWealList = async (current: number, size: number, keyword?: string, type?: string, loading = false) => { const res = await post(apis.LIST, { current, size, keyword, type }, { loading }); return res.data; }; export const getWealDetail = async (roomId: string, loading = false) => { const res = await get(apis.DETAIL, { roomId }, { loading }); return res.data; }; export const joinWealRoom = async (roomId: string, password = '', shareId?: string) => { const res = await getL(apis.JOIN, { roomId, password, shareId }); return res; }; export const getWealRecord = async (current: number, size: number, loading = false) => { const res = await post(apis.RECORD, { current, size }, { loading }); return res.data; }; export const getWinningRecord = async (roomId: string) => { const res = await get(apis.WINNINGRECORD, { roomId }); return res.data; }; export const getLuckNumList = async (roomId: string) => { const res = await getL(`${apis.LUCKNUMLIST}?roomId=${roomId}`); return res.data; }; export const getRoomTypePermission = async () => { const res = await getL(apis.ROOM_TYPE); return res.data; }; export const getDateTimeScope = async () => { const res = await get(apis.DATE_TIME_SCOPE); return res.data; }; // 后续如有创建相关需求可继续添加 export const getMyCreateList = async (current: number, size: number, loading = false) => { const res = await post(apis.LIST_CREATE, { current, size }, { loading }); return res.data; }; export const createRoom = async (params: { description: string; inventoryIds: string[]; luckTime: string; name: string; password?: string; participateMode?: number; }) => { console.log('Service: createRoom called', params); try { const res = await post(apis.CREATE, params, { loading: true }); console.log('Service: createRoom response', res); return res; } catch (error) { console.error('Service: createRoom error', error); return { success: false, msg: '网络或未知错误' }; } }; export default { getWealList, getWealDetail, joinWealRoom, getWealRecord, getWinningRecord, getLuckNumList, getRoomTypePermission, getDateTimeScope, getMyCreateList, createRoom, };