This repository was archived by the owner on Sep 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhome.html
139 lines (138 loc) · 5.86 KB
/
home.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>PoemScape</title>
<link rel="stylesheet" href="/static/css/home.css">
<script src="/static/js/vue.js"></script>
<script src="/static/js/axios.min.js"></script>
</head>
<body>
<img class="hero" src="/static/images/hero.png">
<div id="upload" class="content">
<label for="image" v-if="uploading">正在上传</label>
<label for="image" v-else>
<div class="pure-g">
<div class="pure-u-1-2 upload-landscape">
<label>
<img class="upload-button pure-img" id="file" src="/static/images/landscape.png" alt="上传景致">
<input type="file" id="image" accept="image/*" hidden @change="update">
</label>
</div>
<div class="pure-u-1-2 upload-people">
<label>
<img class="upload-button pure-img" id="file" src="/static/images/people.png" alt="上传人像">
<input type="file" id="image" accept="image/*" hidden @change="update_face">
</label>
</div>
</div>
</label>
<input type="file" id="image" accept="image/*" hidden @change="update">
<div class="pure-g share">
<h2 class="pure-u-1">
<img src="/static/images/share.png" alt="诗景分享">
</h2>
<div class="pure-u-1 pure-u-sm-1-2 pure-u-md-1-3 pure-u-lg-1-4">
<a class="share-item" href="/234">
<img class="pure-img share-img" src="/api/image?order=234">
</a>
</div>
<div class="pure-u-1 pure-u-sm-1-2 pure-u-md-1-3 pure-u-lg-1-4">
<a class="share-item" href="/241">
<img class="pure-img share-img" src="/api/image?order=241">
</a>
</div>
<div class="pure-u-1 pure-u-sm-1-2 pure-u-md-1-3 pure-u-lg-1-4">
<a class="share-item" href="/246">
<img class="pure-img share-img" src="/api/image?order=246">
</a>
</div>
<div class="pure-u-1 pure-u-sm-1-2 pure-u-md-1-3 pure-u-lg-1-4">
<a class="share-item" href="/250">
<img class="pure-img share-img" src="/api/image?order=250">
</a>
</div>
<div class="pad"></div>
</div>
</div>
<script>
app = new Vue({
el: '#upload',
data: {
uploading: false,
},
methods: {
update(e) {
console.log('uploading...');
// disable input
document.getElementById("image").disabled="disabled";
this.uploading = true;
let file = e.target.files[0];
let param = new FormData();
param.append('image', file);
console.log(param.get('image'));
axios.post('/api/upload', param)
.then(function (response) {
console.log("upload success!");
console.log(response);
// jump to result page, response.data.id is the #order
window.location.href = String(response.data.id);
})
.catch(function (error) {
app.uploading = false;
// enable input
document.getElementById("image").disabled="";
file = document.getElementById('image');
file.type = '';
file.type = 'file';
console.log("upload fail!");
console.log(error);
console.log(error.response.data)
if(error.response.data.error == undefined){
alert("Server Error.");
}
else{
alert(error.response.data.error);
}
});
},
update_face(e) {
console.log('uploading...');
// disable input
document.getElementById("image").disabled="disabled";
this.uploading = true;
let file = e.target.files[0];
let param = new FormData();
param.append('image', file);
console.log(param.get('image'));
axios.post('/api/upload_face_type', param)
.then(function (response) {
console.log("upload success!");
console.log(response);
// jump to result page, response.data.id is the #order
window.location.href = String(response.data.id);
})
.catch(function (error) {
app.uploading = false;
// enable input
document.getElementById("image").disabled="";
file = document.getElementById('image');
file.type = '';
file.type = 'file';
console.log("upload fail!");
console.log(error);
console.log(error.response.data)
if(error.response.data.error == undefined){
alert("Server Error.");
}
else{
alert(error.response.data.error);
}
});
},
},
});
</script>
</body>
</html>