HomeApi.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. *
  70. * 获取每日时间段奖励状态
  71. * @static
  72. * @param {*} success
  73. * @param {*} fail
  74. * @memberof HomeApi
  75. */
  76. static getReward(success, fail) {
  77. let url = '/user/getReward';
  78. Api.httpGet(this.setRequestBody(url, {}, success, fail));
  79. }
  80. /**
  81. *
  82. * 领取每日时间段奖励
  83. * @static
  84. * @param {*} success
  85. * @param {*} fail
  86. * @memberof HomeApi
  87. */
  88. static reward(success, fail) {
  89. let url = '/user/reward';
  90. Api.httpGet(this.setRequestBody(url, {}, success, fail));
  91. }
  92. // //// 获取用户商品信息
  93. // static getUserShopData() {
  94. // let url = '/shop/getUserShops';
  95. // Api.httpGet(this.setRequestBody(url, {}, success, fail));
  96. // }
  97. // 生成一个 RequestBody, 总是要写重复代码, 太恶心了
  98. static setRequestBody(url, data, success, fail) {
  99. let requestBody = {
  100. url: url,
  101. data: data,
  102. success: success,
  103. fail: fail,
  104. complete: () => {
  105. }
  106. };
  107. return requestBody;
  108. }
  109. }
  110. module.exports = HomeApi;