-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.php
362 lines (338 loc) · 12.8 KB
/
main.php
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width,height=device-height, user-scalable=no,initial-scale=1, minimum-scale=1, maximum-scale=1,target-densitydpi=device-dpi ">
<meta name="viewport" content="width=device-width,height=device-height, user-scalable=no,initial-scale=1, minimum-scale=1, maximum-scale=1,target-densitydpi=device-dpi ">
<meta charset="utf-8">
<script src="resources/vue.min.js"></script>
<script src="resources/classie.js"></script>
<link rel="stylesheet" type="text/css" href="resources/component.css" />
<link rel="stylesheet" type="text/css" href="resources/normalize.css" />
<link rel="stylesheet" type="text/css" href="resources/demo.css" />
<style>
html,
body {
font-size: 25px;
text-align: center;
height: 100%;
margin: 0;
padding: 0;
}
.bg {
height: 100%;
width: 100%;
background: url(./resources/bg.jpg) no-repeat 50%;
background-size: cover;
}
.login_box {
position: absolute;
top: 50%;
left: 50%;
margin-left: -190px;
margin-top: -270px;
border-radius: 4px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
background-color: #fff;
width: 380px;
height: 600px;
box-shadow: 0 2px 10px #999;
-moz-box-shadow: #999 0 2px 10px;
-webkit-box-shadow: #999 0 2px 10px;
}
.tip {
margin-top: 10px;
}
.tips {
color: #888;
font-size: 18px;
padding: 20px;
margin-top: 20px;
display: inline-block;
}
img {
width: 260px;
height: 260px;
}
form{
margin-top: -25px;
}
.qrimg {
position: relative;
}
.logo {
position: absolute;
left: 80px;
top: 50px;
opacity: 0.32;
}
.web_wechat_login_logo {
display: inline-block;
vertical-align: middle;
width: 140px;
height: 150px;
background: url(http://qingtingtech.com/Public/static/portal/images/logo.png)no-repeat;
}
/*a upload */
.a-upload {
padding: 4px 10px;
height: calc(80px);
width: calc(100% - 8px - 2em);
line-height: 80px;
position: relative;
cursor: pointer;
color: #888;
background: #fafafa;
border: 1px solid #ddd;
border-radius: 4px;
overflow: hidden;
display: inline-block;
*display: inline;
*zoom: 1
}
.a-upload input {
position: absolute;
font-size: 100px;
right: 0;
top: 0;
opacity: 0;
filter: alpha(opacity=0);
cursor: pointer
}
.a-upload:hover {
color: #444;
background: #eee;
border-color: #ccc;
text-decoration: none
}
.input__label--ichiro::before {
border: 1px solid #ddd;
}
.submit {
margin-top: 20px;
width: calc((100% - 8px - 2em) / 2);
height: 80px;
background: #fff;
border-radius:4px;
}
.submit:hover,.input__label-content:hover,.input__label--ichiro:hover{
background: #eee;
}
.input__label-content--ichiro {
text-align: center;
}
</style>
</head>
<body>
<div class="logo">
<i class="web_wechat_login_logo"></i>
</div>
<div class="bg">
<div class="login_box">
<br>
<div id="app">
<form action="upload.php?newTicket=<?=$_REQUEST['newTicket']?>" method="post" enctype="multipart/form-data">
<span class="input input--ichiro">
<input class="input__field input__field--ichiro" type="text" id="input-25" name="appid" />
<label class="input__label input__label--ichiro" for="input-25">
<span class="input__label-content input__label-content--ichiro">Appid</span>
</label>
</span>
<span class="input input--ichiro">
<input class="input__field input__field--ichiro" type="text" id="input-24" name="version" />
<label class="input__label input__label--ichiro" for="input-24">
<span class="input__label-content input__label-content--ichiro">Version</span>
</label>
</span>
<span class="input input--ichiro">
<input class="input__field input__field--ichiro" type="text" id="input-23" name="describe" />
<label class="input__label input__label--ichiro" for="input-23">
<span class="input__label-content input__label-content--ichiro">Describe</span>
</label>
</span>
<p>
<a href="javascript:;" class="a-upload">
<input type="file" name="file" id="">点击这里上传文件</a>
</p>
<p>
<!-- <input type="hidden" name="newTicket" value="<?=$_REQUEST['newTicket']?>"> -->
<input type="hidden" id="hidden" name="act">
<input type="button" class="submit" onclick="preview(this)" value="预览" />
<input type="button" class="submit" onclick="upload(this)" value="上传" />
</p>
</form>
</div>
<br>
<!-- <a href="main.php?uuid=<?=end($qr)?>">我已经确认登陆</a> -->
</div>
</div>
<script>
new Vue({
el: '#app',
data: {
header: false,
qrImg: 'resources/loading.gif',
tips: '请扫描二维码进行登陆'
},
methods: {
ajax(opt) {
opt = opt || {};
opt.method = opt.method.toUpperCase() || 'POST';
opt.url = opt.url || '';
opt.async = opt.async || true;
opt.data = opt.data || null;
opt.success = opt.success || function() {};
var xmlHttp = null;
if (XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
} else {
xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
}
var params = [];
for (var key in opt.data) {
params.push(key + '=' + opt.data[key]);
}
var postData = params.join('&');
if (opt.method.toUpperCase() === 'POST') {
xmlHttp.open(opt.method, opt.url, opt.async);
xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=utf-8');
xmlHttp.send(postData);
} else if (opt.method.toUpperCase() === 'GET') {
xmlHttp.open(opt.method, opt.url + '?' + postData, opt.async);
xmlHttp.send(null);
}
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
opt.success(xmlHttp.responseText);
}
};
},
wait() {
let uuid = this.qrImg.split("/").pop()
let _this = this;
this.ajax({
method: 'GET',
url: 'api.php',
data: {
act: 'check',
uuid: uuid
},
success: function(response) {
response = eval('(' + response + ')');
const STATE_REFRESH = "402"; //超时,需要重新获取数据
const STATE_CANCEL = "403"; //用户点击取消
const STATE_WAIT_CONFIRM = "404"; //用户扫描成功,等待用户确认
const STATE_CONFIRM = "405"; //用户点击确认登陆
const STATE_WAIT = "408"; //继续等待用户扫码
switch (response['window.wx_errcode']) {
case STATE_REFRESH:
_this.header = false;
_this.init();
break;
case STATE_CANCEL:
_this.header = false;
_this.tips = "请扫描二维码进行登陆"
setTimeout(() => {
_this.wait();
_this.tips = "请扫描二维码进行登陆"
}, 2000);
break;
case STATE_WAIT_CONFIRM:
_this.header = true;
_this.tips = "扫描成功,请确认"
setTimeout(() => {
_this.wait();
}, 1500);
break;
case STATE_CONFIRM:
_this.tips = "正在跳转,请稍后"
_this.ajax({
method: 'GET',
url: 'api.php',
data: {
act: 'getTicket',
wx_code: response['window.wx_code']
},
success: function(response) {
response = eval('(' + response + ')');
// console.log("upload?newTicket=" + response['Debugger-NewTicket']);
window.location.href = "upload.php?newTicket=" + response['Debugger-NewTicket'];
}
});
break;
case STATE_WAIT:
case STATE_CANCEL:
_this.tips = "请扫描二维码进行登陆"
_this.header = false;
_this.wait();
break;
}
console.log(response);
console.log(response['window.wx_errcode']);
}
});
},
init() {
// _this = this
// this.ajax({
// method: 'GET',
// url: 'api.php',
// data: {
// act: 'getUUID'
// },
// success: function (response) {
// response = eval('(' + response + ')');
// console.log(response)
// _this.qrImg = response.uuid
// _this.wait()
// }
// });
// console.log("created")
}
},
created() {
// this.init();
}
})
function preview(ele){
document.getElementById("hidden").value = "preview";
ele.parentNode.parentNode.submit();
}
function upload(ele){
document.getElementById("hidden").value = "upload";
ele.parentNode.parentNode.submit();
}
</script>
<script>
(function() {
// trim polyfill : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim
if (!String.prototype.trim) {
(function() {
// Make sure we trim BOM and NBSP
var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
String.prototype.trim = function() {
return this.replace(rtrim, '');
};
})();
}
[].slice.call(document.querySelectorAll('input.input__field')).forEach(function(inputEl) {
// in case the input is already filled..
if (inputEl.value.trim() !== '') {
classie.add(inputEl.parentNode, 'input--filled');
}
// events:
inputEl.addEventListener('focus', onInputFocus);
inputEl.addEventListener('blur', onInputBlur);
});
function onInputFocus(ev) {
classie.add(ev.target.parentNode, 'input--filled');
}
function onInputBlur(ev) {
if (ev.target.value.trim() === '') {
classie.remove(ev.target.parentNode, 'input--filled');
}
}
})();
</script>
</body>
</html>