|
86 | 86 | </div> |
87 | 87 | </div> |
88 | 88 | <v-btn |
89 | | - v-if="IsFavorite(group)" |
| 89 | + v-if="is_bookmarked" |
90 | 90 | icon |
91 | | - class="pink--text" |
92 | | - @click="removeFavorite(group)" |
93 | | - ><v-icon>mdi-heart</v-icon></v-btn |
| 91 | + color="sairai" |
| 92 | + @click="removeBookmark(group.id)" |
| 93 | + ><v-icon>mdi-bookmark</v-icon></v-btn |
94 | 94 | > |
95 | | - <v-btn v-else icon @click="addFavorite(group)" |
96 | | - ><v-icon>mdi-heart-outline</v-icon></v-btn |
| 95 | + <v-btn v-else icon @click="addBookmark(group.id)" |
| 96 | + ><v-icon>mdi-bookmark-outline</v-icon></v-btn |
97 | 97 | > |
98 | 98 | </v-card-actions> |
99 | 99 |
|
@@ -379,7 +379,8 @@ type Data = { |
379 | 379 | ticket_person: number |
380 | 380 | person_labels: any[] |
381 | 381 | person_icons: any[] |
382 | | - displayFavorite: number |
| 382 | + nowloading: boolean |
| 383 | + is_bookmarked: boolean |
383 | 384 | listStock: number[] |
384 | 385 | listTakenTickets: number[] |
385 | 386 | view_count: number | string |
@@ -430,7 +431,8 @@ export default Vue.extend({ |
430 | 431 | dialog: false, |
431 | 432 | success_snackbar_link: undefined, |
432 | 433 | error_snackbar_link: undefined, |
433 | | - displayFavorite: 0, |
| 434 | + nowloading: true, |
| 435 | + is_bookmarked: false, |
434 | 436 | listStock: [], |
435 | 437 | listTakenTickets: [], |
436 | 438 | view_count: '...', |
@@ -522,32 +524,29 @@ export default Vue.extend({ |
522 | 524 | return this.$quaintUserRole(val.target, this.$auth.user) |
523 | 525 | }) |
524 | 526 | }, |
525 | | - methods: { |
526 | | - IsFavorite(group: Group) { |
527 | | - if (this.displayFavorite === 0) { |
528 | | - this.displayFavorite = 1 |
529 | | - return false |
530 | | - } |
531 | | - if (this.displayFavorite === 2) { |
532 | | - return false |
533 | | - } |
534 | | - if (this.displayFavorite === 3) { |
535 | | - return true |
536 | | - } |
537 | | - for (let i = 0; i < localStorage.length; i++) { |
538 | | - if ('seiryofes.groups.favorite.' + group?.id === localStorage.key(i)) { |
539 | | - return true |
540 | | - } |
| 527 | +
|
| 528 | + mounted() { |
| 529 | + for (let i = 0; i < localStorage.length; i++) { |
| 530 | + if ( |
| 531 | + 'seiryofes.groups.favorite.' + this.group?.id === |
| 532 | + localStorage.key(i) |
| 533 | + ) { |
| 534 | + // お気に入りならtrue |
| 535 | + this.is_bookmarked = true |
| 536 | + break |
541 | 537 | } |
542 | | - return false |
543 | | - }, |
544 | | - addFavorite(group: Group) { |
545 | | - localStorage.setItem('seiryofes.groups.favorite.' + group?.id, group?.id) |
546 | | - this.displayFavorite = 3 |
| 538 | + } |
| 539 | + this.nowloading = false |
| 540 | + }, |
| 541 | +
|
| 542 | + methods: { |
| 543 | + addBookmark(id: string) { |
| 544 | + localStorage.setItem('seiryofes.groups.favorite.' + id, id) |
| 545 | + this.is_bookmarked = true |
547 | 546 | }, |
548 | | - removeFavorite(group: Group) { |
549 | | - localStorage.removeItem('seiryofes.groups.favorite.' + group?.id) |
550 | | - this.displayFavorite = 2 |
| 547 | + removeBookmark(id: string) { |
| 548 | + localStorage.removeItem('seiryofes.groups.favorite.' + id) |
| 549 | + this.is_bookmarked = false |
551 | 550 | }, |
552 | 551 | checkStock(index: number) { |
553 | 552 | return this.listStock[index] |
|
0 commit comments