-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
202 lines (188 loc) · 6.4 KB
/
Copy pathindex.html
File metadata and controls
202 lines (188 loc) · 6.4 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>微信小程序跳转工具</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 500px;
margin: 50px auto;
padding: 20px;
background-color: #f5f5f5;
}
.container {
background-color: white;
padding: 30px;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
h1 {
text-align: center;
color: #333;
margin-bottom: 30px;
}
.form-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 5px;
font-weight: bold;
color: #555;
}
input[type="text"] {
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 5px;
font-size: 14px;
box-sizing: border-box;
}
.radio-group {
margin-bottom: 20px;
}
.radio-options {
display: flex;
gap: 20px;
margin-top: 10px;
}
.radio-option {
display: flex;
align-items: center;
gap: 5px;
}
input[type="radio"] {
margin: 0;
}
.env-warning {
margin-top: 10px;
color: #ff4757;
font-size: 12px;
font-weight: bold;
}
.param-tip {
margin-top: 5px;
color: #666;
font-size: 12px;
font-style: italic;
}
.jump-button {
width: 100%;
padding: 15px;
background-color: #07c160;
color: white;
border: none;
border-radius: 5px;
font-size: 16px;
font-weight: bold;
cursor: pointer;
transition: background-color 0.3s;
}
.jump-button:hover {
background-color: #06a050;
}
.preview {
margin-top: 20px;
padding: 15px;
background-color: #f8f9fa;
border-radius: 5px;
border-left: 4px solid #07c160;
}
.preview-title {
font-weight: bold;
margin-bottom: 10px;
color: #333;
}
.preview-url {
word-break: break-all;
font-family: monospace;
font-size: 12px;
color: #666;
}
</style>
</head>
<body>
<div class="container">
<h1>微信小程序跳转工具</h1>
<div class="form-group">
<label for="appid">appid:</label>
<input type="text" id="appid" value="wx8d886c6f1cff8d28" oninput="updatePreview()">
</div>
<div class="form-group">
<label for="pagePath">页面路径:</label>
<input type="text" id="pagePath" value="pages/home/homePage" oninput="updatePreview()">
</div>
<div class="form-group">
<label for="params">参数:</label>
<input type="text" id="params" value="channel=1" oninput="updatePreview()">
<div class="param-tip">
多个参数用&连接,如:channel=1&name=测试&id=123
</div>
</div>
<div class="radio-group">
<label>环境版本:</label>
<div class="radio-options">
<div class="radio-option">
<input type="radio" id="develop" name="env" value="develop" onchange="updatePreview()">
<label for="develop">开发</label>
</div>
<div class="radio-option">
<input type="radio" id="trial" name="env" value="trial" onchange="updatePreview()">
<label for="trial">体验</label>
</div>
<div class="radio-option">
<input type="radio" id="release" name="env" value="release" checked onchange="updatePreview()">
<label for="release">正式</label>
</div>
</div>
<div class="env-warning">
开发和体验环境,请在非微信内置浏览器打开链接
</div>
</div>
<button class="jump-button" onclick="jumpToWeixin()">跳转到微信小程序</button>
<div class="preview">
<div class="preview-title">跳转链接预览:</div>
<div class="preview-url" id="previewUrl"></div>
</div>
</div>
<script>
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function updatePreview() {
const appid = document.getElementById('appid').value;
const pagePath = document.getElementById('pagePath').value;
const params = document.getElementById('params').value;
const env = document.querySelector('input[name="env"]:checked').value;
const url = buildWeixinUrl(appid, pagePath, params, env);
document.getElementById('previewUrl').textContent = url;
}
function buildWeixinUrl(appid, pagePath, params, env) {
let url = `weixin://dl/business/?appid=${appid}&path=${pagePath}`;
if (params) {
const encodedParams = encodeURIComponent(params)
url += `&query=${encodedParams}`;
}
url += `&env_version=${env}`;
return url;
}
function jumpToWeixin() {
const appid = document.getElementById('appid').value;
const pagePath = document.getElementById('pagePath').value;
const params = document.getElementById('params').value;
const env = document.querySelector('input[name="env"]:checked').value;
if (!appid || !pagePath) {
alert('请填写完整的appid和页面路径!');
return;
}
const url = buildWeixinUrl(appid, pagePath, params, env);
location.href = url;
}
// 页面加载时更新预览
window.onload = function() {
updatePreview();
};
</script>
</body>
</html>