SkillApi.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. const Api = require('../net/Api');
  2. class SkillApi {
  3. /**
  4. * 获取所有技能信息
  5. */
  6. static getAllSkills(success, fail) {
  7. let url = "/skill/getAllSkills";
  8. Api.httpGet(this.setRequestBody(url, {}, success, fail));
  9. }
  10. /// 根据skillId 购买技能 就最后三个技能需要购买
  11. static buySkill(skillId, success, fail) {
  12. let url = "/skill/buySkill";
  13. Api.httpPost(this.setRequestBody(url, {"skillId": skillId}, success, fail));
  14. }
  15. //// 升级楼层
  16. static upBuildingLevel(upLevel, success, fail) {
  17. let url = "/user/upBuildingLevel";
  18. Api.httpPost(this.setRequestBody(url, {'level': upLevel}, success, fail));
  19. }
  20. /**
  21. * 升级某个技能
  22. * skillId 技能id
  23. * level 当前技能等级
  24. */
  25. static upSkill(skillId, success, fail) {
  26. let url = "/skill/upSkill";
  27. let body = {
  28. "skillId" : skillId,
  29. };
  30. Api.httpPost(this.setRequestBody(url, body, success, fail));
  31. }
  32. /// 使用某个技能
  33. static useSkill(skillId, success, fail) {
  34. let url = "/skill/useSkill";
  35. let body = {
  36. "skillId": skillId,
  37. };
  38. Api.httpPost(this.setRequestBody(url, body, success, fail));
  39. }
  40. /// 重置技能
  41. static resetSkill(success, fail) {
  42. let url = "/skill/resetSkill";
  43. Api.httpGet(this.setRequestBody(url, {}, success, fail));
  44. }
  45. /**
  46. * 上报数据
  47. * type 1看广告,2是分享,3是领取里程碑
  48. *
  49. */
  50. static report(type, success, fail) {
  51. let url = "/statistic/report";
  52. let body = {
  53. "type": type
  54. };
  55. Api.httpGet(this.setRequestBody(url, body, success, fail));
  56. }
  57. static setRequestBody(url, data, success, fail) {
  58. let requestBody = {
  59. url: url,
  60. data: data,
  61. success: success,
  62. fail: fail,
  63. complete: () => {
  64. }
  65. };
  66. return requestBody;
  67. }
  68. }
  69. module.exports = SkillApi;