HomeApi.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. const Api = require('./Api');
  2. class HomeApi {
  3. /**
  4. * 获取目标用户的建筑
  5. * @param targetUid [long] 目标用户,当前用户就传自己的uid 的值
  6. * @param cityId [long] 城市 id
  7. */
  8. static getUserBuildings(success, fail) {
  9. let url = "/room/getAllRooms.do";
  10. Api.httpGet(this.setRequestBody(url, {}, success, fail));
  11. }
  12. /**
  13. * 升级建筑
  14. * @param buildingId [int] 建筑Id
  15. * @param cityId [int] 城市id
  16. * @param grossIncome [int] 当前总金币数
  17. * @param grossRate [int] 自动收入金额
  18. * @param level [int] 建筑等级
  19. * @param stars [int] 星星数
  20. *
  21. * */
  22. static buildingUpGrade(formmInfoJson, success, fail) {
  23. let url = "/building/upGrade.do";
  24. let data = {
  25. formInfo: formmInfoJson,
  26. };
  27. Api.httpPost(this.setRequestBody(url, data, success, fail));
  28. }
  29. /**
  30. * 获取首页好友列表
  31. * */
  32. static getFriends(success, fail) {
  33. let url = "/friend/getIndexList.do";
  34. Api.httpGet(this.setRequestBody(url, {}, success, fail));
  35. }
  36. /**
  37. * 主界面艺人管理列表
  38. */
  39. static getFriendManageList(success, fail) {
  40. let url = "/friend/getManageList.do";
  41. Api.httpGet(this.setRequestBody(url, {}, success, fail));
  42. }
  43. /**
  44. * 上报接口
  45. * @param {*} reportFormInfo {"grossIncome":1000,"grossRate":10000,"stars":1}
  46. * @param {*} success
  47. * @param {*} fail
  48. */
  49. static userReportGross(reportFormInfo, success, fail) {
  50. let url = "/room/reportGold.do";
  51. let data = {
  52. reportFormInfo: reportFormInfo,
  53. };
  54. Api.httpPost(this.setRequestBody(url, data, success, fail));
  55. }
  56. /**
  57. * 获取好友艺人列表
  58. * @param {int} fid 好友uid
  59. * @param {*} success
  60. * @param {*} fail
  61. */
  62. static friendGetArtists(fid, success, fail) {
  63. let url = "/friend/getArtists.do";
  64. let data = {
  65. fid: fid,
  66. };
  67. Api.httpGet(this.setRequestBody(url, data, success, fail));
  68. }
  69. /**
  70. * 获取好友艺人列表
  71. * @param {int} buildingId 建筑对应的 buildingId
  72. * @param {*} success
  73. * @param {*} fail
  74. */
  75. static friendGetArtistsByBuildingId(targetUid, buildingId, success, fail) {
  76. let url = "/friend/station/getArtists.do";
  77. let data = {
  78. targetUid: targetUid,
  79. buildingId: buildingId,
  80. };
  81. Api.httpGet(this.setRequestBody(url, data, success, fail));
  82. }
  83. /**
  84. * 艺人入驻
  85. * @param {*} formmInfoJson
  86. * @param {*} success
  87. * @param {*} fail
  88. */
  89. static friendStation(formmInfoJson, success, fail) {
  90. let url = "/friend/station.do";
  91. let data = {
  92. form: formmInfoJson,
  93. };
  94. Api.httpPost(this.setRequestBody(url, data, success, fail));
  95. }
  96. /**
  97. * 艺人的驱赶召回
  98. * @param {*} formmInfoJson
  99. * @param {*} success
  100. * @param {*} fail
  101. */
  102. static friendExpelRecall(artistUid, success, fail) {
  103. let url = "/friend/expelRecall.do";
  104. let data = {
  105. artistUid: artistUid,
  106. };
  107. Api.httpPost(this.setRequestBody(url, data, success, fail));
  108. }
  109. /**
  110. * 获取用户对应建筑入驻的艺人列表
  111. * @param {*} targetUid 目标用户(是谁的家园,目标用户就是谁)
  112. * @param {*} buildingId 建筑id
  113. * @param {*} success
  114. * @param {*} fail
  115. */
  116. static friendGetArtistsInBuilding(targetUid, buildingId, success, fail) {
  117. let url = "/friend/getArtistsInBuilding.do";
  118. let data = {
  119. targetUid: targetUid,
  120. buildingId: buildingId
  121. };
  122. Api.httpGet(this.setRequestBody(url, data, success, fail));
  123. }
  124. /**
  125. * 入驻艺人收益
  126. * @param {*} formmInfoJson
  127. * @param {*} success
  128. * @param {*} fail
  129. */
  130. static friendGetBenefit(artistUid, success, fail) {
  131. let url = "/friend/getBenefit.do";
  132. let data = {
  133. artistUid: artistUid,
  134. };
  135. Api.httpPost(this.setRequestBody(url, data, success, fail));
  136. }
  137. /**
  138. * 举报艺人
  139. * @param {*} formmInfoJson
  140. * @param {*} success
  141. * @param {*} fail
  142. */
  143. static friendReportArtist(artistUid, success, fail) {
  144. let url = "/friend/reportArtist.do";
  145. let data = {
  146. artistUid: artistUid,
  147. };
  148. Api.httpPost(this.setRequestBody(url, data, success, fail));
  149. }
  150. //领取房间里程碑奖励
  151. static getRoomAward(roomId, success, fail) {
  152. let url = "/room/award.do";
  153. let data = {
  154. roomId: roomId,
  155. };
  156. Api.httpPost(this.setRequestBody(url, data, success, fail));
  157. }
  158. // 退出游戏
  159. static exitGame(success, fail) {
  160. let url = "/user/exitGame.do";
  161. Api.httpGet(this.setRequestBody(url, {}, success, fail));
  162. }
  163. static getInformation(success, fail) {
  164. let url = '/information/getInformation';
  165. Api.httpGet(this.setRequestBody(url, {}, success, fail));
  166. }
  167. // //// 获取用户商品信息
  168. // static getUserShopData() {
  169. // let url = '/shop/getUserShops';
  170. // Api.httpGet(this.setRequestBody(url, {}, success, fail));
  171. // }
  172. // 生成一个 RequestBody, 总是要写重复代码, 太恶心了
  173. static setRequestBody(url, data, success, fail) {
  174. let requestBody = {
  175. url: url,
  176. data: data,
  177. success: success,
  178. fail: fail,
  179. complete: () => {
  180. }
  181. };
  182. return requestBody;
  183. }
  184. }
  185. module.exports = HomeApi;