weal.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import { get, getL, post } from './http';
  2. const apis = {
  3. LIST: '/api/luckRoom',
  4. DETAIL: '/api/luckRoom/detail',
  5. JOIN: '/api/luckRoom/participate',
  6. RECORD: '/api/luckRoom/participateRecordMy',
  7. LIST_CREATE: '/api/luckRoom/myCreate',
  8. CREATE: '/api/luckRoom/create',
  9. ROOM_AUDIT_RECORD: '/api/luckRoom/roomParticipateRecord',
  10. ROOM_AUDIT_PASS: '/api/luckRoom/auditPass',
  11. ROOM_AUDIT_UNPASS: '/api/luckRoom/auditUnpass',
  12. WINNINGRECORD: '/api/luckRoom/winningTheLotteryRecord',
  13. LUCKNUMLIST: '/api/luckRoom/mySign',
  14. ROOM_TYPE: '/api/luckRoom/roomType',
  15. DATE_TIME_SCOPE: '/api/wallet/dateTimeScope', // 用于首页活动时间判断
  16. };
  17. export const getWealList = async (current: number, size: number, keyword?: string, type?: string, loading = false) => {
  18. const res = await post(apis.LIST, { current, size, keyword, type }, { loading });
  19. return res.data;
  20. };
  21. export const getWealDetail = async (roomId: string, loading = false) => {
  22. const res = await get(apis.DETAIL, { roomId }, { loading });
  23. return res.data;
  24. };
  25. export const joinWealRoom = async (roomId: string, password = '', shareId?: string) => {
  26. const res = await getL(apis.JOIN, { roomId, password, shareId });
  27. return res;
  28. };
  29. export const getWealRecord = async (current: number, size: number, loading = false) => {
  30. const res = await post(apis.RECORD, { current, size }, { loading });
  31. return res.data;
  32. };
  33. export const getWinningRecord = async (roomId: string) => {
  34. const res = await get(apis.WINNINGRECORD, { roomId });
  35. return res.data;
  36. };
  37. export const getLuckNumList = async (roomId: string) => {
  38. const res = await getL(`${apis.LUCKNUMLIST}?roomId=${roomId}`);
  39. return res.data;
  40. };
  41. export const getRoomTypePermission = async () => {
  42. const res = await getL(apis.ROOM_TYPE);
  43. return res.data;
  44. };
  45. export const getDateTimeScope = async () => {
  46. const res = await get(apis.DATE_TIME_SCOPE);
  47. return res.data;
  48. };
  49. // 后续如有创建相关需求可继续添加
  50. export const getMyCreateList = async (current: number, size: number, loading = false) => {
  51. const res = await post(apis.LIST_CREATE, { current, size }, { loading });
  52. return res.data;
  53. };
  54. export const createRoom = async (params: {
  55. description: string;
  56. inventoryIds: string[];
  57. luckTime: string;
  58. name: string;
  59. password?: string;
  60. participateMode?: number;
  61. }) => {
  62. console.log('Service: createRoom called', params);
  63. try {
  64. const res = await post(apis.CREATE, params, { loading: true });
  65. console.log('Service: createRoom response', res);
  66. return res;
  67. } catch (error) {
  68. console.error('Service: createRoom error', error);
  69. return { success: false, msg: '网络或未知错误' };
  70. }
  71. };
  72. export default {
  73. getWealList,
  74. getWealDetail,
  75. joinWealRoom,
  76. getWealRecord,
  77. getWinningRecord,
  78. getLuckNumList,
  79. getRoomTypePermission,
  80. getDateTimeScope,
  81. getMyCreateList,
  82. createRoom,
  83. };