dimension.ts 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. import { get, getL, post, postL } 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. // 获取审核记录列表
  100. export const roomAuditRecord = async (
  101. current: number,
  102. size: number,
  103. roomId: string,
  104. auditStatus: number,
  105. ) => {
  106. const res = await post(apis.ROOM_AUDIT_RECORD, {
  107. current,
  108. size,
  109. roomId,
  110. auditStatus,
  111. });
  112. return res.data;
  113. };
  114. // 审核通过
  115. export const roomAuditPass = async (id: string) => {
  116. const res = await postL(apis.ROOM_AUDIT_PASS, { id });
  117. return res.success;
  118. };
  119. // 审核拒绝
  120. export const roomAuditUnpass = async (id: string) => {
  121. const res = await postL(apis.ROOM_AUDIT_UNPASS, { id });
  122. return res.success;
  123. };
  124. export default {
  125. getWealList,
  126. getWealDetail,
  127. joinWealRoom,
  128. getWealRecord,
  129. getWinningRecord,
  130. getLuckNumList,
  131. getRoomTypePermission,
  132. getDateTimeScope,
  133. getMyCreateList,
  134. createRoom,
  135. roomAuditRecord,
  136. roomAuditPass,
  137. roomAuditUnpass,
  138. // 扭蛋机相关 API
  139. catchDollDetail: async () => {
  140. const res = await get("/api/activity/dollMachine/detail");
  141. return res;
  142. },
  143. dollLottery: async (params: { quantity: number }) => {
  144. const res = await post("/api/activity/dollMachine/participate", params);
  145. return res;
  146. },
  147. prizeResult: async (
  148. params: { current: number; size: number },
  149. loading = false,
  150. ) => {
  151. const res = await post(
  152. "/api/activity/dollMachine/pageAllParticipate",
  153. params,
  154. { loading },
  155. );
  156. return res.data;
  157. },
  158. // 祈愿相关 API (置换)
  159. getWishList: async () => {
  160. const res = await post(apis.WISH_LIST);
  161. return res.data;
  162. },
  163. wishPreview: async (params: {
  164. substituteGoodsId: string;
  165. inventoryIds: string[];
  166. }) => {
  167. const res = await post(apis.WISH_PREVIEW, params);
  168. return res.data;
  169. },
  170. wishSubmit: async (params: {
  171. substituteGoodsId: string;
  172. inventoryIds: string[];
  173. }) => {
  174. const res = await post(apis.WISH_SUBMIT, params);
  175. return res;
  176. },
  177. };