forked from carzygod/wechatmpc-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqr.html
More file actions
152 lines (143 loc) · 3.79 KB
/
qr.html
File metadata and controls
152 lines (143 loc) · 3.79 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>连接钱包</title>
<!-- 引入 QRCode.js 库 -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
background: #001f3f;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
margin: 0;
padding: 20px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100vh;
color: #ffffff;
}
.card {
background: #0a2540;
padding: 30px;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0,0,0,0.5);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
max-width: 600px;
width: 100%;
margin-bottom: 30px;
}
.card h1 {
margin: 0 0 20px;
font-size: 24px;
font-weight: normal;
}
button {
background-color: #007BFF;
border: none;
border-radius: 4px;
color: #fff;
padding: 12px 24px;
font-size: 16px;
cursor: pointer;
transition: background-color 0.3s ease;
margin-top: 20px;
}
button:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class="card">
<h1>Wechat</h1>
<div id="qrcode1"></div>
<button id="confirmBtn1">Mobile Continue</button>
</div>
<div class="card">
<h1>Alipay</h1>
<div id="qrcode2"></div>
<button id="confirmBtn2">Mobile Continue</button>
</div>
<script>
async function check_request_action(uuid){
try{
return (await fetch('https://mpcapi.sidcloud.cn/result/'+uuid,{
method: "GET",
headers: {},
redirect: 'follow'
})).json()
}catch(e)
{
console.error(e)
return false;
}
}
async function sleep (ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}
async function loopCheck(uuid) {
for(var i = 0 ; i < 100 ; i++)
{
const ret = await check_request_action(uuid)
if(ret?.data)
{
try{
window.close()
}catch(e)
{
console.error(e)
}
}
await sleep(1000)
}
return {
status:false,
reason:"user operation timeout"
}
}
const urlParams = new URLSearchParams(window.location.search);
const token = urlParams.get('token');
const uuid = urlParams.get("uuid")
// const targetUrl = token ? `https://a.com/${token}` : "https://a.com/";
const wechatUrl = `https://mpcapi.sidcloud.cn/wechat/dl/${token}`
const alipayUrl = `https://ds.alipay.com/?scheme=` + encodeURIComponent(`alipays://platformapi/startapp?appId=2021005129619947&page=pages/index/index&query=${token}`);
new QRCode(document.getElementById("qrcode1"), {
text: wechatUrl,
width: 200,
height: 200,
colorDark : "#ffffff",
colorLight : "#0a2540",
correctLevel : QRCode.CorrectLevel.H
});
new QRCode(document.getElementById("qrcode2"), {
text: alipayUrl,
width: 200,
height: 200,
colorDark : "#ffffff",
colorLight : "#0a2540",
correctLevel : QRCode.CorrectLevel.L
});
document.getElementById("confirmBtn1").addEventListener("click", function() {
window.location.href = wechatUrl;
});
document.getElementById("confirmBtn2").addEventListener("click", function() {
window.location.href = alipayUrl;
});
async function init(){
if(uuid)
{
await loopCheck(uuid)
}
}
init()
</script>
</body>
</html>