-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
280 lines (270 loc) · 8.45 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<!-- import CSS -->
<link
rel="stylesheet"
href="https://unpkg.com/element-ui/lib/theme-chalk/index.css"
/>
<!-- font-awsome -->
<link
rel="stylesheet"
href="https://use.fontawesome.com/releases/v5.8.1/css/all.css"
integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf"
crossorigin="anonymous"
/>
<link rel="shortcut icon" href="static/favicon.png" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"
/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- import Vue before Element -->
<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
<!-- import JavaScript -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<!-- import axios -->
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<title>吃点啥 | trash-station</title>
</head>
<body>
<div id="app">
<el-row>
<el-col :xs="0" :sm="2" :md="4" :lg="6" :xl="7">
<div class="empty"><br /></div>
</el-col>
<el-col :xs="24" :sm="20" :md="16" :lg="12" :xl="10">
<el-card class="maincard">
<el-image
:src="'static/logo.png'"
class="logo"
width="100%"
height="100%"
></el-image>
<h1>吃点啥</h1>
<el-link
type="primary"
style="font-size: 1em; color: black"
href="https://trash-station.github.io/"
>
<img
src="static/trash-station.png"
alt=""
style="
width: 1em;
display: inline-block;
vertical-align: middle;
"
/>
trash-station
</el-link>
<el-divider></el-divider>
<el-image
style="width: 250px; height: 250px"
:src="showimg"
fit="contain"
></el-image>
<p>{{ showtxt == "" ? randomtype[radio] : showtxt }}</p>
<div class="choice">
<el-radio v-model="radio" label="foods" :disabled="!buttoncanuse"
>食物</el-radio
>
<el-radio v-model="radio" label="shops" :disabled="!buttoncanuse"
>店铺</el-radio
>
<div style="display: inline-block">
<span id="radio">是否显示动画</span>
<el-switch
v-model="effect"
active-color="#13ce66"
inactive-color="#606266"
>
</el-switch>
</div>
</div>
<p style="font-weight: bold; color: #a0a0a0; font-size: 0.9em">
店铺功能仅为开发者使用(因为送不到)
</p>
<el-button
type="danger"
@click="onstartclick()"
:disabled="!buttoncanuse"
>{{ startbutton }}</el-button
>
<el-divider></el-divider>
<div class="footer">
<a
href="https://github.com/trash-station"
target="_blank"
rel="noopener noreferrer"
><img
src="https://img.shields.io/static/v1?label=Organization&message=TrashStation&color=lightgrey&logo=github"
alt=""
/></a>
<el-divider direction="vertical"></el-divider>
<a
href="https://im0o.top"
target="_blank"
rel="noopener noreferrer"
><img
src="https://img.shields.io/static/v1?label=Author&message=Jz0ojiang&color=9cf&logo=github"
alt=""
/></a>
<el-divider direction="vertical"></el-divider>
<a
href="https://github.com/trash-station/whattoeat"
target="_blank"
rel="noopener noreferrer"
><img
src="https://img.shields.io/static/v1?label=Repository&message=whattoeat&color=green&logo=github"
alt=""
/></a>
<br />
<el-link
class="el-icon-link"
type="success"
style="font-size: 1em; margin-bottom: -20px"
href="/support/"
>支持我们</el-link
>
<p
style="
font-weight: bold;
color: #707070;
font-size: 0.9em;
margin: 20px 0 -10px 0;
"
>
吃点啥基于 Vue.js 开发,使用 Vercel 服务部署<br />如果希望提交图片,请点击上方的
Repository 图标提交 Pull Request
</p>
</div>
</el-card>
</el-col>
<el-col :xs="0" :sm="2" :md="4" :lg="6" :xl="7">
<div class="empty"><br /></div>
</el-col>
</el-row>
</div>
</body>
<script>
Vue.prototype.$http = axios;
new Vue({
el: "#app",
data: function () {
return {
radio: "foods",
data: {},
shoptype: ["meituan", "ele"],
randomtype: {
foods: "点击下方按钮,随机一种食物",
shops: "点击下方按钮,随机一个店铺",
},
showimg: "static/sample.png",
showtxt: "",
startbutton: "开始随机",
buttoncanuse: true,
effect: true,
shopname: {
meituan: "美团",
ele: "饿了么",
},
};
},
methods: {
getdata() {
axios
.get("/static/listdata.json")
.then((res) => {
this.data = res.data;
})
.finally(() => {
console.log(this.data);
});
},
async onstartclick() {
if (this.effect) {
this.buttoncanuse = false;
this.startbutton = "正在随机...";
for (let i = 1; i < 21; i++) {
setTimeout(
() => {
this.random();
if (i == 1) {
this.buttoncanuse = true;
this.startbutton = "换一个";
}
},
9000 / i >= 2000 ? 2000 : 8000 / i
);
}
} else {
this.random();
this.startbutton = "换一个";
}
},
random() {
if (this.radio === "foods") {
let random = Math.floor(
Math.random() * this.data.foods.list.length
);
this.showtxt = this.data.foods.list[random];
this.showimg = this.data[this.radio][this.showtxt];
} else if (this.radio === "shops") {
let dp = this.shoptype[Math.floor(Math.random() * 2)];
let random = Math.floor(Math.random() * this.data.shops[dp].length);
this.showtxt = `${this.shopname[dp]}-${this.data.shops[dp][random]}`;
this.showimg =
this.data[this.radio]["detail"][dp][this.data.shops[dp][random]];
}
},
},
created() {
this.getdata();
},
});
</script>
<style>
.maincard {
width: 100%;
height: 100%;
box-sizing: border-box;
text-align: center;
padding-top: 30px;
margin-top: 10px;
/*background-color: #e0e0e0;*/
}
h1 {
line-height: 0.5;
}
.empty {
width: 100%;
height: 100%;
-webkit-touch-callout: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
#app {
width: 100%;
height: 100%;
box-sizing: border-box;
margin-top: 10px;
}
body {
background-image: url("/static/bg.jpg");
background-repeat: no-repeat;
background-size: cover;
background-attachment: fixed;
font-family: "Helvetica Neue", Helvetica, "PingFang SC",
"Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}
#radio {
font-weight: 500;
font-size: 14px;
color: #606266;
}
</style>
</html>