This commit is contained in:
Nguyen Ha Khue
2023-05-01 16:11:19 +07:00
3 changed files with 253 additions and 182 deletions
+207 -158
View File
File diff suppressed because it is too large Load Diff
@@ -116,8 +116,8 @@
</div>
</div>
<!-- phone number -->
<div class="form-group row">
<!--capcha -->
<div *ngIf="isSend" class="form-group row">
<div class="col-xl-3 col-md-4">
<label for="validationCustom2"><span></span></label>
</div>
@@ -429,4 +429,11 @@
<h5>Vui lòng điền đầy đủ thông tin trước khi tạo tài khoản.</h5>
<button type="button" class="btn btn-primary" (click)="closeLayer2()">Tiếp tục</button>
</div>
</ng-template>
<ng-template #empty_phonenumber>
<div class="modal-body text-center">
<h5>Số điện thoại không được bỏ trống.</h5>
<button type="button" class="btn btn-primary" (click)="closeLayer2()">Tiếp tục</button>
</div>
</ng-template>
@@ -70,18 +70,19 @@ export class SignupComponent {
@ViewChild('error_modal') errorModal: TemplateRef<any>;
@ViewChild('miss_info') missInfoModal: TemplateRef<any>;
@ViewChild('miss_otp') missOTPModal: TemplateRef<any>;
@ViewChild('empty_phonenumber') emptyPhoneNumber: TemplateRef<any>;
//Phonenumber
isSend: boolean = false;
isVerified: boolean = false;
reCaptchaVerifier;
verify;
constructor(
private formBuilder: FormBuilder,
private authService: AuthService,
private firebaseAuth: AngularFireAuth,
private districtService: DistrictService,
private storage: AngularFireStorage,
private shopService: ShopService,
private modalService: BsModalService,
private router: Router,
private firebaseService: FirebaseService
@@ -337,29 +338,43 @@ export class SignupComponent {
}
getOTP() {
this.reCaptchaVerifier = new firebase.auth.RecaptchaVerifier(
'recapcha',
{
size: 'visible',
}
);
const reg: User = new User();
reg.phoneNumber = this.userPhoneNumber.value;
firebase
.auth()
.signInWithPhoneNumber('+84 ' + this.userPhoneNumber.value, this.reCaptchaVerifier)
.then((confirmationResult) => {
if (this.userPhoneNumber.value == '') {
this.layer2 = this.modalService.show(this.emptyPhoneNumber, { class: 'modal-sm' });
}
else {
this.authService.checkEmailOrPhoneNumberExist(reg).subscribe((response) => {
if (response.title == 'phoneNumExist') {
this.errorItem = "Số điện thoại"
this.layer2 = this.modalService.show(this.errorModal, { class: 'modal-sm' });
}
else {
this.isSend = true;
this.reCaptchaVerifier = new firebase.auth.RecaptchaVerifier(
'recapcha',
{
size: 'visible',
}
);
this.verify = confirmationResult.verificationId;
firebase
.auth()
.signInWithPhoneNumber('+84 ' + this.userPhoneNumber.value, this.reCaptchaVerifier)
.then((confirmationResult) => {
this.verify = confirmationResult.verificationId;
})
.catch((error) => {
//Catch error
alert(error.message);
setTimeout(() => {
window.location.reload();
}, 5000);
});
}
})
.catch((error) => {
//Catch error
console.log(error.message);
alert(error.message);
setTimeout(() => {
window.location.reload();
}, 5000);
});
}
}
//Districts and Wards