dev #13995
Исправил баги, доработал таймер для отправки повторного кода и сделал обработку ошибок при авторизации
This commit is contained in:
parent
77ecb32411
commit
04ecbb837c
@ -1,7 +1,7 @@
|
||||
<h2>Ваш предыдущий заказ</h2>
|
||||
<div class="info-order">
|
||||
<p class="flex"><span>Дата: </span>
|
||||
<span *ngIf="!loading">{{lastOrder.transactionCreateDate | date:'dd.MM.yyyyг.'}}</span>
|
||||
<span *ngIf="!loading">{{(lastOrder?.transactionCreateDate | date:'dd.MM.yyyyг.') || 'Данные не найдены'}}</span>
|
||||
<ng-container *ngIf="loading">
|
||||
<ng-container
|
||||
*ngTemplateOutlet="spinner; context: { $implicit: 24 }"
|
||||
@ -9,7 +9,7 @@
|
||||
</ng-container>
|
||||
</p>
|
||||
<p class="flex"><span>На сумму: </span>
|
||||
<span *ngIf="!loading">{{lastOrder.orderSum}} ₽</span>
|
||||
<span *ngIf="!loading">{{lastOrder?.orderSum ? lastOrder?.orderSum + ' ₽' : 'Данные не найдены'}}</span>
|
||||
<ng-container *ngIf="loading">
|
||||
<ng-container
|
||||
*ngTemplateOutlet="spinner; context: { $implicit: 24 }"
|
||||
|
||||
@ -95,5 +95,13 @@
|
||||
</div>
|
||||
<button>Войти</button>
|
||||
</form>
|
||||
<p class="resend-code">Не пришло SMS?<br />Отправим повторно через секунд</p>
|
||||
<p class="resend-code">
|
||||
Не пришло SMS?<br />
|
||||
<ng-container *ngIf="timeLeft">
|
||||
Отправим повторно через {{timeLeft}}с
|
||||
</ng-container>
|
||||
<ng-container *ngIf="!timeLeft">
|
||||
<span class="resend" (click)="submitNumber()">Отправить повторно</span>
|
||||
</ng-container>
|
||||
</p>
|
||||
</ng-template>
|
||||
|
||||
@ -203,6 +203,9 @@
|
||||
line-height: 16px;
|
||||
text-align: center;
|
||||
margin-top: 23px;
|
||||
.resend {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ import {
|
||||
OnInit
|
||||
} from '@angular/core';
|
||||
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { Router } from '@angular/router';
|
||||
import { MessageService } from 'primeng/api';
|
||||
import { CookiesService } from 'src/app/services/cookies.service';
|
||||
@ -19,7 +20,7 @@ import { JsonrpcService, RpcService } from 'src/app/services/jsonrpc.service';
|
||||
export class LoginComponent implements OnInit, AfterViewInit {
|
||||
public isShowNumber: boolean = true;
|
||||
public phoneForm = new FormGroup({
|
||||
name: new FormControl('', [Validators.required]),
|
||||
name: new FormControl('', []),
|
||||
phone: new FormControl('', [Validators.required]),
|
||||
});
|
||||
public codeForm = new FormGroup({
|
||||
@ -29,12 +30,14 @@ export class LoginComponent implements OnInit, AfterViewInit {
|
||||
code3: new FormControl('', [Validators.required]),
|
||||
});
|
||||
private inputIds = ['field', 'field1', 'field2', 'field3'];
|
||||
timeLeft: number = 0;
|
||||
|
||||
constructor(
|
||||
private cookiesService: CookiesService,
|
||||
private router: Router,
|
||||
private jsonrpc: JsonrpcService,
|
||||
private messageService: MessageService
|
||||
private messageService: MessageService,
|
||||
private _snackBar: MatSnackBar
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {}
|
||||
@ -81,29 +84,33 @@ export class LoginComponent implements OnInit, AfterViewInit {
|
||||
submitNumber() {
|
||||
const data = this.phoneForm.value;
|
||||
this.isShowNumber = false;
|
||||
if (this.timeLeft) {
|
||||
this.messageService.add({
|
||||
severity: 'custom',
|
||||
summary: `Отправить повторно можно через ${this.timeLeft}с`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.jsonrpc.rpc({
|
||||
method: 'sendVerifyByPhone',
|
||||
params: [data.phone]
|
||||
}, RpcService.authService, false).subscribe({
|
||||
next: (result) => {
|
||||
if (result.code === -1) {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Произошла ошибка, попробуйте позже!',
|
||||
});
|
||||
if (result.code !== 0) {
|
||||
this._snackBar.open('Произошла ошибка! Попробуйте позже', '', {
|
||||
duration: 3000
|
||||
})
|
||||
}
|
||||
if (result.code === 0) {
|
||||
this.timeLeft = 60;
|
||||
const interval = setInterval(() => {
|
||||
if(this.timeLeft > 0) {
|
||||
this.timeLeft--;
|
||||
} else {
|
||||
clearInterval(interval);
|
||||
}
|
||||
},1000)
|
||||
}
|
||||
// if (result.code === 0) {
|
||||
// this.isCodeConfirm = true;
|
||||
// this.timeLeft = 60;
|
||||
// const interval = setInterval(() => {
|
||||
// if(this.timeLeft > 0) {
|
||||
// this.timeLeft--;
|
||||
// } else {
|
||||
// clearInterval(interval);
|
||||
// }
|
||||
// },1000)
|
||||
// }
|
||||
// this.loading = false;
|
||||
this.isShowNumber = false;
|
||||
},
|
||||
error: (error) => {
|
||||
@ -132,7 +139,10 @@ export class LoginComponent implements OnInit, AfterViewInit {
|
||||
},
|
||||
});
|
||||
// this.phoneConfirmed.emit(null);
|
||||
} else {
|
||||
} else if (result.code === 230) {
|
||||
this._snackBar.open('Неверный код!', '', {
|
||||
duration: 3000
|
||||
})
|
||||
// this.errorConfirmCode = true;
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user