Selaa lähdekoodia

dataRequest连接异常更新

leijie 6 vuotta sitten
vanhempi
commit
7dc0cfe899

+ 217 - 217
display-server/src/main/webapp/biz/js/common/common.js

@ -1,218 +1,218 @@
1
/**
2
 * 将一些公共的业务处理放入此对象中 
3
 */
4
define(["jcl","mobile","clientTool"],function(Wade,Mobile,ClientTool) {
5
	var Common = new function(){
6
		/*调用服务*/
7
		this.callSvc = function(action,param,callback,isEscape,error){
8
			param = param ? param : new Wade.DataMap();
9
            error = error ? error : function(x_info, x_code) {
10
				Mobile.loadingStop();
11
				if(x_code){
12
					alert("错误编码:[" + x_code + "]\n错误信息:" + x_info);
13
				}else{
14
					alert("错误信息:" + x_info);
15
				}
16
				if(x_code==-100){
17
					Mobile.openPage("Login");
18
				}
19
			};
20
            
21
			Common.get(function(data) {
22
				if (typeof data == "string") {
23
					data = new Wade.DataMap(data);
24
				}
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]);
33
			
34
			function callSvc(_action,_param,_callback,_isEscape,_error){
35
				Mobile.dataRequest(_action,_param,function(resultData){
36
					if (typeof (resultData) == "string") {
37
						resultData = new Wade.DataMap(resultData);
38
					}
39
					var x_resultcode = resultData.get(Constant.X_RESULTCODE);
40
					var x_resultinfo = resultData.get(Constant.X_RESULTINFO);
41
					if(x_resultcode<0){
42
						_error(x_resultinfo, x_resultcode);//接口异常则回调报错函数
43
					}else{
44
						_callback(resultData);
45
					}
46
				}, _isEscape, _error);
47
			}
48
		};
49

50
		this.openPage = function(action, param, error) {
51
			param = param ? param : new Wade.DataMap();
52
			error = error ? error : function(x_info, x_code) {
53
				Mobile.loadingStop();
54
				if(x_code){
55
					alert("错误编码:[" + x_code + "]\n错误信息:" + x_info);
56
				}else{
57
					alert("错误信息:" + x_info);
58
				}
59
				if(x_code==-100){
60
					Mobile.openPage("Login");
61
				}
62
			};
63

64
			Common.get(function(data) {
65
				if (typeof data == "string") {
66
					data = new Wade.DataMap(data);
67
				}
68
				if (data.get(Constant.SESSION_ID)) {
69
					param.put(Constant.SESSION_ID, data.get(Constant.SESSION_ID));
70
				}
71
				if (data.get(Constant.STAFF_ID)) {
72
					param.put(Constant.STAFF_ID, data.get(Constant.STAFF_ID));
73
				}
74
				openPage(action, param, error);
75
			}, [Constant.SESSION_ID,Constant.STAFF_ID]);
76

77
			function openPage(_action, _param, _error) {
78
				Mobile.openPage(_action, _param, function(errMsg) {
79
					if (typeof (errMsg) == "string") {
80
						errMsg = new Wade.DataMap(errMsg);
81
					}
82
					var x_resultcode = errMsg.get("X_RESULTCODE");
83
					var x_resultinfo = errMsg.get("X_RESULTINFO");
84
					_error(x_resultinfo, x_resultcode);
85
				});
86
			}
87
		};
88
		
89
		this.getPage = function(action, param, callback, error) {
90
			param = param ? param : new Wade.DataMap();
91
			error = error ? error : function(x_info, x_code) {
92
				Mobile.loadingStop();
93
				if(x_code){
94
					alert("错误编码:[" + x_code + "]\n错误信息:" + x_info);
95
				}else{
96
					alert("错误信息:" + x_info);
97
				}
98
				if(x_code==-100){
99
					Mobile.openPage("Index");
100
				}
101
			};
102
			Common.get(function(data) {
103
				if (typeof data == "string") {
104
					data = new Wade.DataMap(data);
105
				}
106
				if (data.get(Constant.SESSION_ID)) {
107
					param.put(Constant.SESSION_ID, data.get(Constant.SESSION_ID));
108
				}
109
				if (data.get(Constant.STAFF_ID)) {
110
					param.put(Constant.STAFF_ID, data.get(Constant.STAFF_ID));
111
				}
112
				getPage(action, param, callback, error);
113
			}, [Constant.SESSION_ID,Constant.STAFF_ID]);
114
			function getPage(_action, _param, _callback, _error) {
115
				Mobile.getPage(_action, _param, _callback, function(errMsg) {
116
					if (typeof (errMsg) == "string") {
117
						errMsg = new Wade.DataMap(errMsg);
118
					}
119
					var x_resultcode = errMsg.get("X_RESULTCODE");
120
					var x_resultinfo = errMsg.get("X_RESULTINFO");
121
					_error(x_resultinfo, x_resultcode);
122
				});
123
			}
124
		};
125
		
126
		this.closeApp = function(){
127
			if(confirm("确定要退出应用程序吗?")){
128
				Mobile.closeApp();
129
			}
130
		};
131
		
132
		this.logoutAccount = function(){
133
			if(confirm("确定要注销该工号吗?")){
134
				Common.remove(Constant.SESSION_ID);
135
                WadeMobile.clearBackStack();
136
				Mobile.openTemplate("Home");
137
			}
138
		};
139
		
140
		this.put = function(key, value) {
141
			if(!checkMapKey(key)){
142
				return;
143
			}
144
			Mobile.setMemoryCache(key, value);
145
		};
146
		this.get = function(callback, key, value) {
147
			if(!checkArrayKey(key)){
148
				return;
149
			}
150
			Mobile.getMemoryCache(callback, key, value);
151
		};
152
		this.remove = function(key) {
153
			if(!checkArrayKey(key)){
154
				return;
155
			}
156
			Mobile.removeMemoryCache(key);
157
		};
158
		this.clear = function() {
159
		    Mobile.clearMemoryCache();
160
		};
161
		this.putLocal = function(key, value) {
162
			if(!checkMapKey(key)){
163
				return;
164
			}
165
			Mobile.setOfflineCache(key, value);
166
		};
167
		this.getLocal = function(callback, key, value) {
168
			if(!checkArrayKey(key)){
169
				return;
170
			}
171
			Mobile.getOfflineCache(callback, key,value);
172
		};
173
		this.removeLocal = function(key) {
174
			if(!checkArrayKey(key)){
175
				return;
176
			}
177
			Mobile.removeOfflineCache(key);
178
		};
179
		this.clearLocal = function() {
180
			Mobile.clearOfflineCache();
181
		};
182
		/*数据库操作*/
183
		var dbName = "display";
184
		this.execSQL = function(sql,bindArgs,callback,err){
185
			Mobile.execSQL(dbName,sql,bindArgs,callback,err);
186
		};
187
		
188
		function checkMapKey(key){
189
			if (!key || (typeof (key) != "string" && !ClientTool.tool.isDataMap(key))) {
190
				alert(key+"参数类型异常");
191
				return false;
192
			} else {
193
				return true;
194
			}
195
		}
196
		
197
		function checkArrayKey(key){
198
			if (!key || (typeof (key) != "string" && !ClientTool.tool.isArray(key))) {
199
				alert(key+"参数类型异常");
200
				return false;
201
			} else {
202
				return true;
203
			}
204
		}
205
	}
206
	
207
	window.Constant = {
208
		OPEN_PAGE_KEY : "OPEN_PAGE_KEY",
209
		STAFF_ID : "STAFF_ID",
210
		SESSION_ID : "SESSION_ID",
211
		X_RECORDNUM : "X_RECORDNUM",
212
		X_RESULTCODE : "X_RESULTCODE",
213
		X_RESULTINFO : "X_RESULTINFO",
214
		X_RESULTCAUSE : "X_RESULTCAUSE"
215
	}
216
	
217
	return Common;
1
/**
2
 * 将一些公共的业务处理放入此对象中 
3
 */
4
define(["jcl","mobile","clientTool"],function(Wade,Mobile,ClientTool) {
5
	var Common = new function(){
6
		/*调用服务*/
7
		this.callSvc = function(action,param,callback,isEscape,error){
8
			param = param ? param : new Wade.DataMap();
9
            error = error ? error : function(x_info, x_code) {
10
				Mobile.loadingStop();
11
				if(x_code){
12
					alert("错误编码:[" + x_code + "]\n错误信息:" + x_info);
13
				}else{
14
					alert("错误信息:" + x_info);
15
				}
16
				if(x_code==-100){
17
					Mobile.openPage("Login");
18
				}
19
			};
20
            
21
			Common.get(function(data) {
22
				if (typeof data == "string") {
23
					data = new Wade.DataMap(data);
24
				}
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]);
33
			
34
			function callSvc(_action,_param,_callback,_isEscape,_error){
35
				Mobile.dataRequest(_action,_param,function(resultData){
36
					if (typeof (resultData) == "string") {
37
						resultData = new Wade.DataMap(resultData);
38
					}
39
					var x_resultcode = resultData.get(Constant.X_RESULTCODE);
40
					var x_resultinfo = resultData.get(Constant.X_RESULTINFO);
41
					if(x_resultcode<0){
42
						_error(x_resultinfo, x_resultcode);//接口异常则回调报错函数
43
					}else{
44
						_callback(resultData);
45
					}
46
				}, _error);
47
			}
48
		};
49
50
		this.openPage = function(action, param, error) {
51
			param = param ? param : new Wade.DataMap();
52
			error = error ? error : function(x_info, x_code) {
53
				Mobile.loadingStop();
54
				if(x_code){
55
					alert("错误编码:[" + x_code + "]\n错误信息:" + x_info);
56
				}else{
57
					alert("错误信息:" + x_info);
58
				}
59
				if(x_code==-100){
60
					Mobile.openPage("Login");
61
				}
62
			};
63
64
			Common.get(function(data) {
65
				if (typeof data == "string") {
66
					data = new Wade.DataMap(data);
67
				}
68
				if (data.get(Constant.SESSION_ID)) {
69
					param.put(Constant.SESSION_ID, data.get(Constant.SESSION_ID));
70
				}
71
				if (data.get(Constant.STAFF_ID)) {
72
					param.put(Constant.STAFF_ID, data.get(Constant.STAFF_ID));
73
				}
74
				openPage(action, param, error);
75
			}, [Constant.SESSION_ID,Constant.STAFF_ID]);
76
77
			function openPage(_action, _param, _error) {
78
				Mobile.openPage(_action, _param, function(errMsg) {
79
					if (typeof (errMsg) == "string") {
80
						errMsg = new Wade.DataMap(errMsg);
81
					}
82
					var x_resultcode = errMsg.get("X_RESULTCODE");
83
					var x_resultinfo = errMsg.get("X_RESULTINFO");
84
					_error(x_resultinfo, x_resultcode);
85
				});
86
			}
87
		};
88
		
89
		this.getPage = function(action, param, callback, error) {
90
			param = param ? param : new Wade.DataMap();
91
			error = error ? error : function(x_info, x_code) {
92
				Mobile.loadingStop();
93
				if(x_code){
94
					alert("错误编码:[" + x_code + "]\n错误信息:" + x_info);
95
				}else{
96
					alert("错误信息:" + x_info);
97
				}
98
				if(x_code==-100){
99
					Mobile.openPage("Index");
100
				}
101
			};
102
			Common.get(function(data) {
103
				if (typeof data == "string") {
104
					data = new Wade.DataMap(data);
105
				}
106
				if (data.get(Constant.SESSION_ID)) {
107
					param.put(Constant.SESSION_ID, data.get(Constant.SESSION_ID));
108
				}
109
				if (data.get(Constant.STAFF_ID)) {
110
					param.put(Constant.STAFF_ID, data.get(Constant.STAFF_ID));
111
				}
112
				getPage(action, param, callback, error);
113
			}, [Constant.SESSION_ID,Constant.STAFF_ID]);
114
			function getPage(_action, _param, _callback, _error) {
115
				Mobile.getPage(_action, _param, _callback, function(errMsg) {
116
					if (typeof (errMsg) == "string") {
117
						errMsg = new Wade.DataMap(errMsg);
118
					}
119
					var x_resultcode = errMsg.get("X_RESULTCODE");
120
					var x_resultinfo = errMsg.get("X_RESULTINFO");
121
					_error(x_resultinfo, x_resultcode);
122
				});
123
			}
124
		};
125
		
126
		this.closeApp = function(){
127
			if(confirm("确定要退出应用程序吗?")){
128
				Mobile.closeApp();
129
			}
130
		};
131
		
132
		this.logoutAccount = function(){
133
			if(confirm("确定要注销该工号吗?")){
134
				Common.remove(Constant.SESSION_ID);
135
                WadeMobile.clearBackStack();
136
				Mobile.openTemplate("Home");
137
			}
138
		};
139
		
140
		this.put = function(key, value) {
141
			if(!checkMapKey(key)){
142
				return;
143
			}
144
			Mobile.setMemoryCache(key, value);
145
		};
146
		this.get = function(callback, key, value) {
147
			if(!checkArrayKey(key)){
148
				return;
149
			}
150
			Mobile.getMemoryCache(callback, key, value);
151
		};
152
		this.remove = function(key) {
153
			if(!checkArrayKey(key)){
154
				return;
155
			}
156
			Mobile.removeMemoryCache(key);
157
		};
158
		this.clear = function() {
159
		    Mobile.clearMemoryCache();
160
		};
161
		this.putLocal = function(key, value) {
162
			if(!checkMapKey(key)){
163
				return;
164
			}
165
			Mobile.setOfflineCache(key, value);
166
		};
167
		this.getLocal = function(callback, key, value) {
168
			if(!checkArrayKey(key)){
169
				return;
170
			}
171
			Mobile.getOfflineCache(callback, key,value);
172
		};
173
		this.removeLocal = function(key) {
174
			if(!checkArrayKey(key)){
175
				return;
176
			}
177
			Mobile.removeOfflineCache(key);
178
		};
179
		this.clearLocal = function() {
180
			Mobile.clearOfflineCache();
181
		};
182
		/*数据库操作*/
183
		var dbName = "display";
184
		this.execSQL = function(sql,bindArgs,callback,err){
185
			Mobile.execSQL(dbName,sql,bindArgs,callback,err);
186
		};
187
		
188
		function checkMapKey(key){
189
			if (!key || (typeof (key) != "string" && !ClientTool.tool.isDataMap(key))) {
190
				alert(key+"参数类型异常");
191
				return false;
192
			} else {
193
				return true;
194
			}
195
		}
196
		
197
		function checkArrayKey(key){
198
			if (!key || (typeof (key) != "string" && !ClientTool.tool.isArray(key))) {
199
				alert(key+"参数类型异常");
200
				return false;
201
			} else {
202
				return true;
203
			}
204
		}
205
	}
206
	
207
	window.Constant = {
208
		OPEN_PAGE_KEY : "OPEN_PAGE_KEY",
209
		STAFF_ID : "STAFF_ID",
210
		SESSION_ID : "SESSION_ID",
211
		X_RECORDNUM : "X_RECORDNUM",
212
		X_RESULTCODE : "X_RESULTCODE",
213
		X_RESULTINFO : "X_RESULTINFO",
214
		X_RESULTCAUSE : "X_RESULTCAUSE"
215
	}
216
	
217
	return Common;
218 218
});

+ 37 - 10
display-server/src/main/webapp/biz/js/more/scene/DataRequest.js

@ -12,17 +12,34 @@ require(["mobile","util"], function(Mobile) {
12 12
		headers.put("Date","09 Step 2018 11:01:31 GMT");
13 13
		
14 14
		// 数据请求
15
		Mobile.dataRequest("SceneBean.dataRequestScene", param, function(result){
15
		Mobile.dataRequest("SceneBean.dataRequestScene", param, function(resultData){
16 16
			// 获取返回的数据
17
			var obj = new Wade.DataMap(result);
18
			var retName = obj.get("retName");
19
			var retMsg = obj.get("retMsg");
20
			
21
			$("#retName").text(retName);
22
			$("#retMsg").text(retMsg);
23
			$("#mainTestCharacterContent").hide();
24
			$("#retTestCharacterContent").show();
25
		},null,headers);
17
			if (typeof (resultData) == "string") {
18
				resultData = new Wade.DataMap(resultData);
19
			}
20
			alert(resultData);
21
			var x_resultcode = resultData.get(Constant.X_RESULTCODE);
22
			var x_resultinfo = resultData.get(Constant.X_RESULTINFO);
23
			alert(x_resultcode + "," +x_resultinfo);
24
			if(x_resultcode<0){
25
				alert(x_resultcode + "," +x_resultinfo);
26
			}else{
27
				var retName = resultData.get("retName");
28
				var retMsg = resultData.get("retMsg");
29
				
30
				$("#retName").text(retName);
31
				$("#retMsg").text(retMsg);
32
				$("#mainTestCharacterContent").hide();
33
				$("#retTestCharacterContent").show();
34
			}
35
36
		},function(errData){
37
			//插件异常处理
38
			if (typeof (errData) == "string") {
39
				errData = new Wade.DataMap(errData);
40
			}
41
			alert("插件调用异常信息:" + errData);
42
		},headers);
26 43
	});
27 44
	
28 45
	// 再测一次按钮
@ -34,4 +51,14 @@ require(["mobile","util"], function(Mobile) {
34 51
		$("#mainTestCharacterContent").show();
35 52
	});
36 53
	
54
	window.Constant = {
55
			OPEN_PAGE_KEY : "OPEN_PAGE_KEY",
56
			STAFF_ID : "STAFF_ID",
57
			SESSION_ID : "SESSION_ID",
58
			X_RECORDNUM : "X_RECORDNUM",
59
			X_RESULTCODE : "X_RESULTCODE",
60
			X_RESULTINFO : "X_RESULTINFO",
61
			X_RESULTCAUSE : "X_RESULTCAUSE"
62
		}
63
	
37 64
});

+ 3 - 0
display-server/src/main/webapp/res/js/mobile/expand-mobile.js

@ -378,6 +378,9 @@ define(["require"],function(require) {
378 378
                if(WadeMobile.isAndroid()){
379 379
                    execute("clearBackStack",[]);
380 380
                }
381
            },downloadFile:function(type,url,relPath,callback){
382
            	storageCallback("downloadFile",callback);
383
            	execute("downloadFile",[type,url,relPath]);
381 384
            }
382 385
			
383 386