|
@ -6,39 +6,48 @@ define(["jcl","mobile","clientTool"],function(Wade,Mobile,ClientTool) {
|
6
|
6
|
/*调用服务*/
|
7
|
7
|
this.callSvc = function(action,param,callback,isEscape,error){
|
8
|
8
|
param = param ? param : new Wade.DataMap();
|
9
|
|
error = error ? error : function(x_code, x_info) {
|
|
9
|
error = error ? error : function(x_info, x_code) {
|
10
|
10
|
Mobile.loadingStop();
|
11
|
|
alert(action + "请求失败\n错误编码:[" + x_code + "]\n错误信息:" + x_info);
|
|
11
|
if(x_code){
|
|
12
|
alert("错误编码:[" + x_code + "]\n错误信息:" + x_info);
|
|
13
|
}else{
|
|
14
|
alert("错误信息:" + x_info);
|
|
15
|
}
|
12
|
16
|
if(x_code==-100){
|
13
|
|
Mobile.openPage("SessionErr");
|
|
17
|
Mobile.openPage("Login");
|
14
|
18
|
}
|
15
|
19
|
};
|
16
|
20
|
|
17
|
|
Common.get(function(sessionID){
|
18
|
|
param.put(Constant.SESSION_ID,sessionID);
|
19
|
|
if(!param.get(Constant.STAFF_ID)){
|
20
|
|
Common.getLocal(function(staffID){
|
21
|
|
param.put(Constant.STAFF_ID,staffID);
|
22
|
|
callSvc(action,param,callback,isEscape,error);
|
23
|
|
},Constant.STAFF_ID);
|
24
|
|
}else{
|
25
|
|
callSvc(action,param,callback,isEscape,error);
|
|
21
|
Common.get(function(data) {
|
|
22
|
if (typeof data == "string") {
|
|
23
|
data = new Wade.DataMap(data);
|
26
|
24
|
}
|
27
|
|
},Constant.SESSION_ID);
|
|
25
|
if (data.get(Constant.SESSION_ID)) {
|
|
26
|
param.put(Constant.SESSION_ID, data.get(Constant.SESSION_ID));
|
|
27
|
}
|
|
28
|
if (data.get(Constant.STAFF_ID)) {
|
|
29
|
param.put(Constant.STAFF_ID, data.get(Constant.STAFF_ID));
|
|
30
|
}
|
|
31
|
callSvc(action, param, callback, isEscape, error);
|
|
32
|
}, [Constant.SESSION_ID,Constant.STAFF_ID]);
|
28
|
33
|
|
29
|
34
|
function callSvc(_action,_param,_callback,_isEscape,_error){
|
30
|
|
Mobile.dataRequest(_action,_param,function(data){
|
|
35
|
Mobile.dataRequest(_action,_param,function(resultData){
|
31
|
36
|
var x_resultcode, x_resultinfo;
|
32
|
|
if (data.substring(0, 1) == "{") {
|
33
|
|
data = new Wade.DataMap(data);
|
34
|
|
x_resultcode = data.get(Constant.X_RESULTCODE);
|
35
|
|
x_resultinfo = data.get(Constant.X_RESULTINFO);
|
36
|
|
} else if (data.substring(0, 1) == "[") {
|
37
|
|
data = new Wade.DatasetList(data);
|
38
|
|
x_resultcode = data.get(0).get(Constant.X_RESULTCODE);
|
39
|
|
x_resultinfo = data.get(0).get(Constant.X_RESULTINFO);
|
|
37
|
if (resultData.substring(0, 1) == "{") {
|
|
38
|
resultData = new Wade.DataMap(resultData);
|
|
39
|
x_resultcode = resultData.get(Constant.X_RESULTCODE);
|
|
40
|
x_resultinfo = resultData.get(Constant.X_RESULTINFO);
|
|
41
|
} else if (resultData.substring(0, 1) == "[") {
|
|
42
|
resultData = new Wade.DatasetList(resultData);
|
|
43
|
x_resultcode = resultData.get(0).get(Constant.X_RESULTCODE);
|
|
44
|
x_resultinfo = resultData.get(0).get(Constant.X_RESULTINFO);
|
|
45
|
}
|
|
46
|
if(x_resultcode<0){
|
|
47
|
_error(x_resultinfo, x_resultcode);//接口异常则回调报错函数
|
|
48
|
}else{
|
|
49
|
_callback(resultData);
|
40
|
50
|
}
|
41
|
|
_callback(data);
|
42
|
51
|
}, _isEscape, _error);
|
43
|
52
|
}
|
44
|
53
|
};
|