Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scilla-components
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
劳工
scilla-components
Commits
ff28e792
Commit
ff28e792
authored
Apr 23, 2019
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
迁移业务逻辑相关组件到duiba-components库
parent
5cd6c17c
Changes
24
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
1 addition
and
816 deletions
+1
-816
generateAllComponents.js
generateAllComponents.js
+1
-1
ApiComponent.ts
src/net/ApiComponent.ts
+0
-56
SampleApi.ts
src/net/SampleApi.ts
+0
-53
SamplePollingApi.ts
src/net/SamplePollingApi.ts
+0
-60
AjaxElementComponent.ts
src/net/api/hdtool/base/AjaxElementComponent.ts
+0
-22
DoJoinComponent.ts
src/net/api/hdtool/base/DoJoinComponent.ts
+0
-35
GetOrderStatusComponent.ts
src/net/api/hdtool/base/GetOrderStatusComponent.ts
+0
-20
PrizeDetailComponent.ts
src/net/api/hdtool/base/PrizeDetailComponent.ts
+0
-26
SubCreditsStatusComponent.ts
src/net/api/hdtool/base/SubCreditsStatusComponent.ts
+0
-18
DatapashComponent.ts
src/net/api/hdtool/game/DatapashComponent.ts
+0
-22
GetNgameStartStatusComponent.ts
src/net/api/hdtool/game/GetNgameStartStatusComponent.ts
+0
-20
NgameManySubmitComponent.ts
src/net/api/hdtool/game/NgameManySubmitComponent.ts
+0
-31
NgameSubmitComponent.ts
src/net/api/hdtool/game/NgameSubmitComponent.ts
+0
-31
ResurrectionComponent.ts
src/net/api/hdtool/game/ResurrectionComponent.ts
+0
-20
ResurrectionStatusComponent.ts
src/net/api/hdtool/game/ResurrectionStatusComponent.ts
+0
-22
GetGameOrderInfoComponent.ts
src/net/api/hdtool/preLottery/GetGameOrderInfoComponent.ts
+0
-20
GetGameSubmitComponent.ts
src/net/api/hdtool/preLottery/GetGameSubmitComponent.ts
+0
-22
CheckOutAnswerComponent.ts
src/net/api/hdtool/question/CheckOutAnswerComponent.ts
+0
-22
GetQuestionComponent.ts
src/net/api/hdtool/question/GetQuestionComponent.ts
+0
-20
QuestionSubmitComponent.ts
src/net/api/hdtool/question/QuestionSubmitComponent.ts
+0
-22
AjaxThroughInfoComponent.ts
src/net/api/hdtool/throughGame/AjaxThroughInfoComponent.ts
+0
-22
ThroughSubmitComponent.ts
src/net/api/hdtool/throughGame/ThroughSubmitComponent.ts
+0
-20
webService.ts
src/net/webService.ts
+0
-187
registerAllComponents.ts
src/registerAllComponents.ts
+0
-44
No files found.
generateAllComponents.js
View file @
ff28e792
...
...
@@ -7,7 +7,7 @@ const fs = require('fs');
let
files
=
glob
.
sync
(
'src/**/!(index|registerAllComponents).ts'
);
let
fileContent
=
`import {registerDef} from "scilla
-core
"
let
fileContent
=
`import {registerDef} from "scilla"
`
;
...
...
src/net/ApiComponent.ts
deleted
100644 → 0
View file @
5cd6c17c
/**
* Created by rockyl on 2018-12-16.
*
* Api接口组件基类
*/
import
{
ScillaEvent
}
from
"scilla"
;
import
ScillaComponent
from
"../base/ScillaComponent"
;
export
default
class
ApiComponent
extends
ScillaComponent
{
onResponse
:
ScillaEvent
=
new
ScillaEvent
();
onError
:
ScillaEvent
=
new
ScillaEvent
();
onFinish
:
ScillaEvent
=
new
ScillaEvent
();
autoCall
:
boolean
=
false
;
private
_args
;
onAwake
()
{
super
.
onAwake
();
if
(
this
.
autoCall
){
this
.
execute
();
}
}
protected
async
execute
(
paramsInput
?,
...
args
)
{
this
.
_args
=
args
;
}
onGotResponse
(
response
:
any
)
{
if
(
this
.
_args
&&
this
.
_args
.
length
>
0
){
this
.
onResponse
.
invoke
(
response
,
...
this
.
_args
);
}
else
{
this
.
onResponse
.
invoke
(
response
);
}
this
.
onCallFinish
();
}
onGotError
(
e
)
{
if
(
this
.
_args
&&
this
.
_args
.
length
>
0
){
this
.
onError
.
invoke
(
e
,
...
this
.
_args
);
}
else
{
this
.
onError
.
invoke
(
e
);
}
this
.
onCallFinish
();
}
onCallFinish
(){
if
(
this
.
_args
&&
this
.
_args
.
length
>
0
){
this
.
onFinish
.
invoke
(...
this
.
_args
);
}
else
{
this
.
onFinish
.
invoke
();
}
}
}
src/net/SampleApi.ts
deleted
100644 → 0
View file @
5cd6c17c
/**
* Created by hwj on 2018/12/1.
*
* 简单的api组件
*/
import
{
utils
,
dynamic
}
from
'scilla'
import
ApiComponent
from
"./ApiComponent"
;
import
{
callApi
}
from
"./webService"
;
export
default
class
SampleApi
extends
ApiComponent
{
ignoreSuccessField
:
boolean
=
false
;
name
:
string
;
uri
:
string
;
method
:
string
=
'POST'
;
params
:
dynamic
;
async
callApi
(
name
,
paramsInput
,
...
args
){
if
(
this
.
name
==
name
){
await
this
.
execute
(
paramsInput
,
...
args
);
}
}
protected
async
execute
(
paramsInput
?,
...
args
)
{
await
super
.
execute
(
paramsInput
,
...
args
);
const
params
=
{
};
if
(
this
.
params
){
utils
.
injectProp
(
params
,
this
.
params
);
}
if
(
paramsInput
){
utils
.
injectProp
(
params
,
paramsInput
);
}
const
{
uri
,
method
,
name
}
=
this
;
try
{
const
response
=
await
callApi
(
name
,
uri
,
params
,
method
,
'json'
,
this
.
ignoreSuccessField
);
this
.
onGotResponse
(
response
);
return
response
.
data
;
}
catch
(
e
)
{
this
.
onGotError
(
e
);
}
}
}
src/net/SamplePollingApi.ts
deleted
100644 → 0
View file @
5cd6c17c
/**
* Created by hwj on 2018/12/1.
*
* 简单的api组件
*/
import
{
utils
,
dynamic
}
from
'scilla'
import
ApiComponent
from
"./ApiComponent"
;
import
{
callApi
,
polling
}
from
"./webService"
;
export
default
class
SamplePollingApi
extends
ApiComponent
{
name
:
string
;
successField
:
string
;
successValues
:
any
[];
uri
:
string
;
method
:
string
=
'GET'
;
params
:
dynamic
;
maxTimes
:
number
=
5
;
delay
:
number
=
500
;
async
callApi
(
name
,
paramsInput
,
...
args
)
{
if
(
this
.
name
==
name
)
{
await
this
.
execute
(
paramsInput
,
...
args
);
}
}
protected
async
execute
(
paramsInput
?,
...
args
)
{
await
super
.
execute
(
paramsInput
,
...
args
);
const
params
=
{
};
if
(
this
.
params
)
{
utils
.
injectProp
(
params
,
this
.
params
);
}
if
(
paramsInput
)
{
utils
.
injectProp
(
params
,
paramsInput
);
}
const
{
uri
,
method
,
name
}
=
this
;
try
{
const
response
=
await
polling
(
name
,
this
.
successFunc
,
uri
,
params
,
this
.
maxTimes
,
this
.
delay
,
method
);
this
.
onGotResponse
(
response
);
return
response
.
data
;
}
catch
(
e
)
{
this
.
onGotError
(
e
);
}
}
successFunc
=
(
response
)
=>
{
const
{
successField
,
successValues
}
=
this
;
let
v
=
successField
?
response
.
data
[
successField
]
:
response
.
data
;
return
successValues
.
indexOf
(
v
)
>=
0
;
}
}
src/net/api/hdtool/base/AjaxElementComponent.ts
deleted
100644 → 0
View file @
5cd6c17c
import
{
utils
,
dynamic
}
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
:
dynamic
;
//入库活动ID
activityId
:
dynamic
;
protected
async
execute
()
{
utils
.
injectProp
(
this
.
params
,
{
duibaId
:
this
.
duibaId
,
activityId
:
this
.
activityId
});
super
.
execute
();
}
}
\ No newline at end of file
src/net/api/hdtool/base/DoJoinComponent.ts
deleted
100644 → 0
View file @
5cd6c17c
import
{
utils
,
dynamic
}
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
:
dynamic
;
//token
token
:
dynamic
;
//再来一次订单ID
againOrderId
:
dynamic
;
//活动类型
activityType
:
dynamic
;
//用户ID
consumerId
:
dynamic
;
//积分
credits
:
dynamic
;
//分数 分段发奖
score
:
dynamic
;
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
src/net/api/hdtool/base/GetOrderStatusComponent.ts
deleted
100644 → 0
View file @
5cd6c17c
import
{
utils
,
dynamic
}
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
:
dynamic
;
protected
async
execute
()
{
utils
.
injectProp
(
this
.
params
,
{
orderId
:
this
.
orderId
});
super
.
execute
();
}
}
\ No newline at end of file
src/net/api/hdtool/base/PrizeDetailComponent.ts
deleted
100644 → 0
View file @
5cd6c17c
import
{
utils
,
dynamic
}
from
"scilla"
;
import
SampleApi
from
"../../../SampleApi"
;
/**
* 查询奖品信息
*/
export
default
class
PrizeDetailComponent
extends
SampleApi
{
//唯一标识
name
:
string
=
'prizeDetail'
;
//访问路径
uri
:
string
=
'/hdtool/recon/prizeDetail'
;
//请求方式
method
:
string
=
'GET'
;
//
appItemId
:
dynamic
;
//
itemId
:
dynamic
;
//
appId
:
dynamic
;
protected
async
execute
()
{
utils
.
injectProp
(
this
.
params
,
{
appItemId
:
this
.
appItemId
,
itemId
:
this
.
itemId
,
appId
:
this
.
appId
});
super
.
execute
();
}
}
src/net/api/hdtool/base/SubCreditsStatusComponent.ts
deleted
100644 → 0
View file @
5cd6c17c
import
{
utils
,
dynamic
}
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
:
dynamic
;
protected
async
execute
()
{
utils
.
injectProp
(
this
.
params
,
{
orderId
:
this
.
orderId
});
super
.
execute
();
}
}
\ No newline at end of file
src/net/api/hdtool/game/DatapashComponent.ts
deleted
100644 → 0
View file @
5cd6c17c
import
{
utils
,
dynamic
}
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
:
dynamic
;
//防作弊数据
dynamicData
:
dynamic
;
//duiba活动ID
duibaId
:
dynamic
;
protected
async
execute
()
{
utils
.
injectProp
(
this
.
params
,
{
orderId
:
this
.
orderId
,
duibaId
:
this
.
duibaId
,
dynamicData
:
this
.
dynamicData
});
super
.
execute
();
}
}
\ No newline at end of file
src/net/api/hdtool/game/GetNgameStartStatusComponent.ts
deleted
100644 → 0
View file @
5cd6c17c
import
{
utils
,
dynamic
}
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
:
dynamic
;
protected
async
execute
()
{
utils
.
injectProp
(
this
.
params
,
{
orderId
:
this
.
orderId
});
super
.
execute
();
}
}
\ No newline at end of file
src/net/api/hdtool/game/NgameManySubmitComponent.ts
deleted
100644 → 0
View file @
5cd6c17c
import
{
utils
,
dynamic
}
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
:
dynamic
;
//分数
score
:
dynamic
;
//无用
gameData
:
dynamic
;
//签名
sgin
:
dynamic
;
//防作弊数据
dynamicData
:
dynamic
;
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
src/net/api/hdtool/game/NgameSubmitComponent.ts
deleted
100644 → 0
View file @
5cd6c17c
import
{
utils
,
dynamic
}
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
:
dynamic
;
//分数
score
:
dynamic
;
//无用
gameData
:
dynamic
;
//签名
sgin
:
dynamic
;
//防作弊数据
dynamicData
:
dynamic
;
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
src/net/api/hdtool/game/ResurrectionComponent.ts
deleted
100644 → 0
View file @
5cd6c17c
import
{
utils
,
dynamic
}
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
:
dynamic
;
protected
async
execute
()
{
utils
.
injectProp
(
this
.
params
,
{
orderId
:
this
.
orderId
});
super
.
execute
();
}
}
\ No newline at end of file
src/net/api/hdtool/game/ResurrectionStatusComponent.ts
deleted
100644 → 0
View file @
5cd6c17c
import
{
utils
,
dynamic
}
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
:
dynamic
;
//resurrec订单ID
resurrecOrderId
:
dynamic
;
protected
async
execute
()
{
utils
.
injectProp
(
this
.
params
,
{
orderId
:
this
.
orderId
,
resurrecOrderId
:
this
.
resurrecOrderId
});
super
.
execute
();
}
}
\ No newline at end of file
src/net/api/hdtool/preLottery/GetGameOrderInfoComponent.ts
deleted
100644 → 0
View file @
5cd6c17c
import
{
utils
,
dynamic
}
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
:
dynamic
;
protected
async
execute
()
{
utils
.
injectProp
(
this
.
params
,
{
orderId
:
this
.
orderId
});
super
.
execute
();
}
}
\ No newline at end of file
src/net/api/hdtool/preLottery/GetGameSubmitComponent.ts
deleted
100644 → 0
View file @
5cd6c17c
import
{
utils
,
dynamic
}
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
:
dynamic
;
//价值
facePrice
:
dynamic
;
protected
async
execute
()
{
utils
.
injectProp
(
this
.
params
,
{
orderId
:
this
.
orderId
,
facePrice
:
this
.
facePrice
});
super
.
execute
();
}
}
\ No newline at end of file
src/net/api/hdtool/question/CheckOutAnswerComponent.ts
deleted
100644 → 0
View file @
5cd6c17c
import
{
utils
,
dynamic
}
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
:
dynamic
;
//答案
answerData
:
dynamic
;
protected
async
execute
()
{
utils
.
injectProp
(
this
.
params
,
{
orderId
:
this
.
orderId
,
answerData
:
this
.
answerData
});
super
.
execute
();
}
}
\ No newline at end of file
src/net/api/hdtool/question/GetQuestionComponent.ts
deleted
100644 → 0
View file @
5cd6c17c
import
{
utils
,
dynamic
}
from
"scilla"
;
import
SampleApi
from
"../../../SampleApi"
;
/**
* 获取题目数据
*/
export
default
class
GetQuestionComponent
extends
SampleApi
{
//唯一标识
name
:
string
=
'getQuestionInfo'
;
//访问路径
uri
:
string
=
'/recon/getQuestionInfo'
;
//请求方式
method
:
string
=
'GET'
;
//入库活动ID
activityId
:
dynamic
;
protected
async
execute
()
{
utils
.
injectProp
(
this
.
params
,
{
activityId
:
this
.
activityId
});
super
.
execute
();
}
}
\ No newline at end of file
src/net/api/hdtool/question/QuestionSubmitComponent.ts
deleted
100644 → 0
View file @
5cd6c17c
import
{
utils
,
dynamic
}
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
:
dynamic
;
//答案
answerData
:
dynamic
;
protected
async
execute
()
{
utils
.
injectProp
(
this
.
params
,
{
orderId
:
this
.
orderId
,
answerData
:
this
.
answerData
});
super
.
execute
();
}
}
\ No newline at end of file
src/net/api/hdtool/throughGame/AjaxThroughInfoComponent.ts
deleted
100644 → 0
View file @
5cd6c17c
import
{
utils
,
dynamic
}
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
:
dynamic
;
//关卡ID
throughId
:
dynamic
;
protected
async
execute
()
{
utils
.
injectProp
(
this
.
params
,
{
duibaId
:
this
.
duibaId
,
throughId
:
this
.
throughId
});
super
.
execute
();
}
}
\ No newline at end of file
src/net/api/hdtool/throughGame/ThroughSubmitComponent.ts
deleted
100644 → 0
View file @
5cd6c17c
import
{
utils
,
dynamic
}
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
:
dynamic
;
protected
async
execute
()
{
utils
.
injectProp
(
this
.
params
,
{
orderId
:
this
.
orderId
});
super
.
execute
();
}
}
\ No newline at end of file
src/net/webService.ts
deleted
100644 → 0
View file @
5cd6c17c
/**
* Created by hwj on 2018/11/22.
* 网络组件
*/
import
{
utils
,
customConfig
,
dataCenter
,
dataCenterConfig
}
from
"scilla"
;
/**
* 调用接口
* @param uri
* @param params
* @param method
* @param responseType
* @param ignoreSuccessField
* @param name
*/
export
function
callApi
(
name
:
string
,
uri
:
string
,
params
:
any
=
null
,
method
:
string
=
'post'
,
responseType
=
'json'
,
ignoreSuccessField
=
false
):
Promise
<
any
>
{
let
ts
=
Date
.
now
()
+
Math
.
floor
(
Math
.
random
()
*
9999999
);
let
url
=
uri
.
indexOf
(
'//'
)
===
0
?
uri
:
`
${
uri
}
?_=
${
ts
}
`
;
params
=
params
||
{};
let
options
:
any
=
{
method
,
};
let
baseUrl
=
customConfig
.
webServiceUrl
;
if
(
!
baseUrl
)
{
options
.
credentials
=
'include'
;
}
let
temp
=
typeof
params
===
'string'
?
params
:
utils
.
objectStringify
(
params
);
switch
(
method
.
toUpperCase
())
{
case
'GET'
:
if
(
temp
&&
temp
.
length
>
0
){
url
+=
(
url
.
indexOf
(
'?'
)
<
0
?
'?'
:
''
)
+
'&'
+
temp
;
}
break
;
case
'POST'
:
options
.
body
=
temp
;
options
.
headers
=
{
'Content-Type'
:
'application/x-www-form-urlencoded;charset=UTF-8'
,
};
break
;
}
const
fetchMethod
=
responseType
==
'jsonp'
?
window
[
'fetchJsonp'
]
:
fetch
;
url
=
baseUrl
?
baseUrl
+
url
:
url
return
fetchMethod
(
url
,
options
)
.
then
((
response
)
=>
{
if
(
response
.
type
===
'opaque'
)
{
return
null
;
}
return
response
.
text
();
})
.
then
((
response
)
=>
{
//console.log('fetch ==>', url, response);
if
(
response
)
{
let
data
;
switch
(
responseType
)
{
case
'json'
:
try
{
/*console.log('debug', GameConfig.debug);
console.log(url, options);
console.log(response);*/
data
=
JSON
.
parse
(
response
);
}
catch
(
e
)
{
console
.
log
(
'decode json failed: '
+
url
);
return
Promise
.
reject
({});
}
if
(
ignoreSuccessField
||
data
.
success
)
{
return
{
data
:
data
.
hasOwnProperty
(
'data'
)
?
data
.
data
:
data
,
origin
:
data
,
};
}
else
{
return
Promise
.
reject
(
data
.
code
);
}
case
'html'
:
let
html
=
null
;
//DOMParser.parseFromString(response, 'text/html');
return
html
;
case
'txt'
:
return
response
;
}
}
return
Promise
.
reject
();
})
.
then
(
response
=>
{
dataCenter
.
set
(
dataCenterConfig
.
ajax
,
name
,
response
.
origin
)
return
response
})
}
/**
* 轮训请求
* @param name
* @param successFunc
* @param maxTimes
* @param delay
* @param uri
* @param params
* @param method
* @param responseType
*/
export
function
polling
(
name
,
successFunc
,
uri
,
params
,
maxTimes
=
10
,
delay
=
500
,
method
=
'POST'
,
responseType
=
'json'
):
Promise
<
any
>
{
let
p
=
Promise
.
resolve
();
for
(
let
i
=
0
;
i
<
maxTimes
;
i
++
)
{
p
=
p
.
then
(
func
);
p
=
p
.
then
(()
=>
{
return
utils
.
waitPromise
(
delay
)
})
}
let
lastData
;
return
p
.
then
(
()
=>
{
return
Promise
.
reject
(
null
);
},
(
e
)
=>
{
if
(
e
===
'success'
)
{
return
Promise
.
resolve
(
lastData
);
}
return
Promise
.
reject
(
e
);
}
);
function
func
()
{
return
callApi
(
name
,
uri
,
params
,
method
,
responseType
).
then
(
(
data
)
=>
{
if
(
successFunc
(
data
))
{
lastData
=
data
;
return
Promise
.
reject
(
'success'
);
}
},
(
e
)
=>
{
return
Promise
.
reject
(
e
);
}
)
}
}
/**
* 获取token并发送
* @param name
* @param uri
* @param params
* @param method
* @param responseType
*/
export
async
function
getToken
(
name
:
string
,
uri
:
string
,
params
:
any
,
method
:
string
=
'POST'
,
responseType
:
string
=
'json'
)
{
if
(
window
[
'getDuibaToken'
])
{
window
[
'getDuibaToken'
](
async
(
tokenObj
:
any
)
=>
{
params
.
token
=
tokenObj
.
token
;
await
callApi
(
name
,
uri
,
params
,
method
,
responseType
);
},
()
=>
{
});
}
else
{
await
callApi
(
name
,
uri
,
params
,
method
,
responseType
);
}
}
// /**
// * 通讯底层错误
// */
// protected onError(key,msgObj): void {
// const msg = `${key}:${msgObj}`
// this.dispatchEvent('Error', msg );
// }
/**
* 生成签名
* @param {number} ticketId
* @param {number} score
* @param {any} gameData
* @param {string} submitToken 提交
* @returns {string} 签名
*/
export
function
createSgin
(
ticketId
:
number
,
score
:
number
,
gameData
:
any
,
submitToken
:
string
):
string
{
return
window
[
'duiba_md5'
](
ticketId
+
''
+
score
+
''
+
gameData
+
''
+
submitToken
);
}
src/registerAllComponents.ts
View file @
ff28e792
import
{
registerDef
}
from
"scilla"
import
ScillaComponent
from
'./base/ScillaComponent'
;
import
BounceZoom
from
'./animation/BounceZoom'
;
import
Fade
from
'./animation/Fade'
;
import
Rotation
from
'./animation/Rotation'
;
...
...
@@ -13,27 +12,6 @@ import InteractComponent from './base/InteractComponent';
import
ScillaComponent
from
'./base/ScillaComponent'
;
import
TouchInterrupt
from
'./base/TouchInterrupt'
;
import
Transform
from
'./base/Transform'
;
import
AjaxElementComponent
from
'./net/api/hdtool/base/AjaxElementComponent'
;
import
DoJoinComponent
from
'./net/api/hdtool/base/DoJoinComponent'
;
import
GetOrderStatusComponent
from
'./net/api/hdtool/base/GetOrderStatusComponent'
;
import
PrizeDetailComponent
from
'./net/api/hdtool/base/PrizeDetailComponent'
;
import
SubCreditsStatusComponent
from
'./net/api/hdtool/base/SubCreditsStatusComponent'
;
import
DatapashComponent
from
'./net/api/hdtool/game/DatapashComponent'
;
import
GetNgameStartStatusComponent
from
'./net/api/hdtool/game/GetNgameStartStatusComponent'
;
import
NgameManySubmitComponent
from
'./net/api/hdtool/game/NgameManySubmitComponent'
;
import
NgameSubmitComponent
from
'./net/api/hdtool/game/NgameSubmitComponent'
;
import
ResurrectionComponent
from
'./net/api/hdtool/game/ResurrectionComponent'
;
import
ResurrectionStatusComponent
from
'./net/api/hdtool/game/ResurrectionStatusComponent'
;
import
GetGameOrderInfoComponent
from
'./net/api/hdtool/preLottery/GetGameOrderInfoComponent'
;
import
GetGameSubmitComponent
from
'./net/api/hdtool/preLottery/GetGameSubmitComponent'
;
import
CheckOutAnswerComponent
from
'./net/api/hdtool/question/CheckOutAnswerComponent'
;
import
GetQuestionComponent
from
'./net/api/hdtool/question/GetQuestionComponent'
;
import
QuestionSubmitComponent
from
'./net/api/hdtool/question/QuestionSubmitComponent'
;
import
AjaxThroughInfoComponent
from
'./net/api/hdtool/throughGame/AjaxThroughInfoComponent'
;
import
ThroughSubmitComponent
from
'./net/api/hdtool/throughGame/ThroughSubmitComponent'
;
import
ApiComponent
from
'./net/ApiComponent'
;
import
SampleApi
from
'./net/SampleApi'
;
import
SamplePollingApi
from
'./net/SamplePollingApi'
;
import
CameraController
from
'./other/CameraController'
;
import
ContentSizeFitter
from
'./other/ContentSizeFitter'
;
import
FullStageSize
from
'./other/FullStageSize'
;
...
...
@@ -51,7 +29,6 @@ import ProgressBar from './ui/ProgressBar';
import
ScrollView
from
'./ui/ScrollView'
;
export
function
registerAllComponents
(){
registerDef
(
'components/base/ScillaComponent'
,
ScillaComponent
);
registerDef
(
'components/animation/BounceZoom'
,
BounceZoom
);
registerDef
(
'components/animation/Fade'
,
Fade
);
registerDef
(
'components/animation/Rotation'
,
Rotation
);
...
...
@@ -64,27 +41,6 @@ export function registerAllComponents(){
registerDef
(
'components/base/ScillaComponent'
,
ScillaComponent
);
registerDef
(
'components/base/TouchInterrupt'
,
TouchInterrupt
);
registerDef
(
'components/base/Transform'
,
Transform
);
registerDef
(
'components/net/api/hdtool/base/AjaxElementComponent'
,
AjaxElementComponent
);
registerDef
(
'components/net/api/hdtool/base/DoJoinComponent'
,
DoJoinComponent
);
registerDef
(
'components/net/api/hdtool/base/GetOrderStatusComponent'
,
GetOrderStatusComponent
);
registerDef
(
'components/net/api/hdtool/base/PrizeDetailComponent'
,
PrizeDetailComponent
);
registerDef
(
'components/net/api/hdtool/base/SubCreditsStatusComponent'
,
SubCreditsStatusComponent
);
registerDef
(
'components/net/api/hdtool/game/DatapashComponent'
,
DatapashComponent
);
registerDef
(
'components/net/api/hdtool/game/GetNgameStartStatusComponent'
,
GetNgameStartStatusComponent
);
registerDef
(
'components/net/api/hdtool/game/NgameManySubmitComponent'
,
NgameManySubmitComponent
);
registerDef
(
'components/net/api/hdtool/game/NgameSubmitComponent'
,
NgameSubmitComponent
);
registerDef
(
'components/net/api/hdtool/game/ResurrectionComponent'
,
ResurrectionComponent
);
registerDef
(
'components/net/api/hdtool/game/ResurrectionStatusComponent'
,
ResurrectionStatusComponent
);
registerDef
(
'components/net/api/hdtool/preLottery/GetGameOrderInfoComponent'
,
GetGameOrderInfoComponent
);
registerDef
(
'components/net/api/hdtool/preLottery/GetGameSubmitComponent'
,
GetGameSubmitComponent
);
registerDef
(
'components/net/api/hdtool/question/CheckOutAnswerComponent'
,
CheckOutAnswerComponent
);
registerDef
(
'components/net/api/hdtool/question/GetQuestionComponent'
,
GetQuestionComponent
);
registerDef
(
'components/net/api/hdtool/question/QuestionSubmitComponent'
,
QuestionSubmitComponent
);
registerDef
(
'components/net/api/hdtool/throughGame/AjaxThroughInfoComponent'
,
AjaxThroughInfoComponent
);
registerDef
(
'components/net/api/hdtool/throughGame/ThroughSubmitComponent'
,
ThroughSubmitComponent
);
registerDef
(
'components/net/ApiComponent'
,
ApiComponent
);
registerDef
(
'components/net/SampleApi'
,
SampleApi
);
registerDef
(
'components/net/SamplePollingApi'
,
SamplePollingApi
);
registerDef
(
'components/other/CameraController'
,
CameraController
);
registerDef
(
'components/other/ContentSizeFitter'
,
ContentSizeFitter
);
registerDef
(
'components/other/FullStageSize'
,
FullStageSize
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment