parent
134ee3f59d
commit
e558fcabc0
@ -47,4 +47,5 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <button *ngIf="deviceType == 'ios'" class="add-to-wallet" (click)="addCardToWallet($event)">Добавить в Apple Wallet</button> -->
|
||||
</div>
|
||||
|
||||
@ -3,14 +3,14 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
&>h2 {
|
||||
& > h2 {
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
font-size: 20px;
|
||||
line-height: 24px;
|
||||
}
|
||||
|
||||
&>p {
|
||||
& > p {
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
font-size: 15px;
|
||||
@ -154,12 +154,12 @@
|
||||
}
|
||||
|
||||
&.active_back {
|
||||
>.card-content__front {
|
||||
> .card-content__front {
|
||||
transform: rotateY(180deg);
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
>.card-content__back {
|
||||
> .card-content__back {
|
||||
opacity: 1;
|
||||
transform: rotateY(0deg);
|
||||
}
|
||||
@ -196,5 +196,14 @@
|
||||
font-size: 12px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.add-to-wallet {
|
||||
margin-top: 12px;
|
||||
height: 36px;
|
||||
border-radius: 8px;
|
||||
background: #09467f;
|
||||
border-color: #09467f;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { lastValueFrom } from 'rxjs';
|
||||
import { orderStatuses, PageList, PageListWithBonus } from 'src/app/app.constants';
|
||||
import { BonusProgramAccount, Page, Purchase, Transaction } from 'src/app/interface/data';
|
||||
@ -6,6 +6,10 @@ import { JsonrpcService, RpcService } from 'src/app/services/jsonrpc.service';
|
||||
import * as moment from 'moment-timezone';
|
||||
import * as barcode from 'jsbarcode';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { AppleWalletService } from 'src/app/services/apple-wallet.service';
|
||||
import { CookiesService } from 'src/app/services/cookies.service';
|
||||
import { DOCUMENT } from '@angular/common';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
|
||||
@Component({
|
||||
selector: 'app-bonus-program',
|
||||
@ -22,13 +26,25 @@ export class BonusProgramComponent implements OnInit {
|
||||
readonly pageList = environment.hasBonusProgram ? PageListWithBonus : PageList;
|
||||
public currentPage: Page = this.pageList[1];
|
||||
public userName: string = '';
|
||||
public deviceType: 'ios' | 'android' | null = null;
|
||||
|
||||
constructor(
|
||||
private jsonrpc: JsonrpcService,
|
||||
private appleWallet: AppleWalletService,
|
||||
private cookiesService: CookiesService,
|
||||
@Inject(DOCUMENT) private document: Document,
|
||||
private http: HttpClient,
|
||||
) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.getAccountData();
|
||||
this.getTypeDevice()
|
||||
}
|
||||
|
||||
getTypeDevice() {
|
||||
const userAgent = window.navigator.userAgent.toLowerCase()
|
||||
const ios = /iphone|ipod|ipad/.test( userAgent );
|
||||
this.deviceType = ios ? 'ios' : 'android'
|
||||
}
|
||||
|
||||
async getAccountData(): Promise<void>{
|
||||
@ -101,4 +117,22 @@ export class BonusProgramComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
addCardToWallet(e: any) {
|
||||
e.preventDefault()
|
||||
const token = this.cookiesService.getItem('token')
|
||||
if (token) {
|
||||
this.appleWallet.generateCard(token).subscribe({
|
||||
next: (res: any) => {
|
||||
this.document.location.href = res.url
|
||||
},
|
||||
error: (err) => {
|
||||
console.log('Error: ', err);
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
22
src/app/services/apple-wallet.service.ts
Normal file
22
src/app/services/apple-wallet.service.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { environment } from 'src/environments/environment';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class AppleWalletService {
|
||||
private url: string = environment.appleWalletEndpoint;
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
) {}
|
||||
|
||||
generateCard(token: string) {
|
||||
let headers = new HttpHeaders();
|
||||
headers = headers.set('Authorization', environment.appleWalletSecret);
|
||||
const options = {
|
||||
headers: headers,
|
||||
};
|
||||
return this.http.get(`${this.url}/client/${environment.clientName}/passUrl/${token}`, options)
|
||||
}
|
||||
}
|
||||
@ -18,4 +18,7 @@ export const environment = {
|
||||
measurementId: 'G-RQF97ZK7R1',
|
||||
},
|
||||
version: packageJson.version,
|
||||
appleWalletEndpoint: 'https://ru-academy.online/apns/api',
|
||||
appleWalletSecret: 'Token Z_vtuf_flvby!',
|
||||
clientName: 'fashionlogica'
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user