浏览代码

Merge branch 'master' of http://10.1.235.20:3000/ipu/android-share.git

huangbo 8 年之前
父节点
当前提交
259e6b0d58

+ 2 - 0
display-server/etc/server-page.xml

@ -49,6 +49,8 @@
49 49
	<action name="VideoCompressor" template="template/webapp/plugin/VideoCompress.html"></action>
50 50
	<!-- 快捷菜单 -->
51 51
	<action name="PathMenu" template="template/webapp/plugin/PathMenu.html"></action>
52
	<!-- iframeDemo -->
53
	<action name="Iframe" template="template/webapp/plugin/iframe.html"></action>
52 54
	<!-- Web Component Demo-->
53 55
	<action name="WmTab" template="template/webapp/tag/WmTab.html"></action>
54 56
	<action name="WmTabbar" template="template/webapp/tag/WmTabbar.html"></action>

+ 88 - 0
display-server/web/biz/js/common/cross-frame.js

@ -0,0 +1,88 @@
1
define(function(require) {
2
	
3
	// 给子窗口回消息,参数是收到消息时的参数
4
	function sendMsg(event) {
5
		event.source.postMessage(event.data, event.origin);
6
	}
7

8
	function receiveMessage(event) {
9
//		confirm('01ireceive'+event);
10
		
11
		// 来源验证,可以用来判断消息来源是否是一个可信任的源,可根据情况是否需要处理,来源是一个domain地址到端口
12
		// if (event.origin !== "http://example.com:8080")
13
		//  return;
14

15
		var data = event.data;
16
//		confirm('idata'+data);
17

18
		if (!data) {
19
			data = {};
20
			data.code = -1;
21
			data.result = "event没有data";
22
			sendMsg(event);
23
			return;
24
		}
25

26
		var objName = data.objName;
27
		var method = data.method;
28
		var paras = data.paras;
29
		var callBackIndexs = data.callBackIndexs;
30
//		confirm(objName+'--'+method+'--'+paras+'--'+callBackIndexs);
31

32
		// todo检查参数
33
		if (!method) {
34
			data.code = -1;
35
			data.result = "data没有method";
36
			sendMsg(event);
37
			return;
38
		}
39

40
		// 不支持没参数的插件调用
41
		if (!paras || !paras.length) {
42
			data.code = -1;
43
			data.result = "data没有paras";
44
			sendMsg(event);
45
			return;
46
		}
47

48
		var localParas = paras.slice(0); // 复制数组,用来做本地调用
49

50
		// 将参数中原来函数位置值,替换成函数
51
		for ( var key in callBackIndexs) {
52
			var index = callBackIndexs[key];
53
			localParas[index] = (function(code) { // 将所有callBackIndexs对应索引定义成回调函数
54
				return function (){
55
					data.code = code;
56
					data.result = [];
57
					for (var i = 0, j = arguments.length; i < j; i++) {
58
						data.result.push(arguments[i]);
59
					}
60
					sendMsg(event);
61
				}
62
			})(index);
63
		}
64

65
		// TODO: 这个地方实现,怎么找到对象然后调用方法,可自定义相关实现,
66
		// 如果业务复杂,可专门定义一个模块,提供方法给子窗口调用
67
//		confirm('yes');
68
		var WadeMobile = require("wadeMobile");
69
		
70
		/*
71
		WadeMobile.getSysInfo.apply(WadeMobile, [function(info1){
72
			confirm("success"+info1);
73
		},'OSVERSION',function(){
74
			confirm();
75
		}]);
76
		*/
77
		
78
		var callObj = require(objName); 
79
		var callMethod = callObj[method];
80
		callMethod.apply(callObj, localParas);
81

82
		// 测试代码
83
		// var tempIndex = callBackIndexs[1];
84
		// localParas[tempIndex]("test", 12);
85
	}
86

87
	window.addEventListener("message", receiveMessage, false);
88
});

+ 1 - 0
display-server/web/biz/js/common/require-config.js

@ -4,5 +4,6 @@ require.config({
4 4
	paths:{
5 5
		'common' : 'common/common',
6 6
		'util' : 'common/util',
7
		'crossframe':'common/cross-frame'
7 8
	}
8 9
});

+ 4 - 1
display-server/web/res/js/mobile/wade-mobile.js

