DrawApi.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. const Api = require('../net/Api');
  2. class DrawApi {
  3. /**
  4. * 开始抽奖
  5. * @param typeId [long] 1 为第一个抽奖 2 为第二个抽奖 3 为第三个抽奖
  6. * @param isDiamond [int] 是否为钻石抽奖。1是0不 (只有第一个抽奖需要)
  7. */
  8. static startLottery(typeId, isDiamond = 0, success, fail) {
  9. let url = "/lottery/startLottery";
  10. let data = {type: typeId};
  11. if (typeId == 1) {
  12. data.isDiamond = isDiamond;
  13. } else {
  14. data.isDiamond = 1;
  15. }
  16. console.log(data);
  17. Api.httpPost(this.setRequestBody(url, data, success, fail));
  18. }
  19. /**
  20. * 获取抽奖相关信息
  21. */
  22. static getLotteryInfo(success, fail) {
  23. let url = "/lottery/getLotteryInfo.do";
  24. Api.httpGet(this.setRequestBody(url, {}, success, fail));
  25. }
  26. // 生成一个 RequestBody, 总是要写重复代码, 太恶心了
  27. static setRequestBody(url, data, success, fail) {
  28. let requestBody = {
  29. url: url,
  30. data: data,
  31. success: success,
  32. fail: fail,
  33. complete: () => {
  34. }
  35. };
  36. return requestBody;
  37. }
  38. }
  39. module.exports = DrawApi;