SkillApi.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. static resetSkill1(success, fail) {
  46. let url = '/skill/resetSkill1';
  47. Api.httpGet(this.setRequestBody(url, {}, success, fail));
  48. }
  49. /**
  50. * 上报数据
  51. * type 1看广告,2是分享,3是领取里程碑
  52. *
  53. */
  54. static report(type, success, fail) {
  55. let url = "/statistic/report";
  56. let body = {
  57. "type": type
  58. };
  59. Api.httpGet(this.setRequestBody(url, body, success, fail));
  60. }
  61. static setRequestBody(url, data, success, fail) {
  62. let requestBody = {
  63. url: url,
  64. data: data,
  65. success: success,
  66. fail: fail,
  67. complete: () => {
  68. }
  69. };
  70. return requestBody;
  71. }
  72. }
  73. module.exports = SkillApi;