|
@ -4,15 +4,26 @@
|
4
|
4
|
define(["jcl","base64","res/js/mobile/expand-mobile.js","biz/js/common/biz-mobile.js"],function(Wade,Base64) {
|
5
|
5
|
//终端类型,a为android,i为ios
|
6
|
6
|
var deviceType = (function(){
|
7
|
|
var sUserAgent = navigator.userAgent.toLowerCase();
|
8
|
|
var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
|
9
|
|
var bIsIphone = sUserAgent.match(/iphone os/i) == "iphone os";
|
10
|
|
var bIsAndroid = sUserAgent.match(/android/i) == "android";
|
11
|
|
var bIsWinphone = sUserAgent.match(/windows phone /i) == "windows phone " || sUserAgent.match(/windows phone os /i) == "windows phone os ";
|
12
|
|
if(bIsAndroid){
|
13
|
|
return "a";
|
14
|
|
}else if(bIsIpad||bIsIphone){
|
15
|
|
return "i";
|
|
7
|
/*
|
|
8
|
IpuMobile/i1/android/00/2.0/Hybrid
|
|
9
|
userAgent格式
|
|
10
|
i1版本规范:
|
|
11
|
标识符/规范版本号/终端类型(ios,android,wp)/终端型号(平板,或尺寸,00表示默认)/框架版本号/结尾标识符
|
|
12
|
*/
|
|
13
|
var sUserAgent = window.navigator.userAgent;
|
|
14
|
// 标识符 规范1 类型2 型号3 框架4 结尾标识符
|
|
15
|
var re = /IpuMobile\/(.*)\/(.*)\/(.*)\/(.*)\/Hybrid/ig
|
|
16
|
var arrMessages = re.exec(sUserAgent);
|
|
17
|
if(arrMessages && arrMessages[1] =="i1" ){
|
|
18
|
if(arrMessages[2] == "android"){
|
|
19
|
return "a";
|
|
20
|
}else if(arrMessages[2] == "ios"){
|
|
21
|
return "i"
|
|
22
|
}else if(arrMessages[2] == "wp"){
|
|
23
|
return "w";
|
|
24
|
}else{
|
|
25
|
return null;
|
|
26
|
}
|
16
|
27
|
}else{
|
17
|
28
|
return null;
|
18
|
29
|
}
|
|
@ -21,7 +32,6 @@ define(["jcl","base64","res/js/mobile/expand-mobile.js","biz/js/common/biz-mobil
|
21
|
32
|
window["TerminalType"] = deviceType;
|
22
|
33
|
}
|
23
|
34
|
var terminalType = window["TerminalType"];
|
24
|
|
|
25
|
35
|
WadeMobile = (function(){
|
26
|
36
|
return{
|
27
|
37
|
isAndroid:function(){
|
|
@ -31,7 +41,7 @@ define(["jcl","base64","res/js/mobile/expand-mobile.js","biz/js/common/biz-mobil
|
31
|
41
|
},isWP:function(){
|
32
|
42
|
return terminalType=='w';
|
33
|
43
|
},isApp:function(){//判断是否是APP应用
|
34
|
|
return terminalType!=null;
|
|
44
|
return !!terminalType;
|
35
|
45
|
},getSysInfo:function(callback,key,err){//TELNUMBER|IMEI|IMSI|SDKVERSION|OSVERSION|PLATFORM|SIMNUMBER
|
36
|
46
|
WadeMobile.callback.storageCallback("getSysInfo",callback);
|
37
|
47
|
execute("getSysInfo", [key],err);
|
|
@ -363,18 +373,33 @@ define(["jcl","base64","res/js/mobile/expand-mobile.js","biz/js/common/biz-mobil
|
363
|
373
|
//注意:在iframe中,_WadeMobileSet_Key_+时间戳表示一个key,此key作为了在top对象上索引iframe中的WadeMobile的依据。
|
364
|
374
|
//将保持引用的key值存入到当前ifame的window对象上。
|
365
|
375
|
(function(){
|
|
376
|
//屏蔽所有浏览器
|
|
377
|
if( window.navigator.userAgent.indexOf("IpuMobile\/") == -1 ) {
|
|
378
|
console.log("<WadeMobileSet> \"IpuMobile\/\" string does not exist in the userAgent. return.");
|
|
379
|
return;
|
|
380
|
}
|
|
381
|
|
366
|
382
|
if(top != window){
|
367
|
383
|
if(top.WadeMobileSet == undefined){
|
368
|
384
|
top.WadeMobileSet = {};
|
369
|
385
|
}
|
370
|
386
|
for(var key in top.WadeMobileSet){
|
371
|
|
if( key.indexOf("_WadeMobileSet_Key_") != -1 && ( top.WadeMobileSet[key] == undefined || top.WadeMobileSet[key].canRemoved() ) ){
|
|
387
|
try{
|
|
388
|
if( key.indexOf("_WadeMobileSet_Key_") != -1 && ( !top.WadeMobileSet[key] || ( top.WadeMobileSet[key].canRemoved && top.WadeMobileSet[key].canRemoved() ) ) ){
|
|
389
|
console.log("(top set)delete:" + key);
|
|
390
|
delete top.WadeMobileSet[key];
|
|
391
|
console.log("(top set)delete success :" + key);
|
|
392
|
}
|
|
393
|
}catch(e){
|
|
394
|
console.log("a error(WadeMobile) : " + e);
|
|
395
|
console.log("(top set)delete:" + key);
|
372
|
396
|
delete top.WadeMobileSet[key];
|
|
397
|
console.log("(top set)delete success :" + key);
|
373
|
398
|
}
|
374
|
399
|
}
|
375
|
400
|
var key = "_WadeMobileSet_Key_" + new Date().getTime();
|
376
|
401
|
window._WadeMobileSet_Key_ = key;
|
377
|
|
console.log("In an iframe, window.WadeMobile object is referenced top.WadeMobileSet." + key);
|
|
402
|
console.log("in an iframe, window.WadeMobile object is referenced top.WadeMobileSet." + key);
|
378
|
403
|
top.WadeMobileSet[key] = window.WadeMobile;
|
379
|
404
|
window.WadeMobile.canRemoved = function(){
|
380
|
405
|
return !window;
|