-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.vue
332 lines (310 loc) · 9.01 KB
/
App.vue
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
<template>
<view class="container">
<view v-if="isNotStarted">
<text class="copywrite">{{copywrite}}</text>
<view class="gold-button-back">
<button class="gold-button" :on-press="go" title="운명 개척하러 가기" color="white"></button>
</view>
</view>
<view class="container" v-if="isStarted">
<touchable-opacity :on-press="onIconClicked">
<image :style="{width: 100, height: 100}" :source="image" />
</touchable-opacity>
<text class="title" v-if="luck_selected">오늘의 운세는 {{lucktype}}입니다.</text>
<text class="title" v-if="luck_unselected">운세를 직접 골라보세요!</text>
<text class="description">{{text}}</text>
<text class="lucky-item" v-if="luck_selected">행운의 아이템</text>
<view class="lucky-items" v-if="luck_selected">
<touchable-opacity :on-press="onItemClicked1">
<image class="item" :style="{width: 60, height: 60}" :source="item1" />
</touchable-opacity>
<touchable-opacity :on-press="onItemClicked2">
<image class="item" :style="{width: 60, height: 60}" :source="item2" />
</touchable-opacity>
<touchable-opacity :on-press="onItemClicked3">
<image class="item" :style="{width: 60, height: 60}" :source="item3" />
</touchable-opacity>
</view>
</view>
</view>
</template>
<style>
.container {
background-color: white;
align-items: center;
justify-content: center;
flex: 1;
}
.title {
font-size: 24;
font-weight: bold;
margin-top: 20;
}
.description {
margin-top: 10;
padding-left: 40;
padding-right: 40;
}
.layer {
background-color: #000000;
opacity: 0.1;
width: 100;
height: 100;
align-items: center;
justify-content: center;
}
.lucky-item {
margin-top: 50;
font-size: 22;
font-weight: bold;
}
.lucky-items {
flex-direction: row;
margin-top: 15;
}
.item {
margin-left: 10;
margin-right: 10;
}
.copywrite {
text-align: left;
font-size: 40;
line-height: 55;
padding-right: 70;
padding-bottom: 400;
}
.gold-button-back {
background-color: #42b883;
padding: 10;
border-radius: 10;
}
</style>
<script>
import luck from "./assets/luck.json";
import money_image from "./assets/money.png";
import health_image from "./assets/health.png";
import love_image from "./assets/love.png";
import business_image from "./assets/business.png";
import plus_image from "./assets/plus.png";
import item_book from "./assets/items/book.png";
import item_coffee from "./assets/items/coffee.png";
import item_phone from "./assets/items/phone.png";
import item_chair from "./assets/items/chair.png";
import item_glasses from "./assets/items/glasses.png";
import item_pants from "./assets/items/pants.png";
import item_pencil from "./assets/items/pencil.png";
import item_shoes from "./assets/items/shoes.png";
import item_watch from "./assets/items/watch.png";
import { Alert } from "react-native";
export default {
data: {
luck: luck,
lucktype: "???",
text_index: 0,
items: [
plus_image,
item_book,
item_coffee,
item_phone,
item_chair,
item_glasses,
item_pants,
item_pencil,
item_shoes,
item_watch
],
item_index: [0, 0, 0],
accelerometerData: {},
copywrite: "아들아, 언제까지\n정해준 대로만\n살 거니?",
start: false
},
computed: {
isStarted: function() {
return this.start;
},
isNotStarted: function() {
return !this.isStarted;
},
text: function() {
return luck.filter(l => l.name === this.lucktype)[0].text[this.text_index]
.msg;
},
keyword: function() {
return luck.filter(l => l.name === this.lucktype)[0].text[this.text_index]
.key;
},
image: function() {
let f = luck.filter(l => l.name === this.lucktype)[0];
let img = plus_image;
if (this.lucktype === "재물운") {
img = money_image;
} else if (this.lucktype === "사업운") {
img = business_image;
} else if (this.lucktype === "애정운") {
img = love_image;
} else if (this.lucktype === "건강운") {
img = health_image;
}
return img;
},
luck_selected: function() {
return this.lucktype !== "???";
},
luck_unselected: function() {
return this.lucktype === "???";
},
item1: function() {
return this.items[this.item_index[0]];
},
item2: function() {
return this.items[this.item_index[1]];
},
item3: function() {
return this.items[this.item_index[2]];
}
},
methods: {
go: function() {
this.start = true;
},
onIconClicked: function() {
Alert.alert(
"운세 선택",
"오늘의 운세는 어떤가요?",
[
{
text: "재물운",
onPress: () => {
let texts = [];
let text = luck.filter(l => l.name === "재물운")[0].text;
while (texts.length < 3) {
let index = Math.floor(Math.random() * text.length);
var rand = text[index].key;
if (texts.includes(text[index].msg)) {
continue;
}
texts.push({
text: rand,
onPress: () => {
this.lucktype = "재물운";
this.text_index = index;
}
});
}
Alert.alert("상세 선택", "어떤 운세를 바라시나요?", texts, {
cancelable: true
});
}
},
{
text: "사업운",
onPress: () => {
let texts = [];
let text = luck.filter(l => l.name === "사업운")[0].text;
while (texts.length < 3) {
let index = Math.floor(Math.random() * text.length);
var rand = text[index].key;
if (texts.includes(text[index].msg)) {
continue;
}
texts.push({
text: rand,
onPress: () => {
this.lucktype = "사업운";
this.text_index = index;
}
});
}
Alert.alert("상세 선택", "어떤 운세를 바라시나요?", texts, {
cancelable: true
});
}
},
{
text: "애정운",
onPress: () => {
let texts = [];
let text = luck.filter(l => l.name === "애정운")[0].text;
while (texts.length < 3) {
let index = Math.floor(Math.random() * text.length);
var rand = text[index].key;
if (texts.includes(text[index].msg)) {
continue;
}
texts.push({
text: rand,
onPress: () => {
this.lucktype = "애정운";
this.text_index = index;
}
});
}
Alert.alert("상세 선택", "어떤 운세를 바라시나요?", texts, {
cancelable: true
});
}
},
{
text: "건강운",
onPress: () => {
let texts = [];
let text = luck.filter(l => l.name === "건강운")[0].text;
while (texts.length < 3) {
let index = Math.floor(Math.random() * text.length);
var rand = text[index].key;
if (texts.includes(text[index].msg)) {
continue;
}
texts.push({
text: rand,
onPress: () => {
this.lucktype = "건강운";
this.text_index = index;
}
});
}
Alert.alert("상세 선택", "어떤 운세를 바라시나요?", texts, {
cancelable: true
});
}
}
],
{ cancelable: true }
);
},
onItemClicked1: function() {
let items = [];
while (items.length < 3) {
let index = Math.floor(Math.random() * this.items.length);
if (items.includes(index) || index === 0) {
continue;
}
items.push(index);
}
this.item_index = items;
},
onItemClicked2: function() {
let items = [];
while (items.length < 3) {
let index = Math.floor(Math.random() * this.items.length);
if (items.includes(index) || index === 0) {
continue;
}
items.push(index);
}
this.item_index = items;
},
onItemClicked3: function() {
let items = [];
while (items.length < 3) {
let index = Math.floor(Math.random() * this.items.length);
if (items.includes(index) || index === 0) {
continue;
}
items.push(index);
}
this.item_index = items;
}
}
};
</script>