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