@ -330,14 +330,17 @@ define(["jcl","base64","res/js/mobile/expand-mobile.js","biz/js/common/biz-mobil
330 330
     * 重写alert方法,解决在iOS7以上不可点击问题
331 331
     * @param name
332 332
     */
333
	/**/
333 334
    window.alert = function(name){
335
    	
334 336
        var iframe = document.createElement("IFRAME");
335 337
        iframe.style.display="none";
336 338
        iframe.setAttribute("src", 'data:text/plain,');
337 339
        document.documentElement.appendChild(iframe);
338
        window.frames[0].window.alert(name);
340
        window.frames[window.frames.length-1].window.alert(name);
339 341
        iframe.parentNode.removeChild(iframe);
340 342
    }
343
    
341 344
	
342 345
	//动态执行js方法
343 346
	function _eval(code,action){

+ 4 - 0
display-server/web/template/webapp/PluginIndex.html

@ -89,4 +89,8 @@
89 89
		<div class="pic"><span class="e_ico-nfc"></span></div>
90 90
		<div class="text">快捷菜单</div>
91 91
	</li>
92
	<li action="Iframe">
93
		<div class="pic"><span class="e_ico-position"></span></div>
94
		<div class="text">IframeDemo</div>
95
	</li>
92 96
</ul>

+ 62 - 0
display-server/web/template/webapp/plugin/Iframe.html

@ -0,0 +1,62 @@
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1" />
6
<title>Iframe</title>
7
{%>template/common/Head.html%}
8
<style>
9
body{
10
	overflow:auto;
11
}
12
#testIframe, #testIframe2{
13
	height:100%;
14
	width:100%;
15
}
16
</style>
17
</head>
18
<body>
19
<h1>下面是iframe的内容</h1></div>
20
<h1>跨域iframe</h1>
21
<iframe id="testIframe2" src="http://10.13.13.32:8080/iframe/myindex2.html" ></iframe>
22
23
<script type="text/javascript">
24
	setTimeout(function(){
25
		var testIframe = top.document.getElementById('testIframe');
26
		//testIframe.parentNode.removeChild(testIframe);
27
		/* testIframe.src = "http://10.13.13.32:8080/iframe/myindex3.html"; */
28
		setTimeout(function(){
29
			for(var key in top.WadeMobileSet){
30
				if( key.indexOf("_WadeMobileSet_Key_") != -1){
31
					try{
32
						console.log("可被删除:" + key + top.WadeMobileSet[key].canRemoved());
33
					}catch(e){
34
						console.log("出错了:" + e);
35
					}
36
				}
37
			}
38
		},3000)
39
	},1000);
40
</script>
41
42
	<!-- <h1>同源iframe</h1>
43
	<iframe id="testIframe" src="mobile?action=Basic" ></iframe> -->
44
45
<script type="text/javascript">
46
requirejs(["wadeMobile","crossframe"], function(WadeMobile){
47
	WadeMobile.onMobileBackPressed = function(){
48
		alert("(top)返回事件中传递的信息为:" + paramObj.message);
49
		WadeMobile.close();
50
	}
51
});
52
var i =0;
53
function addSrc(ele){
54
	if(i>1){
55
		window.testIframe.src= 'mobile?action=Basic';
56
	}
57
	i++;
58
	ele.innerText = window.location.href;
59
}
60
</script>
61
</body>
62
</html>

+ 140 - 0
display-server/web/template/webapp/plugin/iframe/myindex3.html

@ -0,0 +1,140 @@
1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2
<html>
3
	<head>
4
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
		<meta content='True' name='HandheldFriendly' />
6
		<title></title>
7
		<!-- <script src="res/js/mobile-core.js"></script>
8
		<script src="res/js/zepto.js"></script>
9
		<script src="res/js/base64.js"></script>
10
		<script src="res/js/jcl.js"></script>
11
		<script src="res/js/wade-mobile.js"></script>
12
		<script src="res/js/expand-mobile.js"></script>
13
		<script src="biz/js/common/biz-mobile.js"></script> -->
14
		{%>template/common/Head.html%}
15
	</head>
16
	<body>
17
		<script type="text/javascript">
18
			//WadeMobile.tip("你好,我好,大家好………………");
19
		</script>
20
		<h1>同域调用</h1>
21
		<button style="width:200px;height:100px;" id="openContact">打开联系人(无回调)</button>
22
		<script type="text/javascript">
23
			require(['wadeMobile'], function(WadeMobile){
24
				window.WadeMobile = wadeMobile;
25
			});
26
			var btn = document.getElementById("openContact");
27
			btn.onclick = function(){
28
				//WadeMobile.openBrowser("http://3g.baidu.com");
29
				 WadeMobile.getContacts(function(result){
30
					alert(result.toString());
31
				});
32
			}
33
		</script>
34
		
35
		<button style="width:200px;height:100px;" id="openBrowser">打开浏览器(无回调)</button>
36
		<script type="text/javascript">
37
			var btn = document.getElementById("openBrowser");
38
			btn.onclick = function(){
39
				WadeMobile.openBrowser("http://3g.baidu.com");
40
			}
41
		</script>
42
		
43
		<br /><br />
44
		<button style="width:200px;height:100px;" id="getImei">获取手机IMEI号(回调)</button>
45
		<script type="text/javascript">
46
			var btn = document.getElementById("getImei");
47
			btn.onclick = function(){
48
				WadeMobile.getImei(function(result){
49
					alert("手机IMEI号为:" + result);
50
				},function(msg){
51
					alert("我是异常处理函数,来自android的异常信息为:" + msg)
52
				});
53
			}
54
		</script>
55
		
56
		<br /><br />
57
		<button style="width:200px;height:100px;" id="setMemoryCache">设置缓存</button>
58
		<script type="text/javascript">
59
			var btn = document.getElementById("setMemoryCache");
60
			btn.onclick = function(){
61
				alert('in setMemoryCache');
62
				WadeMobile.setMemoryCache("Key001","我是缓存中的测试值-Value001");
63
			}
64
		</script>
65
		
66
		<br /><br />
67
		<button style="width:200px;height:100px;" id="getMemoryCache">获取缓存</button>
68
		<script type="text/javascript">
69
			var btn = document.getElementById("getMemoryCache");
70
			btn.onclick = function(){
71
				alert('in getMemoryCache');
72
				WadeMobile.getMemoryCache(function(value){
73
					alert(value);
74
				},"Key001","没有取到值我,我是默认值");
75
			}
76
		</script>
77
		
78
		
79
		<br /><br />
80
		<button style="width: 200px;height: 100px;" id="sendAjaxPost">发送Post请求</button>
81
		<script type="text/javascript">
82
			var btn = document.getElementById("sendAjaxPost");
83
			btn.onclick = function(){
84
				//创建XMLHttpRequest对象
85
				xhr = new XMLHttpRequest();
86
				//注册回调函数
87
				xhr.onreadystatechange=callback;
88
				//第一个参数设置成post,第二个写url地址,第三个为是否采用异步方式
89
				xhr.open("POST","data",true);
90
				//post请求需要自己设置请求头
91
				xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
92
				//post请求
93
				xhr.send("name=lisi");
94
			}
95
			function callback(){
96
				//接收响应数据
97
				//判断对象状态是否交互完成,如果为4则交互完成
98
				if(xhr.readyState == 4){
99
					//判断对象状态是否交互成功,如果成功则为200
100
					if(xhr.status == 200){
101
						//接收数据,得到服务器输出的纯属文本数据
102
						var response = xhr.responseText;
103
						alert("返回的数据为:" + response);
104
					}
105
				}
106
			}
107
		</script>
108
		
109
		
110
		<br /><br />
111
		<button style="width:200px;height:100px;" id="goCustomerCentre">跳转到CustomerCentre</button>
112
		<script type="text/javascript">
113
			var btn = document.getElementById("goCustomerCentre");
114
			btn.onclick = function(){
115
				window.location.href="http://10.0.2.2:8080/start";
116
			}
117
		</script>
118
		<br /><br />
119
		<input type="text" style="width: 200px;height: 100px;">
120
		
121
		<script type="text/javascript">
122
			window.WadeMobile.onMobileBackPressed = function(paramObj){
123
				if(!paramObj.isRemoved){
124
					alert("返回键被点击了。在这里可以执行相应的s方法。下面将从父页面中移除本iframe!"
125
							+ "onMobileBackPressed方法返回值为false时,将允许返回键事件继续传播,"
126
							+ "onMobileBackPressed方法返回值为true时,表示已经处理完此返回键事件,本次事件将终止传播。");
127
					alert("返回事件中传递的信息为:" + paramObj.message);
128
					//修改paramObj对象中的信息属性
129
					paramObj.message = "被iframe修改过的message -- 工号'myindex3'";
130
					var testIframe = top.document.getElementById('testIframe2');
131
					paramObj.isRemoved = true;
132
					if(testIframe){
133
						testIframe.parentNode.removeChild(testIframe);
134
					}
135
					return false;
136
				}
137
			}
138
		</script>
139
	</body>
140
</html>

+ 55 - 41
general-web-server/web/myindex2.html

@ -3,29 +3,46 @@
3 3
	<head>
4 4
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 5
		<meta content='True' name='HandheldFriendly' />
6
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
7 6
		<title></title>
8
		<script src="res/js/mobile-core.js"></script>
9 7
		<script src="res/js/zepto.js"></script>
10
		<script src="res/js/base64.js"></script>
11
		<script src="res/js/jcl.js"></script>
12
		<script src="res/js/wade-mobile.js"></script>
13
		<script src="res/js/expand-mobile.js"></script>
14
		<script src="biz/js/common/biz-mobile.js"></script>
8
		<script src="res/js/sendmsg.js"></script>
15 9
	</head>
16 10
	<body>
17 11
		<script type="text/javascript">
18 12
			//WadeMobile.tip("你好,我好,大家好………………");
19 13
		</script>
20
		<h1>myindex2</h1>
14
		<h1>跨域调用</h1>
15
		<button style="width:200px;height:100px;" id="openContacts">打开联系人(无回调)</button>
16
		<script type="text/javascript">
17
		/* 	alert('child alert'); */
18
		
19
			var btn = document.getElementById("openContacts");
20
			btn.onclick = function(){
21
				//WadeMobile.openBrowser("http://3g.baidu.com");
22
				var msg = {
23
						objName : "wadeMobile",
24
						method : "getContacts",
25
						paras : [function(result){
26
							alert(result.toString())
27
							}]
28
				}
29
				sendMsg(msg);
30
			}
31
		</script>
32
		
33
		<br /><br />
21 34
		<button style="width:200px;height:100px;" id="openBrowser">打开浏览器(无回调)</button>
22 35
		<script type="text/javascript">
36
		/* 	alert('child alert'); */
37
		
23 38
			var btn = document.getElementById("openBrowser");
24 39
			btn.onclick = function(){
25
				//WadeMobile.openBrowser("http://3g.baidu.com");
26
				 WadeMobile.getContacts(function(result){
27
					alert(result.toString());
28
				});
40
				var msg = {
41
						objName:"wadeMobile",
42
						method:"openBrowser",
43
						paras:["http://3g.baidu.com"]
44
				}
45
				sendMsg(msg);
29 46
			}
30 47
		</script>
31 48
		
@ -34,11 +51,16 @@
34 51
		<script type="text/javascript">
35 52
			var btn = document.getElementById("getImei");
36 53
			btn.onclick = function(){
37
				WadeMobile.getImei(function(result){
38
					alert("手机IMEI号为:" + result);
39
				},function(msg){
40
					alert("我是异常处理函数,来自android的异常信息为:" + msg)
41
				});
54
				var msg = {
55
						objName : "wadeMobile",
56
						method : "getSysInfo",
57
						paras : [ function(name) {
58
							alert('手机IMEI号:'+name);
59
						}, 'IMEI', function(name, t){
60
							alert("callback error");
61
						}]
62
					};
63
					sendMsg(msg);
42 64
			}
43 65
		</script>
44 66
		
@ -48,7 +70,12 @@
48 70
		<script type="text/javascript">
49 71
			var btn = document.getElementById("setMemoryCache");
50 72
			btn.onclick = function(){
51
				WadeMobile.setMemoryCache("Key001","我是缓存中的测试值-Value001");
73
				var msg = {
74
						objName:"wadeMobile",
75
						method:"setMemoryCache",
76
						paras:["Key001","我是缓存中的测试值-Value001"]
77
				};
78
				sendMsg(msg);
52 79
			}
53 80
		</script>
54 81
		
@ -57,14 +84,18 @@
57 84
		<script type="text/javascript">
58 85
			var btn = document.getElementById("getMemoryCache");
59 86
			btn.onclick = function(){
60
				WadeMobile.getMemoryCache(function(value){
61
					alert(value);
62
				},"Key001","没有取到值我,我是默认值");
87
				var msg = {
88
						objName:"wadeMobile",
89
						method:"getMemoryCache",
90
						paras:[function(value){
91
								alert(value);},"Key001","没有取到值我,我是默认值"]
92
				};
93
				sendMsg(msg);
63 94
			}
64 95
		</script>
65 96
		
66 97
		
67
		<br /><br />
98
	<!-- 	<br /><br />
68 99
		<button style="width: 200px;height: 100px;" id="sendAjaxPost">发送Post请求</button>
69 100
		<script type="text/javascript">
70 101
			var btn = document.getElementById("sendAjaxPost");
@ -104,25 +135,8 @@
104 135
			}
105 136
		</script>
106 137
		<br /><br />
107
		<input type="text" style="width: 200px;height: 100px;">
138
		<input type="text" style="width: 200px;height: 100px;"> -->
139
		
108 140
		
109
		<script type="text/javascript">
110
			window.WadeMobile.onMobileBackPressed = function(paramObj){
111
				if(!paramObj.isRemoved){
112
					alert("返回键被点击了。在这里可以执行相应的s方法。下面将从父页面中移除本iframe!"
113
							+ "onMobileBackPressed方法返回值为false时,将允许返回键事件继续传播,"
114
							+ "onMobileBackPressed方法返回值为true时,表示已经处理完此返回键事件,本次事件将终止传播。");
115
					alert("返回事件中传递的信息为:" + paramObj.message);
116
					//修改paramObj对象中的信息属性
117
					paramObj.message = "被iframe修改过的message -- 工号'myindex2'";
118
					var testIframe = top.document.getElementById('testIframe2');
119
					paramObj.isRemoved = true;
120
					if(testIframe){
121
						testIframe.parentNode.removeChild(testIframe);
122
					}
123
					return false;
124
				}
125
			}
126
		</script>
127 141
	</body>
128 142
</html>

+ 128 - 0
general-web-server/web/myindex2.html.bak

@ -0,0 +1,128 @@
1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2
<html>
3
	<head>
4
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
		<meta content='True' name='HandheldFriendly' />
6
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
7
		<title></title>
8
		<script src="res/js/mobile-core.js"></script>
9
		<script src="res/js/zepto.js"></script>
10
		<script src="res/js/base64.js"></script>
11
		<script src="res/js/jcl.js"></script>
12
		<script src="res/js/wade-mobile.js"></script>
13
		<script src="res/js/expand-mobile.js"></script>
14
		<script src="biz/js/common/biz-mobile.js"></script>
15
	</head>
16
	<body>
17
		<script type="text/javascript">
18
			//WadeMobile.tip("你好,我好,大家好………………");
19
		</script>
20
		<h1>myindex2</h1>
21
		<button style="width:200px;height:100px;" id="openBrowser">打开浏览器(无回调)</button>
22
		<script type="text/javascript">
23
			var btn = document.getElementById("openBrowser");
24
			btn.onclick = function(){
25
				//WadeMobile.openBrowser("http://3g.baidu.com");
26
				 WadeMobile.getContacts(function(result){
27
					alert(result.toString());
28
				});
29
			}
30
		</script>
31
		
32
		<br /><br />
33
		<button style="width:200px;height:100px;" id="getImei">获取手机IMEI号(回调)</button>
34
		<script type="text/javascript">
35
			var btn = document.getElementById("getImei");
36
			btn.onclick = function(){
37
				WadeMobile.getImei(function(result){
38
					alert("手机IMEI号为:" + result);
39
				},function(msg){
40
					alert("我是异常处理函数,来自android的异常信息为:" + msg)
41
				});
42
			}
43
		</script>
44
		
45
		
46
		<br /><br />
47
		<button style="width:200px;height:100px;" id="setMemoryCache">设置缓存</button>
48
		<script type="text/javascript">
49
			var btn = document.getElementById("setMemoryCache");
50
			btn.onclick = function(){
51
				WadeMobile.setMemoryCache("Key001","我是缓存中的测试值-Value001");
52
			}
53
		</script>
54
		
55
		<br /><br />
56
		<button style="width:200px;height:100px;" id="getMemoryCache">获取缓存</button>
57
		<script type="text/javascript">
58
			var btn = document.getElementById("getMemoryCache");
59
			btn.onclick = function(){
60
				WadeMobile.getMemoryCache(function(value){
61
					alert(value);
62
				},"Key001","没有取到值我,我是默认值");
63
			}
64
		</script>
65
		
66
		
67
		<br /><br />
68
		<button style="width: 200px;height: 100px;" id="sendAjaxPost">发送Post请求</button>
69
		<script type="text/javascript">
70
			var btn = document.getElementById("sendAjaxPost");
71
			btn.onclick = function(){
72
				//创建XMLHttpRequest对象
73
				xhr = new XMLHttpRequest();
74
				//注册回调函数
75
				xhr.onreadystatechange=callback;
76
				//第一个参数设置成post,第二个写url地址,第三个为是否采用异步方式
77
				xhr.open("POST","data",true);
78
				//post请求需要自己设置请求头
79
				xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
80
				//post请求
81
				xhr.send("name=lisi");
82
			}
83
			function callback(){
84
				//接收响应数据
85
				//判断对象状态是否交互完成,如果为4则交互完成
86
				if(xhr.readyState == 4){
87
					//判断对象状态是否交互成功,如果成功则为200
88
					if(xhr.status == 200){
89
						//接收数据,得到服务器输出的纯属文本数据
90
						var response = xhr.responseText;
91
						alert("返回的数据为:" + response);
92
					}
93
				}
94
			}
95
		</script>
96
		
97
		
98
		<br /><br />
99
		<button style="width:200px;height:100px;" id="goCustomerCentre">跳转到CustomerCentre</button>
100
		<script type="text/javascript">
101
			var btn = document.getElementById("goCustomerCentre");
102
			btn.onclick = function(){
103
				window.location.href="http://10.0.2.2:8080/start";
104
			}
105
		</script>
106
		<br /><br />
107
		<input type="text" style="width: 200px;height: 100px;">
108
		
109
		<script type="text/javascript">
110
			window.WadeMobile.onMobileBackPressed = function(paramObj){
111
				if(!paramObj.isRemoved){
112
					alert("返回键被点击了。在这里可以执行相应的s方法。下面将从父页面中移除本iframe!"
113
							+ "onMobileBackPressed方法返回值为false时,将允许返回键事件继续传播,"
114
							+ "onMobileBackPressed方法返回值为true时,表示已经处理完此返回键事件,本次事件将终止传播。");
115
					alert("返回事件中传递的信息为:" + paramObj.message);
116
					//修改paramObj对象中的信息属性
117
					paramObj.message = "被iframe修改过的message -- 工号'myindex2'";
118
					var testIframe = top.document.getElementById('testIframe2');
119
					paramObj.isRemoved = true;
120
					if(testIframe){
121
						testIframe.parentNode.removeChild(testIframe);
122
					}
123
					return false;
124
				}
125
			}
126
		</script>
127
	</body>
128
</html>

+ 17 - 7
general-web-server/web/myindex3.html

@ -3,24 +3,25 @@
3 3
	<head>
4 4
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 5
		<meta content='True' name='HandheldFriendly' />
6
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
7 6
		<title></title>
8
		<script src="res/js/mobile-core.js"></script>
7
		<!-- <script src="res/js/mobile-core.js"></script>
9 8
		<script src="res/js/zepto.js"></script>
10 9
		<script src="res/js/base64.js"></script>
11 10
		<script src="res/js/jcl.js"></script>
12 11
		<script src="res/js/wade-mobile.js"></script>
13 12
		<script src="res/js/expand-mobile.js"></script>
14
		<script src="biz/js/common/biz-mobile.js"></script>
13
		<script src="biz/js/common/biz-mobile.js"></script> -->
14
		<script type="text/javascript"/>	
15 15
	</head>
16
	
16 17
	<body>
17 18
		<script type="text/javascript">
18 19
			//WadeMobile.tip("你好,我好,大家好………………");
19 20
		</script>
20
		<h1>myindex3</h1>
21
		<button style="width:200px;height:100px;" id="openBrowser">打开浏览器(无回调)</button>
21
		<h1>同域调用</h1>
22
		<button style="width:200px;height:100px;" id="openContact">打开联系人(无回调)</button>
22 23
		<script type="text/javascript">
23
			var btn = document.getElementById("openBrowser");
24
			var btn = document.getElementById("openContact");
24 25
			btn.onclick = function(){
25 26
				//WadeMobile.openBrowser("http://3g.baidu.com");
26 27
				 WadeMobile.getContacts(function(result){
@ -29,6 +30,14 @@
29 30
			}
30 31
		</script>
31 32
		
33
		<button style="width:200px;height:100px;" id="openBrowser">打开浏览器(无回调)</button>
34
		<script type="text/javascript">
35
			var btn = document.getElementById("openBrowser");
36
			btn.onclick = function(){
37
				WadeMobile.openBrowser("http://3g.baidu.com");
38
			}
39
		</script>
40
		
32 41
		<br /><br />
33 42
		<button style="width:200px;height:100px;" id="getImei">获取手机IMEI号(回调)</button>
34 43
		<script type="text/javascript">
@ -42,12 +51,12 @@
42 51
			}
43 52
		</script>
44 53
		
45
		
46 54
		<br /><br />
47 55
		<button style="width:200px;height:100px;" id="setMemoryCache">设置缓存</button>
48 56
		<script type="text/javascript">
49 57
			var btn = document.getElementById("setMemoryCache");
50 58
			btn.onclick = function(){
59
				alert('in setMemoryCache');
51 60
				WadeMobile.setMemoryCache("Key001","我是缓存中的测试值-Value001");
52 61
			}
53 62
		</script>
@ -57,6 +66,7 @@
57 66
		<script type="text/javascript">
58 67
			var btn = document.getElementById("getMemoryCache");
59 68
			btn.onclick = function(){
69
				alert('in getMemoryCache');
60 70
				WadeMobile.getMemoryCache(function(value){
61 71
					alert(value);
62 72
				},"Key001","没有取到值我,我是默认值");

+ 128 - 0
general-web-server/web/myindex3.html.bak

@ -0,0 +1,128 @@
1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2
<html>
3
	<head>
4
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
		<meta content='True' name='HandheldFriendly' />
6
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
7
		<title></title>
8
		<script src="res/js/mobile-core.js"></script>
9
		<script src="res/js/zepto.js"></script>
10
		<script src="res/js/base64.js"></script>
11
		<script src="res/js/jcl.js"></script>
12
		<script src="res/js/wade-mobile.js"></script>
13
		<script src="res/js/expand-mobile.js"></script>
14
		<script src="biz/js/common/biz-mobile.js"></script>
15
	</head>
16
	<body>
17
		<script type="text/javascript">
18
			//WadeMobile.tip("你好,我好,大家好………………");
19
		</script>
20
		<h1>myindex3</h1>
21
		<button style="width:200px;height:100px;" id="openBrowser">打开浏览器(无回调)</button>
22
		<script type="text/javascript">
23
			var btn = document.getElementById("openBrowser");
24
			btn.onclick = function(){
25
				//WadeMobile.openBrowser("http://3g.baidu.com");
26
				 WadeMobile.getContacts(function(result){
27
					alert(result.toString());
28
				});
29
			}
30
		</script>
31
		
32
		<br /><br />
33
		<button style="width:200px;height:100px;" id="getImei">获取手机IMEI号(回调)</button>
34
		<script type="text/javascript">
35
			var btn = document.getElementById("getImei");
36
			btn.onclick = function(){
37
				WadeMobile.getImei(function(result){
38
					alert("手机IMEI号为:" + result);
39
				},function(msg){
40
					alert("我是异常处理函数,来自android的异常信息为:" + msg)
41
				});
42
			}
43
		</script>
44
		
45
		
46
		<br /><br />
47
		<button style="width:200px;height:100px;" id="setMemoryCache">设置缓存</button>
48
		<script type="text/javascript">
49
			var btn = document.getElementById("setMemoryCache");
50
			btn.onclick = function(){
51
				WadeMobile.setMemoryCache("Key001","我是缓存中的测试值-Value001");
52
			}
53
		</script>
54
		
55
		<br /><br />
56
		<button style="width:200px;height:100px;" id="getMemoryCache">获取缓存</button>
57
		<script type="text/javascript">
58
			var btn = document.getElementById("getMemoryCache");
59
			btn.onclick = function(){
60
				WadeMobile.getMemoryCache(function(value){
61
					alert(value);
62
				},"Key001","没有取到值我,我是默认值");
63
			}
64
		</script>
65
		
66
		
67
		<br /><br />
68
		<button style="width: 200px;height: 100px;" id="sendAjaxPost">发送Post请求</button>
69
		<script type="text/javascript">
70
			var btn = document.getElementById("sendAjaxPost");
71
			btn.onclick = function(){
72
				//创建XMLHttpRequest对象
73
				xhr = new XMLHttpRequest();
74
				//注册回调函数
75
				xhr.onreadystatechange=callback;
76
				//第一个参数设置成post,第二个写url地址,第三个为是否采用异步方式
77
				xhr.open("POST","data",true);
78
				//post请求需要自己设置请求头
79
				xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
80
				//post请求
81
				xhr.send("name=lisi");
82
			}
83
			function callback(){
84
				//接收响应数据
85
				//判断对象状态是否交互完成,如果为4则交互完成
86
				if(xhr.readyState == 4){
87
					//判断对象状态是否交互成功,如果成功则为200
88
					if(xhr.status == 200){
89
						//接收数据,得到服务器输出的纯属文本数据
90
						var response = xhr.responseText;
91
						alert("返回的数据为:" + response);
92
					}
93
				}
94
			}
95
		</script>
96
		
97
		
98
		<br /><br />
99
		<button style="width:200px;height:100px;" id="goCustomerCentre">跳转到CustomerCentre</button>
100
		<script type="text/javascript">
101
			var btn = document.getElementById("goCustomerCentre");
102
			btn.onclick = function(){
103
				window.location.href="http://10.0.2.2:8080/start";
104
			}
105
		</script>
106
		<br /><br />
107
		<input type="text" style="width: 200px;height: 100px;">
108
		
109
		<script type="text/javascript">
110
			window.WadeMobile.onMobileBackPressed = function(paramObj){
111
				if(!paramObj.isRemoved){
112
					alert("返回键被点击了。在这里可以执行相应的s方法。下面将从父页面中移除本iframe!"
113
							+ "onMobileBackPressed方法返回值为false时,将允许返回键事件继续传播,"
114
							+ "onMobileBackPressed方法返回值为true时,表示已经处理完此返回键事件,本次事件将终止传播。");
115
					alert("返回事件中传递的信息为:" + paramObj.message);
116
					//修改paramObj对象中的信息属性
117
					paramObj.message = "被iframe修改过的message -- 工号'myindex3'";
118
					var testIframe = top.document.getElementById('testIframe2');
119
					paramObj.isRemoved = true;
120
					if(testIframe){
121
						testIframe.parentNode.removeChild(testIframe);
122
					}
123
					return false;
124
				}
125
			}
126
		</script>
127
	</body>
128
</html>

+ 56 - 0
general-web-server/web/res/js/sendmsg.js

@ -0,0 +1,56 @@
1
	/**
2
	 * paras里面的项属性或子属性值不能为函数,如 paras:[function(){}, {action:function(){}}];
3
	 * 上面paras,数组第一项function(){}是没问题的,代码已做处理,第二项 {action:function(){}} 会有问题
4
	 * 
5
	 * options = {
6
	 * 	objName:str, // 父窗口中,模块名称,必需
7
	 * 	method:str	 // 要调用的模块方法,必需
8
	 * 	paras:array  // 调用方法所需参数,数组格式,必需,
9
	 * }
10
	 */
11
	var sendMsg = (function() {
12
		var callBackInfos = {}; // 存储需要回调的方法
13
		var uid = 0; // id索引,自增
14

15
		function sendMsg(options) {
16
			// 可做一些基础参数检查,检查参数是否齐全
17

18
			var paras = options.paras;
19
			var localId = options.id = uid++; // 进行编号
20
			var callBacks = callBackInfos[localId] = {};
21
			var callBackIndexs = options.callBackIndexs = [];
22
			
23
			// 若是方法就需要进行替换,因为postMessage不支持传递函数对象
24
			for ( var key in paras) { 
25
				if (typeof paras[key] == "function") {
26
					callBacks[key] = paras[key];
27
					paras[key] = 'function'; // 将function修改为字符串'function'
28
					callBackIndexs.push(key); // 记录下标
29
				}
30
			}
31
			window.parent.postMessage(options, "*"); // 给父窗口发消息,*任何域名domain
32
//			alert('send');
33
		}
34
			
35
		function receiveMessage(event) {
36
			console.dir(event);
37
//			alert('receive');
38
//			alert('child receive'+event);
39
//			alert(JSON.stringify(event.data));
40
			var data = event.data;
41
			var code = data.code;
42

43
			if (code >= 0) { // 大于0表示调用成功
44
				var localId = data.id;
45
				var result = data.result;
46
				callBackInfos[localId][code].apply(this, result);
47
				delete callBackInfos[localId]; // 移除相关信息
48
			} else {
49
				// 表示参数验正失败, 此处理自己处理
50
				alert('invalid:'+data.result);
51
			}
52
		}
53

54
		window.addEventListener("message", receiveMessage, false);
55
		return sendMsg;
56
	})();

+ 2 - 0
general-web-server/web/res/js/wade-mobile.js

@ -381,6 +381,7 @@ window.Mobile = window.WadeMobile = (function() {
381 381
		return;
382 382
	}
383 383
	
384
	/*
384 385
	if(top != window){
385 386
		if(top.WadeMobileSet == undefined){
386 387
			top.WadeMobileSet = {};
@ -407,4 +408,5 @@ window.Mobile = window.WadeMobile = (function() {
407 408
			return !window;
408 409
		};
409 410
	}
411
	*/
410 412
})();

二进制
wade-mobile-func/libs/wade-mobile.jar


二进制
wade-mobile-library/common/ipu-basic-1.0.jar