Przeglądaj źródła

增加异常验证场景

bpascal 6 lat temu
rodzic
commit
06a486884a

+ 2 - 0
show-server/.gitignore

@ -3,3 +3,5 @@ bin/
3 3
target/
4 4
*.war
5 5
.tomcatplugin
6
.idea/
7
classes/

+ 3 - 0
show-server/src/main/resources/server-data.xml

@ -8,4 +8,7 @@
8 8
	<action name="Dropload_update" class="com.ai.ipu.server.frame.bean.SimulatedBean" method="invoke" verify="false"></action>
9 9
	
10 10
	<action name="SceneBean.openIPUScene" class="com.ai.ipu.show.bean.SceneBean" method="openIPUScene" verify="false"></action>
11
12
	<!--测试请求-->
13
	<action name="SceneBean.dataRequestScene" class="com.ai.ipu.show.bean.SceneBean" method="dataRequestScene" verify="false"></action>
11 14
</datas>

+ 212 - 211
show-server/src/main/webapp/biz/js/common/common.js

@ -1,218 +1,219 @@
1 1
/**
2
 * 将一些公共的业务处理放入此对象中 
2
 * 将一些公共的业务处理放入此对象中
3 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
		};
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
            };
49 20
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
			};
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]);
63 33
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]);
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
        };
76 49
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);
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
115
            function getPage(_action, _param, _callback, _error) {
116
                Mobile.getPage(_action, _param, _callback, function (errMsg) {
117
                    if (typeof (errMsg) == "string") {
118
                        errMsg = new Wade.DataMap(errMsg);
119
                    }
120
                    var x_resultcode = errMsg.get("X_RESULTCODE");
121
                    var x_resultinfo = errMsg.get("X_RESULTINFO");
122
                    _error(x_resultinfo, x_resultcode);
123
                });
124
            }
125
        };
126
127
        this.closeApp = function () {
128
            if (confirm("确定要退出应用程序吗?")) {
129
                Mobile.closeApp();
130
            }
131
        };
132
133
        this.logoutAccount = function () {
134
            if (confirm("确定要注销该工号吗?")) {
135
                Common.remove(Constant.SESSION_ID);
135 136
                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;
137
                Mobile.openTemplate("Home");
138
            }
139
        };
140
141
        this.put = function (key, value) {
142
            if (!checkMapKey(key)) {
143
                return;
144
            }
145
            Mobile.setMemoryCache(key, value);
146
        };
147
        this.get = function (callback, key, value) {
148
            if (!checkArrayKey(key)) {
149
                return;
150
            }
151
            Mobile.getMemoryCache(callback, key, value);
152
        };
153
        this.remove = function (key) {
154
            if (!checkArrayKey(key)) {
155
                return;
156
            }
157
            Mobile.removeMemoryCache(key);
158
        };
159
        this.clear = function () {
160
            Mobile.clearMemoryCache();
161
        };
162
        this.putLocal = function (key, value) {
163
            if (!checkMapKey(key)) {
164
                return;
165
            }
166
            Mobile.setOfflineCache(key, value);
167
        };
168
        this.getLocal = function (callback, key, value) {
169
            if (!checkArrayKey(key)) {
170
                return;
171
            }
172
            Mobile.getOfflineCache(callback, key, value);
173
        };
174
        this.removeLocal = function (key) {
175
            if (!checkArrayKey(key)) {
176
                return;
177
            }
178
            Mobile.removeOfflineCache(key);
179
        };
180
        this.clearLocal = function () {
181
            Mobile.clearOfflineCache();
182
        };
183
        /*数据库操作*/
184
        var dbName = "display";
185
        this.execSQL = function (sql, bindArgs, callback, err) {
186
            Mobile.execSQL(dbName, sql, bindArgs, callback, err);
187
        };
188
189
        function checkMapKey(key) {
190
            if (!key || (typeof (key) != "string" && !ClientTool.tool.isDataMap(key))) {
191
                alert(key + "参数类型异常");
192
                return false;
193
            } else {
194
                return true;
195
            }
196
        }
197
198
        function checkArrayKey(key) {
199
            if (!key || (typeof (key) != "string" && !ClientTool.tool.isArray(key))) {
200
                alert(key + "参数类型异常");
201
                return false;
202
            } else {
203
                return true;
204
            }
205
        }
206
    }
207
208
    window.Constant = {
209
        OPEN_PAGE_KEY: "OPEN_PAGE_KEY",
210
        STAFF_ID: "STAFF_ID",
211
        SESSION_ID: "SESSION_ID",
212
        X_RECORDNUM: "X_RECORDNUM",
213
        X_RESULTCODE: "X_RESULTCODE",
214
        X_RESULTINFO: "X_RESULTINFO",
215
        X_RESULTCAUSE: "X_RESULTCAUSE"
216
    }
217
218
    return Common;
218 219
});

+ 36 - 23
show-server/src/main/webapp/biz/js/index.js

@ -1,33 +1,46 @@
1
require(["domReady!","ipu", "jquery", "iScroll","mobile","wadeMobile"], function (doc,ipu, $, iScroll,Mobile,WadeMobile) {
2
	/*首页被其他iframe嵌入时,需要加入这一行代码*/
3
	ipu.page.options.target = window;
4
	
5
	var navBar = ipu.navBar(".ipu-navbar", {
1
require(["domReady!", "ipu", "jquery", "iScroll", "mobile", "wadeMobile", "common", "jcl"], function (doc, ipu, $, iScroll, Mobile, WadeMobile, Common, Wade) {
2
    /*首页被其他iframe嵌入时,需要加入这一行代码*/
3
    ipu.page.options.target = window;
4
5
    var navBar = ipu.navBar(".ipu-navbar", {
6 6
        animate: true,
7 7
        callBack: function (index, lastIndex) {
8 8
            console.log(index + "," + "last:" + lastIndex);
9 9
        }
10 10
    });
11 11
    navBar.show(0);
12
    
13
    $("#plugin-index,#js-Plugin,#static-Plugin,#more-Plugin").children().click(function(){
14
    	var action = $(this).data("action");
15
    	if(action == "ruUI"){
16
			return;
17
		}
18
    	if(action && action != ""){
19
    		Mobile.openPage(action);
20
    	}else{
21
    		Mobile.alert("This element doesn't bind the attribute of 'data-action'");
22
    	}
12
13
    $("#plugin-index,#js-Plugin,#static-Plugin,#more-Plugin").children().click(function () {
14
        var action = $(this).data("action");
15
        if (action == "ruUI" || action == "invokeException") {
16
            return;
17
        }
18
        if (action && action != "") {
19
            Mobile.openPage(action);
20
        } else {
21
            Mobile.alert("This element doesn't bind the attribute of 'data-action'");
22
        }
23
    });
24
25
    Mobile.setBackCallListener(function (e) {
26
        alert(e);
27
    });
28
29
    $("#rnUI").click(function () {
30
        WadeMobile.openRN("UI_GRIDVIEW");
23 31
    });
24
    
25
    Mobile.setBackCallListener(function(e){
26
		alert(e);
27
	});
28
    
29
    $("#rnUI").click(function(){
30
    	WadeMobile.openRN("UI_GRIDVIEW");
32
33
    $("#invokeException").click(function () {
34
        ipu.showPreloader();
35
        var param = new Wade.DataMap();
36
37
        Common.callSvc("SceneBean.dataRequestScene", param, function (resultData) {
38
            ipu.hidePreloader();
39
            alert("成功返回\n参数是:" + JSON.stringify(resultData));
40
        }, null, function (x_info) {
41
            ipu.hidePreloader();
42
            alert("进入了插件错误调用返回,错误信息是:" + x_info);
43
        });
31 44
    });
32 45
33 46
});

+ 4 - 0
show-server/src/main/webapp/template/webapp/more/moreIndex.html

@ -27,6 +27,10 @@
27 27
			<span class="ipu-icon fa fa-sliders"></span>
28 28
			<p>React Native UI库</p>
29 29
		</li>
30
		<li class="ipu-col-33 ipu-text-center" id="invokeException" data-action="invokeException">
31
			<span class="ipu-icon fa fa-compress"></span>
32
			<p>模拟异常</p>
33
		</li>
30 34
	</ul>
31 35
	
32 36
</div>