1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- const Api = require('../net/Api');
- class DrawApi {
- /**
- * 开始抽奖
- * @param typeId [long] 1 为第一个抽奖 2 为第二个抽奖 3 为第三个抽奖
- * @param isDiamond [int] 是否为钻石抽奖。1是0不 (只有第一个抽奖需要)
- */
- static startLottery(typeId, isDiamond = 0, success, fail) {
- let url = "/lottery/startLottery";
-
- let data = {type: typeId};
- if (typeId == 1) {
- data.isDiamond = isDiamond;
- } else {
- data.isDiamond = 1;
- }
- console.log(data);
- Api.httpPost(this.setRequestBody(url, data, success, fail));
- }
- /**
- * 开始抽奖 V1.1.0之后开始使用
- * @param typeId [long] 1 为第一个抽奖 2 为第二个抽奖 3 为第三个抽奖
- * @param isDiamond [int] 是否为钻石抽奖。1是0不 (只有第一个抽奖需要)
- */
- static startNewLottery(typeId, isDiamond = 0, success, fail) {
- let url = "/lottery/startLottery1";
-
- let data = {type: typeId};
- if (typeId == 1) {
- data.isDiamond = isDiamond;
- } else {
- data.isDiamond = 1;
- }
- console.log(data);
- Api.httpPost(this.setRequestBody(url, data, success, fail));
- }
-
- /// /user/getHbs 获取抽奖红包数据
- static getDrawHbs(success, fail) {
- let url = "/user/getHbs";
- Api.httpGet(this.setRequestBody(url, {}, success, fail));
- }
- /**
- * 获取抽奖相关信息
- */
- static getLotteryInfo(success, fail) {
- let url = "/lottery/getLotteryInfo.do";
- Api.httpGet(this.setRequestBody(url, {}, success, fail));
- }
- // 生成一个 RequestBody, 总是要写重复代码, 太恶心了
- static setRequestBody(url, data, success, fail) {
- let requestBody = {
- url: url,
- data: data,
- success: success,
- fail: fail,
- complete: () => {
- }
- };
- return requestBody;
- }
- }
- module.exports = DrawApi;
|