Commit 524b14e4 authored by 劳工's avatar 劳工

Merge branch 'feature/190412-mock' into 'master'

(feat) net 基础请求

See merge request !1
parents 33c0229d ad075289
......@@ -7,5 +7,6 @@ export * from './base';
export * from './other';
export * from './renderer';
export * from './ui';
export * from './net';
export * from './registerAllComponents'
\ No newline at end of file
......@@ -12,7 +12,7 @@ export default class SampleApi extends ApiComponent {
name: string;
uri: string;
method: string = 'POST';
params: any;
params: any = {};
ignoreSuccessField: boolean = false;
async callApi(name, paramsInput, ...args){
......@@ -38,6 +38,7 @@ export default class SampleApi extends ApiComponent {
const {uri, method} = this;
try {
const response = await callApi(uri, params, method, 'json', this.ignoreSuccessField);
......
......@@ -14,7 +14,7 @@ export default class SamplePollingApi extends ApiComponent {
successValues: any[];
uri: string;
method: string = 'GET';
params: any;
params: any = {};
maxTimes: number = 5;
delay: number = 500;
......
import { utils } from "scilla";
import SampleApi from "../../../SampleApi";
/**
* 获取渲染数据
*/
export default class AjaxElementComponent extends SampleApi {
//唯一标识
name: string = 'ajaxElement';
//访问路径
uri: string = '/hdtool/recon/ajaxElement';
//请求方式
method: string = 'GET';
//duiba活动ID
duibaId: string;
//入库活动ID
activityId: string;
protected async execute() {
utils.injectProp(this.params, { duibaId: this.duibaId, activityId: this.activityId });
super.execute();
}
}
\ No newline at end of file
import { utils } from "scilla";
import SampleApi from "../../../SampleApi";
/**
* 获取渲染数据
*/
export default class DoJoinComponent extends SampleApi {
//唯一标识
name: string = 'doJoin';
//访问路径
uri: string = '/hdtool/recon/doJoin';
//请求方式
method: string = 'GET';
//入库活动ID
activityId: string;
//token
token: string;
//再来一次订单ID
againOrderId: string;
//活动类型
activityType: string;
//用户ID
consumerId: string;
//积分
credits: number;
//分数 分段发奖
score: number;
protected async execute() {
utils.injectProp(this.params, {
activityId: this.activityId, token: this.token, againOrderId: this.againOrderId,
activityType: this.activityType, consumerId: this.consumerId, credits: this.credits, score: this.score
});
super.execute();
}
}
\ No newline at end of file
import { utils } from "scilla";
import SampleApi from "../../../SampleApi";
/**
* 查询订单状态
*/
export default class GetOrderStatusComponent extends SampleApi {
//唯一标识
name: string = 'getOrderStatus';
//访问路径
uri: string = '/hdtool/recon/getOrderStatus';
//请求方式
method: string = 'POST';
//订单ID
orderId: string;
protected async execute() {
utils.injectProp(this.params, { orderId: this.orderId });
super.execute();
}
}
\ No newline at end of file
import { utils } from "scilla";
import SampleApi from "../../../SampleApi";
/**
* 查询奖品信息
*/
export default class PrizeDetailComponent extends SampleApi {
//唯一标识
name: string = 'prizeDetail';
//访问路径
uri: string = '/hdtool/recon/prizeDetail';
//请求方式
method: string = 'GET';
//
appItemId: string;
//
itemId: string;
//
appId: string;
protected async execute() {
utils.injectProp(this.params, { appItemId: this.appItemId, itemId: this.itemId, appId: this.appId });
super.execute();
}
}
import { utils } from "scilla";
import SamplePollingApi from "../../../SamplePollingApi";
export default class SubCreditsStatusComponent extends SamplePollingApi {
//唯一标识
name: string = 'subCreditsStatus';
//访问路径
uri: string = '/hdtool/recon/subCreditsStatus';
//请求方式
method: string = 'POST';
//订单ID
orderId: string;
protected async execute() {
utils.injectProp(this.params, { orderId: this.orderId });
super.execute();
}
}
\ No newline at end of file
import { utils } from "scilla";
import SampleApi from "../../../SampleApi";
export default class DatapashComponent extends SampleApi {
//唯一标识
name: string = 'datapash';
//访问路径
uri: string = '/hdtool/recon/ngame/datapash';
//请求方式
method: string = 'POST';
//订单ID
orderId: string;
//防作弊数据
dynamicData: any;
//duiba活动ID
duibaId: any;
protected async execute() {
utils.injectProp(this.params, { orderId: this.orderId, duibaId: this.duibaId, dynamicData: this.dynamicData });
super.execute();
}
}
\ No newline at end of file
import { utils } from "scilla";
import SamplePollingApi from "../../../SamplePollingApi";
/**
* 查询游戏开始订单状态
*/
export default class GetNgameStartStatusComponent extends SamplePollingApi {
//唯一标识
name: string = 'getNgameStartStatus';
//访问路径
uri: string = '/hdtool/recon/ngame/getNgameStartStatus';
//请求方式
method: string = 'POST';
//订单ID
orderId: string;
protected async execute() {
utils.injectProp(this.params, { orderId: this.orderId });
super.execute();
}
}
\ No newline at end of file
import { utils } from "scilla";
import SampleApi from "../../../SampleApi";
/**
* 游戏提交成绩接口
*/
export default class NgameManySubmitComponent extends SampleApi {
//唯一标识
name: string = 'ngameManySubmit';
//访问路径
uri: string = '/hdtool/recon/ngame/ngameManySubmit';
//请求方式
method: string = 'POST';
//订单ID
orderId: string;
//分数
score: string;
//无用
gameData: any;
//签名
sgin: string;
//防作弊数据
dynamicData: any;
protected async execute() {
utils.injectProp(this.params, {
orderId: this.orderId, score: this.score, gameData: this.gameData, sgin: this.sgin,
dynamicData: this.dynamicData
});
super.execute();
}
}
\ No newline at end of file
import { utils } from "scilla";
import SampleApi from "../../../SampleApi";
/**
* 游戏提交成绩接口
*/
export default class NgameSubmitComponent extends SampleApi {
//唯一标识
name: string = 'ngameSubmit';
//访问路径
uri: string = '/hdtool/recon/ngame/ngameSubmit';
//请求方式
method: string = 'POST';
//订单ID
orderId: string;
//分数
score: string;
//无用
gameData: any;
//签名
sgin: string;
//防作弊数据
dynamicData: any;
protected async execute() {
utils.injectProp(this.params, {
orderId: this.orderId, score: this.score, gameData: this.gameData, sgin: this.sgin,
dynamicData: this.dynamicData
});
super.execute();
}
}
\ No newline at end of file
import { utils } from "scilla";
import SampleApi from "../../../SampleApi";
/**
* 游戏复活接口
*/
export default class ResurrectionComponent extends SampleApi {
//唯一标识
name: string = 'resurrection';
//访问路径
uri: string = '/hdtool/recon/ngame/resurrection';
//请求方式
method: string = 'POST';
//订单ID
orderId: string;
protected async execute() {
utils.injectProp(this.params, { orderId: this.orderId });
super.execute();
}
}
\ No newline at end of file
import { utils } from "scilla";
import SamplePollingApi from "../../../SamplePollingApi";
/**
* 查询复活状态
*/
export default class ResurrectionStatusComponent extends SamplePollingApi {
//唯一标识
name: string = 'resurrectionStatus';
//访问路径
uri: string = '/hdtool/recon/ngame/resurrectionStatus';
//请求方式
method: string = 'POST';
//doJoin订单ID
orderId: string;
//resurrec订单ID
resurrecOrderId: string;
protected async execute() {
utils.injectProp(this.params, { orderId: this.orderId, resurrecOrderId: this.resurrecOrderId });
super.execute();
}
}
\ No newline at end of file
import { utils } from "scilla";
import SamplePollingApi from "../../../SamplePollingApi";
/**
* 查询前置开奖结果
*/
export default class GetGameOrderInfoComponent extends SamplePollingApi {
//唯一标识
name: string = 'getGameOrderInfo';
//访问路径
uri: string = '/hdtool/recon/getGameOrderInfo';
//请求方式
method: string = 'POST';
//订单ID
orderId: string;
protected async execute() {
utils.injectProp(this.params, { orderId: this.orderId });
super.execute();
}
}
\ No newline at end of file
import { utils } from "scilla";
import SampleApi from "../../../SampleApi";
/**
* 前置开奖提交成绩接口
*/
export default class GetGameSubmitComponent extends SampleApi {
//唯一标识
name: string = 'getGameSubmit';
//访问路径
uri: string = '/hdtool/recon/getGameSubmit';
//请求方式
method: string = 'POST';
//订单ID
orderId: string;
//价值
facePrice: number;
protected async execute() {
utils.injectProp(this.params, { orderId: this.orderId, facePrice: this.facePrice });
super.execute();
}
}
\ No newline at end of file
import { utils } from "scilla";
import SampleApi from "../../../SampleApi";
/**
* 检查题目答案是否正确
*/
export default class CheckOutAnswerComponent extends SampleApi {
//唯一标识
name: string = 'checkOutAnswer';
//访问路径
uri: string = '/hdtool/recon/checkOutAnswer';
//请求方式
method: string = 'GET';
//订单ID
orderId: string;
//答案
answerData: string;
protected async execute() {
utils.injectProp(this.params, { orderId: this.orderId, answerData: this.answerData });
super.execute();
}
}
\ No newline at end of file
import { utils } from "scilla";
import SampleApi from "../../../SampleApi";
/**
* 获取题目数据
*/
export default class GetQuestionComponent extends SampleApi {
//唯一标识
name: string = 'getQuestionInfo';
//访问路径
uri: string = '/recon/getQuestionInfo';
//请求方式
method: string = 'GET';
//入库活动ID
activityId: string;
protected async execute() {
utils.injectProp(this.params, { activityId: this.activityId });
super.execute();
}
}
\ No newline at end of file
import { utils } from "scilla";
import SampleApi from "../../../SampleApi";
/**
* 获取题目数据
*/
export default class QuestionSubmitComponent extends SampleApi {
//唯一标识
name: string = 'questionSubmit';
//访问路径
uri: string = '/hdtool/recon/questionSubmit';
//请求方式
method: string = 'POST';
//doJoin订单ID
orderId: string;
//答案
answerData: string;
protected async execute() {
utils.injectProp(this.params, { orderId: this.orderId, answerData: this.answerData });
super.execute();
}
}
\ No newline at end of file
import { utils } from "scilla";
import SampleApi from "../../../SampleApi";
/**
* 获取渲染数据
*/
export default class AjaxThroughInfoComponent extends SampleApi {
//唯一标识
name: string = 'ajaxThroughInfo';
//访问路径
uri: string = '/hdtool/recon/ajaxThroughInfo';
//请求方式
method: string = 'GET';
//duiba活动ID
duibaId: string;
//关卡ID
throughId: string;
protected async execute() {
utils.injectProp(this.params, { duibaId: this.duibaId, throughId: this.throughId });
super.execute();
}
}
\ No newline at end of file
import { utils } from "scilla";
import SampleApi from "../../../SampleApi";
/**
* 获取渲染数据
*/
export default class ThroughSubmitComponent extends SampleApi {
//唯一标识
name: string = 'throughSubmit';
//访问路径
uri: string = '/hdtool/recon/throughSubmit';
//请求方式
method: string = 'GET';
//duiba活动ID
orderId: string;
protected async execute() {
utils.injectProp(this.params, { orderId: this.orderId });
super.execute();
}
}
\ No newline at end of file
export { enjectBaseUrl } from './webService'
export { default as SampleApi } from './SampleApi'
\ No newline at end of file
......@@ -5,6 +5,9 @@
import {utils} from "scilla";
// 请求路径 root
let baseUrl: string;
/**
* 调用接口
* @param uri
......@@ -24,9 +27,9 @@ export function callApi(uri: string, params: any = null, method: string = 'post'
method,
};
//if (!GameConfig.debug) {
if (!baseUrl) {
options.credentials = 'include';
//}
}
let temp = typeof params === 'string' ? params : utils.objectStringify(params);
switch (method.toUpperCase()) {
......@@ -45,6 +48,8 @@ export function callApi(uri: string, params: any = null, method: string = 'post'
const fetchMethod = responseType == 'jsonp' ? window['fetchJsonp'] : fetch;
url = baseUrl ? baseUrl + url : url
return fetchMethod(url, options)
.then((response) => {
if (response.type === 'opaque') {
......@@ -177,3 +182,10 @@ export function createSgin(ticketId: number, score: number, gameData: any, submi
return window['duiba_md5'](ticketId + '' + score + '' + gameData + '' + submitToken);
}
/**
* @desc 请求root补全
* @param {string} u
*/
export function enjectBaseUrl(u) {
baseUrl = u;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment