HomeApi.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. const Api = require('./Api');
  2. class HomeApi {
  3. /**
  4. * 获取我的小程序礼包
  5. */
  6. static getUserBuildings(success, fail) {
  7. let url = "/room/getAllRooms.do";
  8. Api.httpGet(this.setRequestBody(url, {}, success, fail));
  9. }
  10. /**
  11. * 上报接口
  12. * @param {*} reportFormInfo {"grossIncome":1000,"grossRate":10000,"stars":1}
  13. * @param {*} success
  14. * @param {*} fail
  15. */
  16. static userReportGross(reportFormInfo, success, fail) {
  17. let url = "/room/reportGold.do";
  18. let data = {
  19. reportFormInfo: reportFormInfo,
  20. };
  21. Api.httpPost(this.setRequestBody(url, data, success, fail));
  22. }
  23. //上报楼层等级接口
  24. static userReportRooms(reportFormInfo, success, fail) {
  25. let url = "/room/reportRooms.do";
  26. let data = {
  27. reportFormInfo: reportFormInfo,
  28. };
  29. Api.httpPost(this.setRequestBody(url, data, success, fail));
  30. }
  31. /**
  32. * 举报艺人
  33. * @param {*} formmInfoJson
  34. * @param {*} success
  35. * @param {*} fail
  36. */
  37. static getAppletAward(success, fail) {
  38. let url = "/user/appletAward.do";
  39. Api.httpGet(this.setRequestBody(url, {}, success, fail));
  40. }
  41. //领取房间里程碑奖励
  42. static getRoomAward(roomId, level, success, fail) {
  43. let url = "/room/award.do";
  44. let data = {
  45. roomId: roomId,
  46. level: level
  47. };
  48. Api.httpPost(this.setRequestBody(url, data, success, fail));
  49. }
  50. // 退出游戏
  51. static exitGame(success, fail) {
  52. let url = "/user/exitGame.do";
  53. Api.httpGet(this.setRequestBody(url, {}, success, fail));
  54. }
  55. static getInformation(success, fail) {
  56. let url = '/information/getInformation';
  57. Api.httpGet(this.setRequestBody(url, {}, success, fail));
  58. }
  59. // //// 获取用户商品信息
  60. // static getUserShopData() {
  61. // let url = '/shop/getUserShops';
  62. // Api.httpGet(this.setRequestBody(url, {}, success, fail));
  63. // }
  64. // 生成一个 RequestBody, 总是要写重复代码, 太恶心了
  65. static setRequestBody(url, data, success, fail) {
  66. let requestBody = {
  67. url: url,
  68. data: data,
  69. success: success,
  70. fail: fail,
  71. complete: () => {
  72. }
  73. };
  74. return requestBody;
  75. }
  76. }
  77. module.exports = HomeApi;