Merge remote-tracking branch 'remotes/origin/coffee-like-test' into coffee-like

This commit is contained in:
gofnnp 2023-09-05 16:31:48 +04:00
commit f4612ad996
3 changed files with 90 additions and 50 deletions

View File

@ -3,17 +3,35 @@
<div class="guest-card"> <div class="guest-card">
<div class="top-info"> <div class="top-info">
<div class="top-info__level"> <div class="top-info__level">
<p id="level">Уровень {{ authService.error ? '--' : authService.userInfo?.current_level_and_cashback?.current_level }}</p> <p id="level">
<p id="level-percent">Кэшбек {{ authService.error ? '--' : authService.currentLvlPeriod.percent }}%</p> Уровень
{{
authService.error
? "--"
: authService.userInfo?.current_level_and_cashback?.current_level
}}
</p>
<p id="level-percent">
Кэшбек
{{ authService.error ? "--" : authService.currentLvlPeriod.percent }}%
</p>
</div> </div>
<ng-container *ngIf="!authService.error && authService.userInfo!.walletBalances < 0"> <ng-container
*ngIf="!authService.error && authService.userInfo!.walletBalances < 0"
>
<p class="top-info__bonus"> <p class="top-info__bonus">
Отрицательный баланс бонусов, свяжитесь с техподдержкой Отрицательный баланс бонусов, свяжитесь с техподдержкой
</p> </p>
</ng-container> </ng-container>
<ng-container *ngIf="authService.error || authService.userInfo!.walletBalances >= 0"> <ng-container
*ngIf="authService.error || authService.userInfo!.walletBalances >= 0"
>
<p class="top-info__bonus"> <p class="top-info__bonus">
{{ authService.error ? '--' : Math.floor(authService.userInfo!.walletBalances) }} {{
authService.error
? "--"
: Math.floor(authService.userInfo!.walletBalances)
}}
бонусов бонусов
</p> </p>
</ng-container> </ng-container>
@ -26,9 +44,7 @@
[size]="qrCodeSize" [size]="qrCodeSize"
errorCorrectionLevel="H" errorCorrectionLevel="H"
></qr-code> ></qr-code>
<span class="material-icons zoom"> <span class="material-icons zoom"> zoom_in </span>
zoom_in
</span>
</div> </div>
<span>Покажи бариста</span> <span>Покажи бариста</span>
</div> </div>
@ -46,13 +62,11 @@
</ng-container> </ng-container>
<ng-container *ngIf="authService.error"> <ng-container *ngIf="authService.error">
<div class="broken"> <div class="broken">
<img src="./assets/broken.jpg" alt="" /> <img src="./assets/broken.jpg" alt="" />
<p> <p>
Упс, что-то пошло не так.. Упс, что-то пошло не так.. Мы уже работаем над этой проблемой.
Мы уже работаем над этой проблемой. Попробуйте обновить страницу или зайти попозже. Приносим извинения за
Попробуйте обновить страницу или зайти попозже. неудобства.
Приносим извинения за неудобства.
</p> </p>
</div> </div>
</ng-container> </ng-container>
@ -65,7 +79,6 @@
></ng-container> ></ng-container>
</ng-container> </ng-container>
<ng-template #spinner let-diameter> <ng-template #spinner let-diameter>
<div class="center wrapper"> <div class="center wrapper">
<mat-spinner [strokeWidth]="3" [diameter]="diameter"></mat-spinner> <mat-spinner [strokeWidth]="3" [diameter]="diameter"></mat-spinner>

View File

@ -54,13 +54,21 @@ export class GuestCardComponent implements OnInit {
) {} ) {}
ngOnInit(): void { ngOnInit(): void {
this.phone = this.getUserPhone()
this.cookiesService.getItem('phone-number') ||
this.authService.userInfo?.phone;
this.requestPermission(); 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() { requestPermission() {
const userAgent = window.navigator.userAgent.toLowerCase(); const userAgent = window.navigator.userAgent.toLowerCase();
const ios = /iphone|ipod|ipad/.test(userAgent); const ios = /iphone|ipod|ipad/.test(userAgent);

View File

@ -13,6 +13,7 @@ import {
import { lvlPeriods } from 'src/app/app.constants'; import { lvlPeriods } from 'src/app/app.constants';
import moment from 'moment-timezone'; import moment from 'moment-timezone';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { Observable, map } from 'rxjs';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
@ -51,6 +52,24 @@ export class AuthService {
return !!this.token; 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() { getUserInfo() {
const token = this.cookiesService.getItem('token'); const token = this.cookiesService.getItem('token');