dimension.ts 4.1 KB

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