weal.ts 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. // Wish APIs
  17. // Wish APIs (Substitute Goods)
  18. WISH_LIST: '/api/substituteGoods/list',
  19. WISH_PREVIEW: '/api/substituteOrder/preSubmit',
  20. WISH_SUBMIT: '/api/substituteOrder/submit',
  21. };
  22. export const getWealList = async (current: number, size: number, keyword?: string, type?: string, loading = false) => {
  23. const res = await post(apis.LIST, { current, size, keyword, type }, { loading });
  24. return res.data;
  25. };
  26. export const getWealDetail = async (roomId: string, loading = false) => {
  27. const res = await get(apis.DETAIL, { roomId }, { loading });
  28. return res.data;
  29. };
  30. export const joinWealRoom = async (roomId: string, password = '', shareId?: string) => {
  31. const res = await getL(apis.JOIN, { roomId, password, shareId });
  32. return res;
  33. };
  34. export const getWealRecord = async (current: number, size: number, loading = false) => {
  35. const res = await post(apis.RECORD, { current, size }, { loading });
  36. return res.data;
  37. };
  38. export const getWinningRecord = async (roomId: string) => {
  39. const res = await get(apis.WINNINGRECORD, { roomId });
  40. return res.data;
  41. };
  42. export const getLuckNumList = async (roomId: string) => {
  43. const res = await getL(`${apis.LUCKNUMLIST}?roomId=${roomId}`);
  44. return res.data;
  45. };
  46. export const getRoomTypePermission = async () => {
  47. const res = await getL(apis.ROOM_TYPE);
  48. return res.data;
  49. };
  50. export const getDateTimeScope = async () => {
  51. const res = await get(apis.DATE_TIME_SCOPE);
  52. return res.data;
  53. };
  54. // 后续如有创建相关需求可继续添加
  55. export const getMyCreateList = async (current: number, size: number, loading = false) => {
  56. const res = await post(apis.LIST_CREATE, { current, size }, { loading });
  57. return res.data;
  58. };
  59. export const createRoom = async (params: {
  60. description: string;
  61. inventoryIds: string[];
  62. luckTime: string;
  63. name: string;
  64. password?: string;
  65. participateMode?: number;
  66. }) => {
  67. console.log('Service: createRoom called', params);
  68. try {
  69. const res = await post(apis.CREATE, params, { loading: true });
  70. console.log('Service: createRoom response', res);
  71. return res;
  72. } catch (error) {
  73. console.error('Service: createRoom error', error);
  74. return { success: false, msg: '网络或未知错误' };
  75. }
  76. };
  77. export default {
  78. getWealList,
  79. getWealDetail,
  80. joinWealRoom,
  81. getWealRecord,
  82. getWinningRecord,
  83. getLuckNumList,
  84. getRoomTypePermission,
  85. getDateTimeScope,
  86. getMyCreateList,
  87. createRoom,
  88. // 扭蛋机相关 API
  89. catchDollDetail: async () => {
  90. const res = await get('/api/activity/dollMachine/detail');
  91. return res;
  92. },
  93. dollLottery: async (params: { quantity: number }) => {
  94. const res = await post('/api/activity/dollMachine/participate', params);
  95. return res;
  96. },
  97. prizeResult: async (params: { current: number; size: number }, loading = false) => {
  98. const res = await post('/api/activity/dollMachine/pageAllParticipate', params, { loading });
  99. return res.data;
  100. },
  101. // 祈愿相关 API (置换)
  102. getWishList: async () => {
  103. const res = await post(apis.WISH_LIST);
  104. return res.data;
  105. },
  106. wishPreview: async (params: { substituteGoodsId: string, inventoryIds: string[] }) => {
  107. const res = await post(apis.WISH_PREVIEW, params);
  108. return res.data;
  109. },
  110. wishSubmit: async (params: { substituteGoodsId: string, inventoryIds: string[] }) => {
  111. const res = await post(apis.WISH_SUBMIT, params);
  112. return res;
  113. }
  114. };