Przeglądaj źródła

远程app模式——ios支持

tik5213 9 lat temu
rodzic
commit
3c5dd0da49

+ 0 - 42
general-web-server/web/myindex.html

@ -18,17 +18,6 @@
18 18
			//WadeMobile.tip("你好,我好,大家好………………");
19 19
		</script>
20 20
		<h1>myindex</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 21
		<br /><br />
33 22
		<button style="width:200px;height:100px;" id="getImei">获取手机IMEI号(回调)</button>
34 23
		<script type="text/javascript">
@ -93,36 +82,5 @@
93 82
				}
94 83
			}
95 84
		</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 -- 工号'myindex'";
118
					var testIframe = top.document.getElementById('testIframe');
119
					paramObj.isRemoved = true;
120
					if(testIframe){
121
						testIframe.parentNode.removeChild(testIframe);
122
					}
123
					return false;
124
				}
125
			}
126
		</script>
127 85
	</body>
128 86
</html>

+ 128 - 0
general-web-server/web/myindex.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>myindex</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 -- 工号'myindex'";
118
					var testIframe = top.document.getElementById('testIframe');
119
					paramObj.isRemoved = true;
120
					if(testIframe){
121
						testIframe.parentNode.removeChild(testIframe);
122
					}
123
					return false;
124
				}
125
			}
126
		</script>
127
	</body>
128
</html>

+ 8 - 1
general-web-server/web/res/js/wade-mobile.js

@ -118,6 +118,7 @@ window.Mobile = window.WadeMobile = (function() {
118 118
			tmpKey += window._WadeMobileSet_Key_;
119 119
		}
120 120
        var callbackKey = globalErrorKey = tmpKey;
121
        
121 122
        if (success || error) {
122 123
    		callbacks[callbackKey] = {success:success, error:error};
123 124
        }
@ -130,7 +131,13 @@ window.Mobile = window.WadeMobile = (function() {
130 131
	};
131 132
 
132 133
    var iosExecute = function(action, args, error, success){
133
        var callbackKey = globalErrorKey = action+callbackId++;
134
		//执行回调方法时,回调方法的key值为,回调方法实际的key值 + 本iframe上保持的WadeMobile在top上的唯一标识
135
		var tmpKey = action+callbackId++;
136
		if(window._WadeMobileSet_Key_ != undefined){
137
			tmpKey += window._WadeMobileSet_Key_;
138
		}
139
		var callbackKey = globalErrorKey = tmpKey;
140
		
134 141
        if (success || error) {
135 142
            callbacks[callbackKey] = {success:success, error:error};
136 143
        }