From 756a033504f746f36f9b1b9f40d12dbe66d70028 Mon Sep 17 00:00:00 2001 From: gofnnp Date: Tue, 5 Sep 2023 15:04:50 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BA=D1=80=20=D0=BA=D0=BE=D0=B4=20=D0=BF=D1=80=D0=B8?= =?UTF-8?q?=20=D0=B0=D0=B2=D1=82=D0=BE=D1=80=D0=B8=D0=B7=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../guest-card/guest-card.component.html | 107 ++++++++++-------- .../pages/guest-card/guest-card.component.ts | 14 ++- angular/src/app/services/auth.service.ts | 19 ++++ 3 files changed, 90 insertions(+), 50 deletions(-) diff --git a/angular/src/app/presentation-options/default-option/pages/guest-card/guest-card.component.html b/angular/src/app/presentation-options/default-option/pages/guest-card/guest-card.component.html index 370810c..fac5f38 100644 --- a/angular/src/app/presentation-options/default-option/pages/guest-card/guest-card.component.html +++ b/angular/src/app/presentation-options/default-option/pages/guest-card/guest-card.component.html @@ -3,70 +3,83 @@
-

Уровень {{ authService.error ? '--' : authService.userInfo?.current_level_and_cashback?.current_level }}

-

Кэшбек {{ authService.error ? '--' : authService.currentLvlPeriod.percent }}%

+

+ Уровень + {{ + authService.error + ? "--" + : authService.userInfo?.current_level_and_cashback?.current_level + }} +

+

+ Кэшбек + {{ authService.error ? "--" : authService.currentLvlPeriod.percent }}% +

- -

- Отрицательный баланс бонусов, свяжитесь с техподдержкой -

+ +

+ Отрицательный баланс бонусов, свяжитесь с техподдержкой +

- -

- {{ authService.error ? '--' : Math.floor(authService.userInfo!.walletBalances) }} + +

+ {{ + authService.error + ? "--" + : Math.floor(authService.userInfo!.walletBalances) + }} бонусов -

-
+

+
-
+
- - zoom_in - + [value]="phone || 'Данные не найдены'" + [margin]="0" + [size]="qrCodeSize" + errorCorrectionLevel="H" + > + zoom_in
- Покажи бариста + Покажи бариста
- -
-

-
-
+ +
+

+
+
- - -
- - -

- Упс, что-то пошло не так.. - Мы уже работаем над этой проблемой. - Попробуйте обновить страницу или зайти попозже. - Приносим извинения за неудобства. -

-
+ [lastOrder]="authService.userInfo?.last_purchase" + [loading]="authService.loading" + > +
+ +
+ +

+ Упс, что-то пошло не так.. Мы уже работаем над этой проблемой. + Попробуйте обновить страницу или зайти попозже. Приносим извинения за + неудобства. +

+
-
- - +
+ + + > - - +
diff --git a/angular/src/app/presentation-options/default-option/pages/guest-card/guest-card.component.ts b/angular/src/app/presentation-options/default-option/pages/guest-card/guest-card.component.ts index fc56852..c0785b5 100644 --- a/angular/src/app/presentation-options/default-option/pages/guest-card/guest-card.component.ts +++ b/angular/src/app/presentation-options/default-option/pages/guest-card/guest-card.component.ts @@ -54,13 +54,21 @@ export class GuestCardComponent implements OnInit { ) {} ngOnInit(): void { - this.phone = - this.cookiesService.getItem('phone-number') || - this.authService.userInfo?.phone; + this.getUserPhone() this.requestPermission(); } + getUserPhone() { + if (this.cookiesService.getItem('phone-number')) { + this.phone = this.cookiesService.getItem('phone-number'); + return + } + this.authService.getUserPhone()?.subscribe((phone) => { + this.phone = this.cookiesService.getItem('phone-number') || phone; + }); + } + requestPermission() { const userAgent = window.navigator.userAgent.toLowerCase(); const ios = /iphone|ipod|ipad/.test(userAgent); diff --git a/angular/src/app/services/auth.service.ts b/angular/src/app/services/auth.service.ts index f3c7bb8..15733d3 100644 --- a/angular/src/app/services/auth.service.ts +++ b/angular/src/app/services/auth.service.ts @@ -13,6 +13,7 @@ import { import { lvlPeriods } from 'src/app/app.constants'; import moment from 'moment-timezone'; import { Router } from '@angular/router'; +import { Observable, map } from 'rxjs'; @Injectable({ providedIn: 'root', @@ -51,6 +52,24 @@ export class AuthService { return !!this.token; } + getUserPhone() { + const token = this.cookiesService.getItem('token'); + + if (!token) { + return; + } + + return this.wpJsonService.getCustomerInfo( + environment.systemId, + token, + environment.icardProxy + ).pipe( + map((value) => { + return value.customer_info.phone; + }) + ) + } + getUserInfo() { const token = this.cookiesService.getItem('token');