-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
58 lines (57 loc) · 2.05 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
<!DOCTYPE html>
<html lang="cn">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Pay</title>
<style>
#code-wechat {
text-align: center;
margin: 20% 7%;
}
img {
max-width: 70%;
max-height: 70%;
}
.prompt {
margin: 10%;
font-size: 120%;
}
</style>
</head>
<body>
<div id="code-wechat" style="display:none">
<div class="prompt">长按识别以下二维码付款</div>
<img id="wechat-url" />
</div>
<script>
var setting = {
wechatUrl: "wxp://f2f0sZ9Nv3BIYSI8kIWw5BPWy73hIM8if8MM",
aliUrl: "https://qr.alipay.com/fkx08267fw3lrqorwtkz649",
qrcodeApi: "https://api.qrserver.com/v1/create-qr-code/?data="
};
if (
!/^http(s*):\/\//.test(location.href) ||
/^http(s*):\/\/localhost/.test(location.href)
) {
alert("在本地打开无效,请上传到GitHub/GitLab或静态网站!");
}
if (navigator.userAgent.match(/Alipay/i)) {
window.location.href = setting.aliUrl;
} else if (navigator.userAgent.match(/MicroMessenger\//i)) {
document.getElementById("code-wechat").style.display = "block";
document.getElementById("wechat-url").src =
setting.qrcodeApi + urlEncode(setting.wechatUrl);
document.getElementById("code-wechat").style.display = "block";
} else {
alert("请使用支付宝或微信扫描二维码!")
}
function urlEncode(String) {
return encodeURIComponent(String)
.replace(/'/g, "%27")
.replace(/"/g, "%22");
}
</script>
</body>
</html>