1
1
<template >
2
- <bottom-sheet-layer title =" ユーザー登録" title-en =" STEP 1" fullscreen >
3
- <template v-slot :LayerContents >
4
- <dl >
5
- <dt class =" SignUp-ItemTitle" >お名前(表示名)</dt >
6
- <dd >
7
- <input-field label =" name" placeholder =" 山田花子" require />
8
- </dd >
9
- <dt class =" SignUp-ItemTitle" >メールアドレス</dt >
10
- <dd >
11
- <input-field
12
- label =" email"
13
-
14
- type =" email"
15
- require
2
+ <div >
3
+ <bottom-sheet-layer title =" ユーザー登録" title-en =" STEP 1" fullscreen >
4
+ <template v-slot :LayerContents >
5
+ <dl >
6
+ <dt class =" SignUp-ItemTitle" >お名前(表示名)</dt >
7
+ <dd >
8
+ <input-field
9
+ v-model =" name"
10
+ label =" name"
11
+ placeholder =" 山田花子"
12
+ require
13
+ />
14
+ </dd >
15
+ <dt class =" SignUp-ItemTitle" >メールアドレス</dt >
16
+ <dd >
17
+ <input-field
18
+ v-model =" email"
19
+ label =" email"
20
+
21
+ type =" email"
22
+ require
23
+ />
24
+ </dd >
25
+ <dt class =" SignUp-ItemTitle" >パスワード</dt >
26
+ <dd >
27
+ <input-field
28
+ v-model =" password"
29
+ label =" password"
30
+ type =" password"
31
+ require
32
+ />
33
+ </dd >
34
+ <dt class =" SignUp-ItemTitle" >パスワード(確認用)</dt >
35
+ <dd >
36
+ <input-field
37
+ v-model =" confirmation"
38
+ label =" confirmation"
39
+ type =" password"
40
+ require
41
+ />
42
+ </dd >
43
+ <dt class =" SignUp-ItemTitle text--red" >{{ passwordConfirm }}</dt >
44
+ </dl >
45
+ </template >
46
+ <template v-slot :LayerFooter >
47
+ <div class =" SignUp-ButtonOuter" >
48
+ <action-button
49
+ theme =" transparent"
50
+ text =" キャンセル"
51
+ class =" SignUp-Button"
52
+ @click =" $router.push('/')"
16
53
/>
17
- </dd >
18
- <dt class =" SignUp-ItemTitle" >パスワード</dt >
19
- <dd >
20
- <input-field label =" password" type =" password" require />
21
- </dd >
22
- <dt class =" SignUp-ItemTitle" >パスワード(確認用)</dt >
23
- <dd >
24
- <input-field label =" confirmation" type =" password" require />
25
- </dd >
26
- </dl >
27
- </template >
28
- <template v-slot :LayerFooter >
29
- <div class =" SignUp-ButtonOuter" >
30
- <action-button
31
- theme =" transparent"
32
- text =" キャンセル"
33
- class =" SignUp-Button"
34
- />
35
- <action-button theme =" primary" text =" 登録" class =" SignUp-Button" />
36
- </div >
37
- </template >
38
- </bottom-sheet-layer >
54
+ <action-button
55
+ theme =" primary"
56
+ text =" 登録"
57
+ class =" SignUp-Button"
58
+ :is-disabled =" disableRegisterButton"
59
+ :is-loading =" loading"
60
+ @click =" doSignUp"
61
+ />
62
+ </div >
63
+ </template >
64
+ </bottom-sheet-layer >
65
+ <v-snackbar v-model =" error" :timeout =" 5000" absolute top color =" #C01B61" >
66
+ 何らかのエラーが発生しました。時間をおいて再度お試しください。
67
+ </v-snackbar >
68
+ <v-dialog v-model =" completion" max-width =" 460px" >
69
+ <v-card class =" DialogCard" >
70
+ <v-container class =" DialogCardContentContainer" >
71
+ 入力いただいたメールアドレス宛に確認メールを送信しました。<br />
72
+ メールに記載されているURLから認証を行ってください。
73
+ </v-container >
74
+ <v-card-actions class =" DialogCardButtons px-4" >
75
+ <action-button
76
+ text =" トップに戻る"
77
+ theme =" border"
78
+ class =" my-3"
79
+ @click =" $router.push('/')"
80
+ />
81
+ </v-card-actions >
82
+ </v-card >
83
+ </v-dialog >
84
+ </div >
39
85
</template >
40
86
41
87
<script lang="ts">
42
88
import Vue from ' vue'
43
89
import BottomSheetLayer from ' @/components/BottomSheetLayer.vue'
44
90
import ActionButton from ' @/components/ActionButton.vue'
45
91
import InputField from ' @/components/InputField.vue'
92
+ import firebase from ' @/plugins/firebase'
46
93
47
94
export default Vue .extend ({
48
95
components: { BottomSheetLayer , ActionButton , InputField },
49
- layout: ' background'
96
+ layout: ' background' ,
97
+ data() {
98
+ return {
99
+ name: ' ' ,
100
+ email: ' ' ,
101
+ password: ' ' ,
102
+ confirmation: ' ' ,
103
+ error: false ,
104
+ completion: false ,
105
+ loading: false
106
+ }
107
+ },
108
+ computed: {
109
+ passwordConfirm() {
110
+ if (this .password && this .confirmation ) {
111
+ if (this .password !== this .confirmation ) {
112
+ return ' パスワードが一致していません'
113
+ }
114
+ return ' '
115
+ }
116
+ return ' '
117
+ },
118
+ disableRegisterButton() {
119
+ if (this .password && this .confirmation && this .email && this .name ) {
120
+ if (this .password !== this .confirmation ) {
121
+ return true
122
+ }
123
+ return false
124
+ }
125
+ return true
126
+ }
127
+ },
128
+ methods: {
129
+ doSignUp(): void {
130
+ this .loading = true
131
+ firebase
132
+ .auth ()
133
+ .createUserWithEmailAndPassword (this .email , this .password )
134
+ .then (() => {
135
+ const user = firebase .auth ().currentUser
136
+ if (user ) {
137
+ firebase
138
+ .firestore ()
139
+ .collection (' users' )
140
+ .doc (user .uid )
141
+ .set ({
142
+ username: this .name ,
143
+ allow_access: [],
144
+ created_at: new Date (),
145
+ last_login: new Date (),
146
+ updated_at: new Date ()
147
+ })
148
+ .catch (() => {
149
+ firebase
150
+ .firestore ()
151
+ .collection (' users' )
152
+ .doc (user .uid )
153
+ .set ({
154
+ username: this .name ,
155
+ allow_access: [],
156
+ created_at: new Date (),
157
+ last_login: new Date (),
158
+ updated_at: new Date ()
159
+ })
160
+ })
161
+ user .sendEmailVerification ()
162
+ this .completion = true
163
+ this .loading = false
164
+ }
165
+ })
166
+ .catch (() => {
167
+ this .error = true
168
+ this .loading = false
169
+ })
170
+ }
171
+ }
50
172
})
51
173
</script >
52
174
@@ -65,4 +187,23 @@ export default Vue.extend({
65
187
.SignUp-Button {
66
188
flex : 0 1 48% ;
67
189
}
190
+ .Dialog {
191
+ margin : auto !important ;
192
+ }
193
+ .v-dialog {
194
+ .DialogCard {
195
+ border-radius : 14px ;
196
+
197
+ & Title ,
198
+ & Buttons {
199
+ flex-direction : column ;
200
+ }
201
+
202
+ & Title ,
203
+ & TitleIcon {
204
+ color : $color-base-color-01 ;
205
+ font-size : 16px ;
206
+ }
207
+ }
208
+ }
68
209
</style >
0 commit comments