forked from zhaomenghuan/mui-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
92 lines (85 loc) · 2.73 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>openQQ</title>
<link rel="stylesheet" type="text/css" href="css/mui.css"/>
</head>
<body>
<div class="mui-content mui-content-padded">
<button id="show" type="button" class="mui-btn mui-btn-blue mui-btn-block">按钮</button>
</div>
<script src="js/mui.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
var os = {
android: false,
ios: false,
plus: false,
stream: false,
qihoo: false,
wkwebview: false
};
var ua = navigator.userAgent;
if (ua.match(/(Android);?[\s\/]+([\d.]+)?/)) {
os.android = true;
} else if (ua.match(/(iPhone\sOS)\s([\d_]+)/)) {
os.ios = true;
if (window.webkit && window.webkit.messageHandlers) {
os.wkwebview = true;
}
}
if (ua.match(/Html5Plus/i)) {
os.plus = true;
if (ua.match(/StreamApp/i)) {
os.stream = true;
if (ua.match(/Qihoo/i)) {
os.qihoo = true;
}
}
}
var openQQ = function(qq) {
var url = null;
if (os.android) {
url = "mqqwpa://im/chat?chat_type=wpa&uin="+qq;
if(os.plus){
plus.runtime.openURL(url,function(e) {
plus.nativeUI.confirm("检查到您未安装QQ,请先到应用商店搜索下载?", function(i) {
if (i.index == 0) {
androidMarket("com.tencent.mobileqq");
}
});
});
}else{
var el = document.createElement("a");
el.href = url;
document.body.appendChild(el);
var evt = document.createEvent("HTMLEvents");
evt.initEvent("click", false, false);
el.dispatchEvent(evt);
}
} else if (os.ios) {
url = "mqq://im/chat?chat_type=wpa&uin="+qq+"&version=1&src_type=web";
if(os.plus){
plus.runtime.openURL(url,function(e) {
plus.nativeUI.confirm("检查到您未安装qq,请先到appstore搜索下载?", function(i) {
if (i.index == 0) {
iosAppstore("itunes.apple.com/cn/app/mqq/");
}
});
});
}else{
var el = document.createElement("a");
el.href = url;
document.body.appendChild(el);
var evt = document.createEvent("HTMLEvents");
evt.initEvent("click", false, false);
el.dispatchEvent(evt);
}
}
}
document.querySelector('#show').addEventListener('tap',function () {
openQQ('1028317108');
})
</script>
</body>
</html>