-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
383 lines (374 loc) · 21.6 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
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
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
<html>
<head>
<title>
外出申请
</title>
<meta name="full-screen" content="yes">
<meta name="browsermode" content="application">
<meta name='apple-mobile-web-app-capable' content='yes' />
<meta name='full-screen' content='true' />
<meta name='x5-fullscreen' content='true' />
<meta name='360-fullscreen' content='true' />
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<meta name="format-detection" content="telephone=yes">
<link rel="stylesheet" href="css/bh-lib.min.css">
<link rel="stylesheet" href="css/iconfont.css">
<link rel="stylesheet" href="css/iconfont2.css">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/mob.css">
<link rel="stylesheet" href="css/skin.css">
<link rel="stylesheet" href="css/style.min.css">
<link rel="stylesheet" href="css/cropper.min.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
<script src="https://unpkg.com/mint-ui@2/lib/index.js"></script>
<link rel="stylesheet" href="https://unpkg.com/mint-ui@2/lib/style.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/global/luxon.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/qrcode.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/sprintf.min.js"></script>
<script>
addEventListener("load", function () { setTimeout(hideURLbar, 0); }, false);
function hideURLbar() {
window.scrollTo(0, 1);
}
window.onload = function () {
scroll();
}
function scroll() {
if (document.documentElement.scrollHeight <= document.documentElement.clientHeight) {
bodyTag = document.getElementsByTagName('body')[0];
bodyTag.style.height = document.documentElement.clientWidth / screen.width * screen.height + 'px';
}
}
const KEY = "7326c9c6-0891-11ec-b5bd-9cda3efd56be";
const loadWithDefault = (key, defaultVal) => {
const vkey = `${KEY}-${key}`;
if (window.localStorage.getItem(vkey) === null) return defaultVal;
else return window.localStorage.getItem(vkey);
};
const save = (key, val) => {
const vkey = `${KEY}-${key}`;
window.localStorage.setItem(vkey, String(val));
};
const loadRecords = () => {
const vkey = `records-${KEY}`;
const resp = window.localStorage.getItem(vkey);
if (resp === null) return [];
else return JSON.parse(resp);
};
const saveRecords = data => {
const vkey = `records-${KEY}`;
window.localStorage.setItem(vkey, JSON.stringify(data));
}
Vue.use(MINT);
document.addEventListener("DOMContentLoaded", () => {
new Vue({
el: "#main",
data: {
name: "",
id: "",
school: "",
classname: "",
returntime: 0,
editing: false,
qrdata: "",
currentTime: 0,
activeTab: "tab1",
waiting: false,
records: [],
currRecord: {
index: -1,
type: "start"
}
},
computed: {
recordvalue: {
get() {
if (this.currRecord.index === -1) return new Date();
return luxon.DateTime.fromSeconds(this.records[this.currRecord.index][this.currRecord.type]).toJSDate();
},
set(v) {
if (this.currRecord.index === -1) return;
this.records[this.currRecord.index][this.currRecord.type] = luxon.DateTime.fromJSDate(v).toSeconds();
}
},
pickerValue: {
get() {
return luxon.DateTime.fromSeconds(this.returntime).toJSDate();
},
set(v) {
this.returntime = Math.floor(luxon.DateTime.fromJSDate(v).toSeconds());
}
},
timeString() {
const current = luxon.DateTime.fromSeconds(this.currentTime);
const end = luxon.DateTime.fromSeconds(this.returntime);
const diff = end.diff(current, "seconds");
const seconds = Math.floor(diff.seconds);
const days = Math.floor(seconds / (24 * 60 * 60));
const rem = seconds % (24 * 60 * 60);
const hours = Math.floor(rem / 3600);
const minutes = Math.floor((rem - 3600 * hours) / 60);
const seconds1 = rem - 3600 * hours - 60 * minutes;
return sprintf("%d天 %02d:%02d:%02d", days, hours, minutes, seconds1);
},
},
watch: {
name(newval) {
save("name", newval)
},
id(newval) {
save("id", newval);
QRCode.toDataURL(newval,
{
width: 150,
color: { dark: "#F97AFB" },
errorCorrectLevel: "H",
version: 2,
margin: 0
}).then(r => this.qrdata = r);
},
school(newval) {
save("school", newval)
},
classname(newval) {
save("classname", newval)
},
returntime(newval) {
save("returntime", newval)
},
editing(newval) {
if (newval == false) {
saveRecords(this.records);
} else {
this.records = loadRecords();
}
}
},
methods: {
openRecordTimeEdit(index, type) {
console.log("?");
if (!this.editing) return;
this.currRecord.index = index;
this.currRecord.type = type;
this.$refs.recordpicker.open();
},
openRecordDest(rawval, callback) {
if (!this.editing) return;
MINT.MessageBox.prompt(`请输入新的目的地 (原始值 ${rawval})`).then(({ value, action }) => {
if (action === "confirm") {
callback(value);
}
});
},
addRecord() {
const now = luxon.DateTime.now()
this.records = [{ start: now.toSeconds(), end: now.plus({ hours: 5 }).toSeconds(), dest: "光谷步行街" }, ...this.records];
},
makeTimeString(second) {
return luxon.DateTime.fromSeconds(second).toFormat("yyyy-MM-dd HH:mm");
},
makeDateString(second) {
return luxon.DateTime.fromSeconds(second).toFormat("yyyy-MM-dd");
},
click1() {
if (!this.waiting) {
this.waiting = true;
setTimeout(() => this.waiting = false, 3000);
}
},
click2() {
if (this.waiting) {
this.waiting = false;
this.editing = true;
}
},
openEdit(key, prompt) {
if (!this.editing) return;
const rval = this[key];
MINT.MessageBox.prompt(`请输入新的 ${prompt} 值 (原始值 ${rval})`).then(({ value, action }) => {
if (action === "confirm") {
this[key] = value;
}
});
},
openTimeEdit() {
if (!this.editing) return;
this.$refs.picker.open();
}
},
mounted() {
window.vueobj = this;
this.name = loadWithDefault("name", "姓名");
this.id = loadWithDefault("id", "学号");
this.school = loadWithDefault("school", "学院");
this.classname = loadWithDefault("classname", "班级");
this.returntime = parseInt(loadWithDefault("returntime", 0));
this.records = loadRecords();
setInterval(() => {
this.currentTime = Math.floor(luxon.DateTime.now().toSeconds());
}, 500);
}
})
});
// document.onload = ;
</script>
<script src="js/hide-address-bar.js"></script>
</head>
<body>
<div id="main" class="mint-layout-container fxyq_fxsq fxyq_wcsq">
<div class="mint-layout-container">
<div class="mint-layout-container pjwvpma57">
<div class="mint-navbar mt-bg-lv3 mt-bColor-grey-lv4" style="overflow-y: hidden;">
<a class="mint-tab-item mt-bColor-theme" v-bind:class="[activeTab!=='tab1'?'is-selected':null]"
componentname="navbar" style="min-width: 0px;">
<div class="-mint-tab-item-label"
v-bind:class="[activeTab==='tab1'?' mt-color-theme':'mt-color-grey-lv2']"
style="font-size: 14px;" v-on:click="activeTab='tab1'">外出申请</div>
</a>
<a class="mint-tab-item mt-bColor-theme" v-bind:class="[activeTab!=='tab2'?'is-selected':null]"
componentname="navbar" style="min-width: 0px;">
<div class="-mint-tab-item-label"
v-bind:class="[activeTab==='tab2'?' mt-color-theme':'mt-color-grey-lv2']"
style="font-size: 14px;" v-on:click="activeTab='tab2'">外出记录</div>
</a>
</div>
<!-- <mt-navbar class="mt-bg-lv3 mt-bColor-grey-lv4" style="overflow-y: hidden;" v-model="activeTab">
<mt-tab-item id="tab1">
外出申请
</mt-tab-item>
<mt-tab-item id="tab2">
外出记录
</mt-tab-item>
</mt-navbar> -->
<mt-tab-container v-model="activeTab">
<mt-tab-container-item v-bind:id="'tab1'">
<div class="wcsq-tab-content">
<div style="background-color: rgb(82, 199, 202);">
<div class="mint-layout-container bh-bg-color-light xszp_image"
v-on:dblclick="click1()">
<img class="mint-image"
style="width: 80px; height: 80px; border-radius: 50%; margin: 3px; display: none;">
<img src="images/none.png" class="mint-image"
style="width: 80px; height: 80px; border-radius: 50%; margin: 3px;">
</div>
<div class="xsxx">
<div>
<div style="display: inline;" v-on:click="openEdit('name','姓名')">{{name}}</div>
<div style="display: inline;" v-on:click="openEdit('id','学号')">{{id}}</div>
</div>
<div>
<div style="display: inline;" v-on:click="openEdit('school','学院')">{{school}}
</div>/<div style="display: inline;" v-on:click="openEdit('classname','班级')">
{{classname}}</div>
</div>
</div>
</div>
<!---->
<!-- <mt-text class="wcsq-erm-title" color="grey">临时出校二维码</mt-text> -->
<div class="mint-text wcsq-erm-title mt-color-grey" v-on:dblclick="click2()">临时出校二维码</div>
<div class="wcsq-ld-content" style="display: none;">
<img alt="" src="images/ld1.png" class="wcsq-ld-img">
<div class="wcsq-ld-text" style="color: rgb(83, 199, 202);">距离外出时间还剩:<span>0天
00:10:03</span>
</div>
</div>
<div class="wcsq-ld-content">
<img alt="" src="images/ld2.png" class="wcsq-ld-img">
<div class="wcsq-ld-text" style="color: rgb(255, 153, 24);">
距离返回时间还剩:<span v-on:click="openTimeEdit">{{timeString}}</span></div>
</div>
<div class="wcsq-ld-content" style="display: none;"><img alt="" src="images/ld2.png"
class="wcsq-ld-img">
<div class="wcsq-ld-text" style="color: rgb(255, 153, 24);">已超时,二维码失效</div>
</div>
<div class="wcsq-ewm-content">
<div id="wcsq_school_code" v-bind:title="id" style="margin: 10px;">
<img alt="Scan me!" v-bind:src="qrdata" style="display: block;">
</div>
</div>
<div class="wcsq-ewm-tip">请向校方检查人员出示二维码,扫码进出校~</div>
<div v-if="editing" style="color:red;font-weight: bold;margin:40px">
当前为编辑模式,点击 姓名 学号 学院 班级 返回时间 可以进行编辑。
<mt-button type="primary" v-on:click="editing=false">关闭编辑</mt-button>
</div>
</div>
</mt-tab-container-item>
<mt-tab-container-item v-bind:id="'tab2'">
<mt-button v-if="editing" type="primary" v-on:click="addRecord">添加</mt-button>
<span v-if="editing" style="color:red;font-weight: bold;margin:40px">
预计外出时间 预计返回时间 目的地 可以双击进行编辑。
</span>
<div class="mint-layout-container pk1itqqpj pk6sm8biv">
<div class="mint-layout-container" id="scroll_container" infinite-scroll-distance="20">
<div v-for="item,i in records"
class="mint-layout-container bh-bg-color-light OPk1iu6ki2">
<div class="mint-layout-container">
<div class="mint-layout-container">
<div class="mint-layout-container OPk1iu6ki3"><img src="images/rl.png"
class="mint-image OPk1iu6ki5">
<div class="mint-text OPk1iu6ki6 mt-color-default">
{{makeDateString(item.start)}}
</div>
</div>
<div class="mint-layout-container" style="margin-top: 10px;"><img
src="images/time.png" class="mint-image wcsq-list-tb">
<div class="mint-text OPk1iu6kiij mt-color-default">预计外出时间:</div>
<div class="mint-text OPk1iu6kiie mt-color-default"
v-on:dblclick="openRecordTimeEdit(i,'start')">
{{makeTimeString(item.start)}}
</div>
</div>
<div class="mint-layout-container" style="margin-top: 10px;"><img
src="images/time.png" class="mint-image wcsq-list-tb">
<div class="mint-text OPk1iu6kiij mt-color-default">预计返回时间:</div>
<div class="mint-text OPk1iu6kiie mt-color-default"
v-on:dblclick="openRecordTimeEdit(i,'end')">
{{makeTimeString(item.end)}}
</div>
</div>
<div class="mint-layout-container OCk6sot574b OPk6sot572x"><span
class="mint-icon OPk6sot573z"><i
class="iconfont mint-icon-i icon-xinxi"
style="color: rgb(146, 150, 156);"></i></span>
<div
class="mint-text bh-color-gray-3 sjaky9s9n OCk6sot56s OCk6sot56t mt-color-default">
离校事由:</div>
<div
class="mint-text bh-color-gray sjakvxbio OPk6sot56t OCk6sot56u mt-color-default">
临时外出</div>
</div>
<div class="mint-layout-container" style="margin-top: 10px;"><img
src="images/qz.png" class="mint-image wcsq-list-tb">
<div class="mint-text OPk1iu6kiij mt-color-default">目的地:</div>
<div class="mint-text OPk1iu6kiie mt-color-default"
v-on:dblclick="openRecordDest(item.dest,r=>item.dest=r)">{{item.dest
|| "目的地"}}</div>
</div>
</div>
<div class="mint-layout-container OPk6sppiq1u wcsq-list-shnr"><span
class="mint-badge sjakuc6ex OCk6sppiodq OPk6sppio7d wcsq-list-shtb mt-color-white mt-bg-primary is-size-small"></span>
<div
class="mint-text sjaky9s9n OPk6sppiobt OPk6sppiocq wcsq-list-shtxt mt-color-default">
已通过</div>
</div>
</div>
<mt-button v-if="editing" type="primary" v-on:click="records.splice(i,1)">删除
</mt-button>
</div>
<div class="mint-text bh-color-gray-3 OPjfbvuua8 mt-color-default"
style="text-align: center;">没有更多了~</div>
</div>
</div>
</mt-tab-container-item>
</mt-tab-container>
</div>
</div>
<mt-datetime-picker ref="picker" v-model="pickerValue" type="datetime"></mt-datetime-picker>
<mt-datetime-picker ref="recordpicker" v-model="recordvalue" type="datetime"></mt-datetime-picker>
</div>
</body>
</html>