From 5a5acb53fd7475c41da34c1849cb456ecf1e69f6 Mon Sep 17 00:00:00 2001 From: gofnnp Date: Tue, 8 Nov 2022 10:28:10 +0400 Subject: [PATCH] =?UTF-8?q?dev=20#13014=20=D0=9F=D0=B5=D1=80=D0=B5=D0=B4?= =?UTF-8?q?=D0=B5=D0=BB=D0=B0=D0=BB=20'=D0=92=D0=B0=D1=88=D0=B0=20=D0=BA?= =?UTF-8?q?=D0=B0=D1=80=D1=82=D0=B0=20=D0=BB=D0=BE=D1=8F=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D0=B8'=20=D0=B8=20'=D0=92=D0=B0=D1=88=D0=B8?= =?UTF-8?q?=20=D1=87=D0=B5=D0=BA=D0=B8'=20=D0=BD=D0=B0=20icard-proxy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- angular/angular.json | 9 +- angular/src/app/app.constants.ts | 28 ++--- angular/src/app/interface/data.ts | 39 +++---- .../app/pages/account/account.component.html | 2 +- .../app/pages/account/auth/auth.component.ts | 10 +- .../bonus-program/bonus-program.component.ts | 102 +++++------------- .../account/orders/orders.component.html | 20 ++-- .../pages/account/orders/orders.component.ts | 45 ++++---- angular/src/app/services/wp-json.service.ts | 18 +++- angular/src/environments/environment.prod.ts | 3 +- angular/src/environments/environment.ts | 3 +- 11 files changed, 129 insertions(+), 150 deletions(-) diff --git a/angular/angular.json b/angular/angular.json index 55a8176..df5e2f1 100644 --- a/angular/angular.json +++ b/angular/angular.json @@ -20,6 +20,7 @@ "builder": "@angular-devkit/build-angular:browser", "options": { "outputPath": "/var/www/html/lk.crm4retail.ru/sakura", + "deleteOutputPath": false, "baseHref": "/", "index": "src/index.html", "main": "src/main.ts", @@ -30,11 +31,10 @@ "src/favicon.ico", "src/assets", "src/manifest.webmanifest", - "src/firebase-messaging-sw.js", - "src/static" + "src/firebase-messaging-sw.js" ], "styles": [ - "node_modules/primeng/resources/themes/bootstrap4-light-blue/theme.css", + "node_modules/primeng/resources/themes/saga-blue/theme.css", "node_modules/primeicons/primeicons.css", "node_modules/primeng/resources/primeng.min.css", "node_modules/ngx-sharebuttons/themes/modern.scss", @@ -85,7 +85,8 @@ "browserTarget": "sakura:build:production" }, "development": { - "browserTarget": "sakura:build:development" + "browserTarget": "sakura:build:development", + "proxyConfig": "proxy.confi.json" } }, "defaultConfiguration": "development" diff --git a/angular/src/app/app.constants.ts b/angular/src/app/app.constants.ts index 8aff840..5b65726 100644 --- a/angular/src/app/app.constants.ts +++ b/angular/src/app/app.constants.ts @@ -36,20 +36,20 @@ export const PageListWithBonus: Page[] = [ resName: 'orders', onSideBar: true, }, - { - code: PageCode.UserData, - name: 'Заполнить анкету', - description: '', - resName: 'user-data', - onSideBar: true - }, - { - code: PageCode.RefSystem, - name: 'Пригласить друга', - description: '', - resName: 'ref-system', - onSideBar: true, - }, + // { + // code: PageCode.UserData, + // name: 'Заполнить анкету', + // description: '', + // resName: 'user-data', + // onSideBar: true + // }, + // { + // code: PageCode.RefSystem, + // name: 'Пригласить друга', + // description: '', + // resName: 'ref-system', + // onSideBar: true, + // }, ]; export const PageListMain: Page[] = [ diff --git a/angular/src/app/interface/data.ts b/angular/src/app/interface/data.ts index 5f9d104..fb5f529 100644 --- a/angular/src/app/interface/data.ts +++ b/angular/src/app/interface/data.ts @@ -32,29 +32,32 @@ export interface UserDataForm { } export interface BonusProgramAccount { - BonusProgramName: string; - BonusProgramTypeID: string; + // BonusProgramName: string; + // BonusProgramTypeID: string; CardNumber: number; Bonuses: number; - HoldedBonuses: number; - BonusProgramAccounts: BonusProgramAccount[]; - DateBonusBurn: string; - _links: any[]; - _embedded: any; + // HoldedBonuses: number; + // BonusProgramAccounts: BonusProgramAccount[]; + // DateBonusBurn: string; + // _links: any[]; + // _embedded: any; } export interface Purchase { - PurchaseId?: string; - CustomerId?: string; - PurchaseDate: string; - PurchaseState?: number; - CardNumber?: number; - Address?: string - CheckSummary?: number - BonusSummary?: number - ID: string; - Transactions: Transaction[]; - IsSingleTransaction?: boolean; + // PurchaseId?: string; + // CustomerId?: string; + // PurchaseDate: string; + // PurchaseState?: number; + // CardNumber?: number; + // Address?: string + // CheckSummary?: number + // BonusSummary?: number + // ID: string; + // Transactions: Transaction[]; + // IsSingleTransaction?: boolean; + transactionCreateDate: string; + orderSum: number; + transactionSum: number; } export interface Transaction { diff --git a/angular/src/app/pages/account/account.component.html b/angular/src/app/pages/account/account.component.html index 2e22bf7..c3225cd 100644 --- a/angular/src/app/pages/account/account.component.html +++ b/angular/src/app/pages/account/account.component.html @@ -32,7 +32,7 @@ - + diff --git a/angular/src/app/pages/account/auth/auth.component.ts b/angular/src/app/pages/account/auth/auth.component.ts index b6eed35..f13a256 100644 --- a/angular/src/app/pages/account/auth/auth.component.ts +++ b/angular/src/app/pages/account/auth/auth.component.ts @@ -83,11 +83,11 @@ export class AuthComponent { next: (result) => { if (result.code === 0) { this.cookiesService.setCookie('token', result?.data?.token); - this.router.navigate(['/auth'], { - queryParams: { - token: result?.data?.token - }, - }); + // this.router.navigate(['/auth'], { + // queryParams: { + // token: result?.data?.token + // }, + // }); this.phoneConfirmed.emit(null); } else { this.errorConfirmCode = true; diff --git a/angular/src/app/pages/account/bonus-program/bonus-program.component.ts b/angular/src/app/pages/account/bonus-program/bonus-program.component.ts index 61897fc..9a8c701 100644 --- a/angular/src/app/pages/account/bonus-program/bonus-program.component.ts +++ b/angular/src/app/pages/account/bonus-program/bonus-program.component.ts @@ -10,6 +10,7 @@ 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'; +import { WpJsonService } from 'src/app/services/wp-json.service'; @Component({ selector: 'app-bonus-program', @@ -34,94 +35,47 @@ export class BonusProgramComponent implements OnInit { private cookiesService: CookiesService, @Inject(DOCUMENT) private document: Document, private http: HttpClient, + private wpJsonService: WpJsonService, ) { } ngOnInit(): void { this.getAccountData(); - this.getTypeDevice() + this.getTypeDevice(); } - getTypeDevice() { - const userAgent = window.navigator.userAgent.toLowerCase() - const ios = /iphone|ipod|ipad/.test( userAgent ); - this.deviceType = ios ? 'ios' : 'android' - } - - async getAccountData(): Promise{ + getAccountData() { + const token = this.cookiesService.getItem('token') + if (!token) { + this.cookiesService.deleteCookie('token') + this.deauthorization.emit(true) + return + } this.loadingBonuses = true; - - this.jsonrpc.rpc({ - method: 'getAdditionalInfo', - params: [] - }, RpcService.authService, true).subscribe({ + this.wpJsonService.getCustomerInfo(environment.systemId, token, environment.icardProxy).subscribe({ next: (res) => { - if (res.code == 334) { - this.cookiesService.deleteCookie('token') - this.deauthorization.emit(true) - return + this.userName = res.customer_info.name + this.accountData = { + CardNumber: res.customer_info.cards[0].Number, + Bonuses: res.customer_info.walletBalances[0].balance } - this.userName = res.data.first_name + barcode("#barcode") + .options({ font: "OCR-B" }) // Will affect all barcodes + .EAN13(`${this.accountData.CardNumber}`.padStart(12, "0"), { fontSize: 18, textMargin: 0 }) + .render(); + this.loadingBonuses = false; }, error: (err) => { console.error('Error: ', err) } - }); + }) + } - this.accountData = (await lastValueFrom( - this.jsonrpc.rpc({ - method: 'GetAccounts', - params: [] - }, - RpcService.bonusService - )))['Cards'][0]; - this.loadingBonuses = false; - - barcode("#barcode") - .options({font: "OCR-B"}) // Will affect all barcodes - .EAN13(`${this.accountData.CardNumber}`.padStart(12, "0"), {fontSize: 18, textMargin: 0}) - .render(); - const transactions: Transaction[] = (await lastValueFrom( - this.jsonrpc.rpc( - { - method: 'GetAccountTransactions', - params: [] - }, - RpcService.bonusService - )))['Transactions']; - - const purchases: Purchase[] = (await lastValueFrom( - this.jsonrpc.rpc( - { - method: 'GetAccountPurchase', - params: [] - }, - RpcService.bonusService - )))['Purchases']; - - this.purchases = purchases.map((purchase) => { - const id = purchase.ID.slice(0,36).toLowerCase(); - purchase.Transactions = transactions.filter((transaction) => { - const same = transaction.Purchase === id; - transaction.HasPurchase = same; - return same; - }); - return purchase; - }); - transactions.forEach((transaction) => { - if(!transaction.HasPurchase){ - this.purchases.push({ - ID: transaction.ID, - PurchaseDate: transaction.Date, - Transactions: [transaction], - IsSingleTransaction: true, - }) - } - }); - this.purchases = this.purchases.sort((a,b) => { - return moment(a.PurchaseDate).date() - moment(b.PurchaseDate).date(); - }); + getTypeDevice() { + const userAgent = window.navigator.userAgent.toLowerCase() + const ios = /iphone|ipod|ipad/.test(userAgent); + this.deviceType = ios ? 'ios' : 'android' } @@ -146,11 +100,11 @@ export class BonusProgramComponent implements OnInit { }, error: (err) => { console.log('Error: ', err); - + } }) } - + } } diff --git a/angular/src/app/pages/account/orders/orders.component.html b/angular/src/app/pages/account/orders/orders.component.html index e467710..19ce809 100644 --- a/angular/src/app/pages/account/orders/orders.component.html +++ b/angular/src/app/pages/account/orders/orders.component.html @@ -9,11 +9,11 @@ > Дата - Место покупки - + --> @@ -35,33 +35,33 @@ class="woocommerce-orders-table__cell woocommerce-orders-table__cell-order-date" data-title="Дата" > -