HomeApi.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. /// 上报类型1升级总部大楼,2升级房间等级,3购买明星
  61. static reportInformation(type, success, fail) {
  62. let url = '/information/report';
  63. let data = {
  64. 'type': type
  65. }
  66. Api.httpPost(this.setRequestBody(url, data, success, fail));
  67. }
  68. // //// 获取用户商品信息
  69. // static getUserShopData() {
  70. // let url = '/shop/getUserShops';
  71. // Api.httpGet(this.setRequestBody(url, {}, success, fail));
  72. // }
  73. // 生成一个 RequestBody, 总是要写重复代码, 太恶心了
  74. static setRequestBody(url, data, success, fail) {
  75. let requestBody = {
  76. url: url,
  77. data: data,
  78. success: success,
  79. fail: fail,
  80. complete: () => {
  81. }
  82. };
  83. return requestBody;
  84. }
  85. }
  86. module.exports = HomeApi;