|
| 1 | +<template> |
| 2 | + <v-card v-if="!routeHasFeedBack" class="elevation-0 dialog-card"> |
| 3 | + <template v-if="!feedBackSent"> |
| 4 | + <v-card-title class="headline"> |
| 5 | + Оставьте свой отзыв |
| 6 | + <slot /> |
| 7 | + </v-card-title> |
| 8 | + <v-card-text class="text-center body-1"> |
| 9 | + Оцените пройденный тест, чтобы мы становились ещё лучше! |
| 10 | + <br> |
| 11 | + Возможно, у Вас есть вопросы или пожелания - напишите их тоже |
| 12 | + <v-rating |
| 13 | + v-model="rating" |
| 14 | + background-color="red lighten-3" |
| 15 | + color="primary" |
| 16 | + :large="!isMobile" |
| 17 | + class="mt-2" |
| 18 | + /> |
| 19 | + <v-textarea |
| 20 | + v-model="message" |
| 21 | + name="message" |
| 22 | + label="Отзыв" |
| 23 | + :height="120" |
| 24 | + no-resize |
| 25 | + class="ma-0" |
| 26 | + /> |
| 27 | + <div class="text-right"> |
| 28 | + <v-btn |
| 29 | + :disabled="!rating" |
| 30 | + :block="isMobile" |
| 31 | + color="primary" |
| 32 | + rounded |
| 33 | + depressed |
| 34 | + @click="send" |
| 35 | + > |
| 36 | + Отправить |
| 37 | + </v-btn> |
| 38 | + </div> |
| 39 | + </v-card-text> |
| 40 | + </template> |
| 41 | + <template v-else> |
| 42 | + <v-card-text class="text-center headline fade-in mt-8 pa-0"> |
| 43 | + Ваш отзыв отправлен, спасибо! |
| 44 | + </v-card-text> |
| 45 | + </template> |
| 46 | + </v-card> |
| 47 | +</template> |
| 48 | + |
| 49 | +<script> |
| 50 | + export default { |
| 51 | + data: () => ({ |
| 52 | + feedBackSent: false, |
| 53 | + routeHasFeedBack: false, |
| 54 | + message: '', |
| 55 | + rating: 0, |
| 56 | + }), |
| 57 | + computed: { |
| 58 | + isMobile() { |
| 59 | + return this.$vuetify.breakpoint.xsOnly; |
| 60 | + }, |
| 61 | + }, |
| 62 | + created() { |
| 63 | + this.$axios.$get(`routeFeedback?path=${encodeURIComponent(this.$route.path)}`).then(({ exists }) => { |
| 64 | + this.routeHasFeedBack = exists; |
| 65 | + }); |
| 66 | + }, |
| 67 | + methods: { |
| 68 | + send() { |
| 69 | + if (!this.rating) return; |
| 70 | +
|
| 71 | + this.$axios.$post('sendFeedback', { |
| 72 | + path: this.$route.path, |
| 73 | + rate: this.rating, |
| 74 | + message: this.message, |
| 75 | + }).then(() => { |
| 76 | + this.feedBackSent = true; |
| 77 | + |
| 78 | + setTimeout(() => { |
| 79 | + this.routeHasFeedBack = true; |
| 80 | + }, 3000); |
| 81 | + }).catch(err => { |
| 82 | + console.error(err); |
| 83 | + }); |
| 84 | + }, |
| 85 | + }, |
| 86 | + }; |
| 87 | +</script> |
| 88 | + |
| 89 | +<style lang="scss" scoped> |
| 90 | + .dialog-card { |
| 91 | + max-width: 100%; |
| 92 | + } |
| 93 | + .headline { |
| 94 | + position: relative; |
| 95 | + justify-content: center; |
| 96 | + word-break: break-word; |
| 97 | +
|
| 98 | + .btn { |
| 99 | + position: absolute; |
| 100 | + right: 10px; |
| 101 | + top: 10px; |
| 102 | + } |
| 103 | + } |
| 104 | +
|
| 105 | + .fade-in { |
| 106 | + animation: fadeIn .5s ease-in; |
| 107 | + } |
| 108 | +
|
| 109 | + @keyframes fadeIn { |
| 110 | + 0% {opacity: 0;} |
| 111 | + 100% {opacity: 1;} |
| 112 | + } |
| 113 | +</style> |
0 commit comments