From 04ecbb837c09448d50e5a4debb8a6f123c437ae7 Mon Sep 17 00:00:00 2001 From: gofnnp Date: Wed, 10 May 2023 13:11:41 +0400 Subject: [PATCH] =?UTF-8?q?dev=20#13995=20=D0=98=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D0=BB=20=D0=B1=D0=B0=D0=B3=D0=B8,=20=D0=B4=D0=BE?= =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=BB=20=D1=82=D0=B0=D0=B9?= =?UTF-8?q?=D0=BC=D0=B5=D1=80=20=D0=B4=D0=BB=D1=8F=20=D0=BE=D1=82=D0=BF?= =?UTF-8?q?=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=BF=D0=BE=D0=B2=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=BA=D0=BE=D0=B4=D0=B0=20?= =?UTF-8?q?=D0=B8=20=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20=D0=BE=D0=B1?= =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA=D1=83=20=D0=BE=D1=88=D0=B8?= =?UTF-8?q?=D0=B1=D0=BE=D0=BA=20=D0=BF=D1=80=D0=B8=20=D0=B0=D0=B2=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../last-order/last-order.component.html | 4 +- .../src/app/pages/login/login.component.html | 10 +++- .../src/app/pages/login/login.component.scss | 3 ++ .../src/app/pages/login/login.component.ts | 50 +++++++++++-------- 4 files changed, 44 insertions(+), 23 deletions(-) diff --git a/angular/src/app/components/last-order/last-order.component.html b/angular/src/app/components/last-order/last-order.component.html index f12cbb5..a5e4b7e 100644 --- a/angular/src/app/components/last-order/last-order.component.html +++ b/angular/src/app/components/last-order/last-order.component.html @@ -1,7 +1,7 @@

Ваш предыдущий заказ

Дата: - {{lastOrder.transactionCreateDate | date:'dd.MM.yyyyг.'}} + {{(lastOrder?.transactionCreateDate | date:'dd.MM.yyyyг.') || 'Данные не найдены'}}

На сумму: - {{lastOrder.orderSum}} ₽ + {{lastOrder?.orderSum ? lastOrder?.orderSum + ' ₽' : 'Данные не найдены'}} -

Не пришло SMS?
Отправим повторно через секунд

+

+ Не пришло SMS?
+ + Отправим повторно через {{timeLeft}}с + + + Отправить повторно + +

diff --git a/angular/src/app/pages/login/login.component.scss b/angular/src/app/pages/login/login.component.scss index 431a4f6..765c9a7 100644 --- a/angular/src/app/pages/login/login.component.scss +++ b/angular/src/app/pages/login/login.component.scss @@ -203,6 +203,9 @@ line-height: 16px; text-align: center; margin-top: 23px; + .resend { + cursor: pointer; + } } } diff --git a/angular/src/app/pages/login/login.component.ts b/angular/src/app/pages/login/login.component.ts index 1da638e..0a60904 100644 --- a/angular/src/app/pages/login/login.component.ts +++ b/angular/src/app/pages/login/login.component.ts @@ -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; }