|
1 | 1 | <template>
|
2 |
| - <div class="MainPage"> |
3 |
| - <v-row class="DataBlock"> |
4 |
| - <v-col |
5 |
| - v-for="(item, i) in classData.classData.Lessons['2020-04-04']" |
6 |
| - :key="i" |
7 |
| - cols="12" |
8 |
| - md="6" |
9 |
| - > |
10 |
| - <StudyCard |
11 |
| - :schooltime="i + 1" |
12 |
| - :realtime="item.realTime" |
13 |
| - :content="item.Content" |
14 |
| - :subject="item.Subject" |
15 |
| - /> |
16 |
| - </v-col> |
17 |
| - </v-row> |
| 2 | + <div class="LoginPage"> |
| 3 | + <v-flex> |
| 4 | + <div class="Logo"> |
| 5 | + <Logo style="height: 80vw; max-height: 350px; width: 100%;" /> |
| 6 | + </div> |
| 7 | + <div class="LoginForm"> |
| 8 | + <v-form ref="form" v-model="valid"> |
| 9 | + <v-text-field |
| 10 | + v-model="classId" |
| 11 | + :counter="6" |
| 12 | + label="クラスID" |
| 13 | + :rules="nameRules" |
| 14 | + outlined |
| 15 | + dark |
| 16 | + required |
| 17 | + /> |
| 18 | + <v-btn |
| 19 | + block |
| 20 | + outlined |
| 21 | + color="white" |
| 22 | + height="40px" |
| 23 | + :loading="loading" |
| 24 | + :disabled="loading || !valid" |
| 25 | + @click="checkInClass" |
| 26 | + > |
| 27 | + LOGIN |
| 28 | + </v-btn> |
| 29 | + </v-form> |
| 30 | + </div> |
| 31 | + </v-flex> |
18 | 32 | </div>
|
19 | 33 | </template>
|
20 | 34 |
|
21 | 35 | <script>
|
22 |
| -import { mapGetters } from 'vuex' |
23 |
| -import StudyCard from '@/components/StudyCard' |
| 36 | +import { mapActions } from 'vuex' |
| 37 | +import firebase from '@/plugins/firebase' |
| 38 | +import Logo from '@/assets/svgs/logo.svg' |
24 | 39 | export default {
|
25 |
| - components: { StudyCard }, |
26 |
| - computed: { |
27 |
| - ...mapGetters('modules/class', ['classData']), |
| 40 | + components: { Logo }, |
| 41 | + data() { |
| 42 | + return { |
| 43 | + classId: '', |
| 44 | + loading: false, |
| 45 | + error: false, |
| 46 | + errorMessages: '', |
| 47 | + valid: true, |
| 48 | + exists: false, |
| 49 | + nameRules: [ |
| 50 | + (v) => !!v || 'クラスIDは必須です', |
| 51 | + (v) => (v && v.length === 6) || 'クラスIDは6文字のひらがなです', |
| 52 | + ], |
| 53 | + } |
| 54 | + }, |
| 55 | + methods: { |
| 56 | + ...mapActions('modules/class', ['loadClassData']), |
| 57 | + checkInClass() { |
| 58 | + this.loading = true |
| 59 | + this.checkExistsClassData(this.classId) |
| 60 | + if (this.exists) { |
| 61 | + this.loadClassData(this.classId) |
| 62 | + this.$router.push('classes') |
| 63 | + } else { |
| 64 | + this.loading = false |
| 65 | + this.error = true |
| 66 | + this.errorMessages = 'クラスIDが間違っています' |
| 67 | + } |
| 68 | + }, |
| 69 | + checkExistsClassData(classid) { |
| 70 | + if (classid !== '' || classid !== null || classid !== '') { |
| 71 | + firebase |
| 72 | + .firestore() |
| 73 | + .collection('classData') |
| 74 | + .doc(classid) |
| 75 | + .get() |
| 76 | + .then(() => { |
| 77 | + this.exists = true |
| 78 | + }) |
| 79 | + .catch(() => { |
| 80 | + this.exists = false |
| 81 | + }) |
| 82 | + } else { |
| 83 | + this.exists = false |
| 84 | + } |
| 85 | + }, |
28 | 86 | },
|
29 | 87 | }
|
30 | 88 | </script>
|
|
0 commit comments