HomeApi.js 5.7 KB

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