dev #14490 WPA CoffeeLike добавление в wallet вместо установки для iOS
This commit is contained in:
parent
425ef99af2
commit
30854f4cb9
@ -4,7 +4,7 @@ import {
|
||||
HostListener,
|
||||
OnInit,
|
||||
Renderer2,
|
||||
Inject,
|
||||
Inject,
|
||||
} from '@angular/core';
|
||||
import { lastValueFrom } from 'rxjs';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
@ -26,11 +26,11 @@ export class DownloadAppDirective implements OnInit {
|
||||
public renderer: Renderer2,
|
||||
private el: ElementRef,
|
||||
private _snackBar: MatSnackBar,
|
||||
private appleWallet: AppleWalletService,
|
||||
private cookiesService: CookiesService,
|
||||
@Inject(DOCUMENT) private document: Document,
|
||||
private jsonrpc: JsonrpcService,
|
||||
) {}
|
||||
private appleWallet: AppleWalletService,
|
||||
private cookiesService: CookiesService,
|
||||
@Inject(DOCUMENT) private document: Document,
|
||||
private jsonrpc: JsonrpcService,
|
||||
) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.getTypeDevice();
|
||||
@ -68,9 +68,10 @@ export class DownloadAppDirective implements OnInit {
|
||||
if (event) {
|
||||
event.preventDefault();
|
||||
}
|
||||
await this.addCardToWallet();
|
||||
return;
|
||||
|
||||
if (this.deviceType === 'ios') {
|
||||
await this.addCardToWallet();
|
||||
return;
|
||||
}
|
||||
if (!this.deferredPrompt) {
|
||||
this.messageService.add({
|
||||
@ -93,29 +94,35 @@ export class DownloadAppDirective implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
async addCardToWallet() {
|
||||
async addCardToWallet() {
|
||||
const token = this.cookiesService.getItem('token');
|
||||
const accountData = (
|
||||
await lastValueFrom(
|
||||
this.jsonrpc.rpc(
|
||||
{
|
||||
method: 'getTokenData',
|
||||
params: [],
|
||||
},
|
||||
RpcService.authService,
|
||||
true
|
||||
try {
|
||||
const accountData = (
|
||||
await lastValueFrom(
|
||||
this.jsonrpc.rpc(
|
||||
{
|
||||
method: 'getTokenData',
|
||||
params: [],
|
||||
},
|
||||
RpcService.authService,
|
||||
true
|
||||
)
|
||||
)
|
||||
)
|
||||
).data;
|
||||
if (token && accountData.user_id) {
|
||||
this.appleWallet.generateCard(token, accountData.user_id).subscribe({
|
||||
next: (res: any) => {
|
||||
this.document.location.href = res.url;
|
||||
},
|
||||
error: (err) => {
|
||||
console.log('Error: ', err);
|
||||
},
|
||||
});
|
||||
).data;
|
||||
|
||||
if (token && accountData.user_id) {
|
||||
this.appleWallet.generateCard(token, accountData.user_id).subscribe({
|
||||
next: (res: any) => {
|
||||
this.document.location.href = res.url;
|
||||
},
|
||||
error: (err) => {
|
||||
console.log('Error: ', err);
|
||||
},
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@ export class GuestCardComponent implements OnInit {
|
||||
public customerInfo!: any;
|
||||
public purchases!: Purchase[];
|
||||
public lastPurchase!: Purchase;
|
||||
public Math: Math = Math;
|
||||
public Math: Math = Math;
|
||||
|
||||
constructor(
|
||||
private _bottomSheet: MatBottomSheet,
|
||||
@ -31,11 +31,11 @@ export class GuestCardComponent implements OnInit {
|
||||
private router: Router,
|
||||
private wpJsonService: WpJsonService,
|
||||
public loyaltyProgram: LoyaltyProgramService
|
||||
) {}
|
||||
) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
const token = this.cookiesService.getItem('token');
|
||||
this.loyaltyProgram.purchaseData.$loading = true;
|
||||
this.loyaltyProgram.purchaseData.$loading = true;
|
||||
this.wpJsonService
|
||||
.getCustomerInfo(
|
||||
environment.systemId,
|
||||
@ -45,6 +45,7 @@ export class GuestCardComponent implements OnInit {
|
||||
.subscribe({
|
||||
next: (value) => {
|
||||
this.customerInfo = value.customer_info;
|
||||
|
||||
this.cookiesService.setCookie('phone-number', this.customerInfo?.phone?.substr(2))
|
||||
this.getPurchases().subscribe((value) => {
|
||||
this.purchases = this.loyaltyProgram.filterPurchases(value[this.customerInfo?.id])
|
||||
@ -55,7 +56,7 @@ export class GuestCardComponent implements OnInit {
|
||||
|
||||
const currentAmount = this.loyaltyProgram.purchaseData.currentAmount || 0
|
||||
this.loyaltyProgram.setCurrentLvl(currentAmount)
|
||||
// this.currentLvlPeriod = this.lvlPeriods.find((item) => item.start <= currentAmount && currentAmount <= (item.end || Infinity))!
|
||||
|
||||
this.loyaltyProgram.purchaseData.$loading = false;
|
||||
});
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user