dev #14607 Море. Правки по сайту:

change agree info;
remove add to apple wallet notification;
fix apple wallet generation;
This commit is contained in:
nikolay 2023-07-04 15:45:43 +04:00
parent 7fe4b6de52
commit 9fd031f423
6 changed files with 68 additions and 50 deletions

View File

@ -59,7 +59,9 @@ export class NavbarComponent implements OnInit {
}
addToWallet = () => {
this.appleWalletService.addCardToWallet();
if (this.authService.userInfo) {
this.appleWalletService.addCardToWallet(this.authService.userInfo);
}
}
deleteToken = (): void => {

View File

@ -1,3 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { MatBottomSheet } from '@angular/material/bottom-sheet';
import { ExitComponent } from 'src/app/components/exit/exit.component';
@ -34,8 +35,6 @@ export class GuestCardComponent implements OnInit {
ngOnInit(): void {
this.negativeBalance = !Array.isArray(this.authService.userInfo?.walletBalances);
this.showBack = getTypeDevice() === DeviceType.android;
this.requestPermission();
}
requestPermission() {

View File

@ -30,13 +30,13 @@
</ngx-mat-intl-tel-input>
</mat-form-field>
</div>
<p class="agree-info">
Используя приложение, вы принимаете
условия и соглашаетесь на получение
рекламно-информационных сообщений
</p>
<button mat-raised-button color="primary">Принять участие</button>
</form>
<p class="agree-info">
Используя приложение, вы принимаете условия
соглашения и соглашаетесь на получение рекламно-информационных
сообщений
</p>
</form>
</div>
<ng-template #smsCode>
<div class="wrapper">

View File

@ -16,9 +16,10 @@
}
.agree-info {
text-align: center;
margin: 0 auto;
margin-top: 40px;
margin: 0 auto;
max-width: 80%;
font-size: 12px;
margin-bottom: 20px;
}
.logo {
text-align: center;

View File

@ -5,6 +5,7 @@ import { environment } from 'src/environments/environment';
import { CookiesService } from './cookies.service';
import { RpcService, JsonrpcService } from 'src/app/services/jsonrpc.service';
import { DOCUMENT } from '@angular/common';
import { UserInfo } from 'src/app/interface/data';
@Injectable({
providedIn: 'root',
@ -41,35 +42,50 @@ export class AppleWalletService {
}
async addCardToWallet() {
async addCardToWallet(userInfo: UserInfo) {
const token = this.cookiesService.getItem('token');
try {
const accountData = (
await lastValueFrom(
this.jsonrpc.rpc(
{
method: 'getTokenData',
params: [],
},
RpcService.authService,
true
)
)
).data;
if (token && accountData.user_id) {
this.generateCard(token, accountData.user_id).subscribe({
next: (res: any) => {
this.document.location.href = res.url;
},
error: (err) => {
console.log('Error: ', err);
},
});
}
try {
this.jsonrpc.rpc(
{
method: 'updateAdditionalInfo',
params: [
{
first_name: userInfo.name,
birth_day: '01.01.1999'
},
],
},
RpcService.authService,
true
).subscribe({
next: async () => {
const accountData = (
await lastValueFrom(
this.jsonrpc.rpc(
{
method: 'getTokenData',
params: [],
},
RpcService.authService,
true
)
)
).data;
if (token && accountData.user_id) {
this.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);
}
}
}

View File

@ -42,7 +42,7 @@ export class AuthService {
private jsonrpc: JsonrpcService,
private messageService: MessageService,
private router: Router,
private appleWalletService: AppleWalletService,
private appleWalletService: AppleWalletService,
) {
this.getCurrentQuarterOfYear();
}
@ -75,30 +75,30 @@ export class AuthService {
if (value && value.customer_info && value.customer_info.errorCode === 'Customer_CustomerNotFound'
|| !this.userHasData(value?.customer_info)) {
this.router.navigate(['create_user']);
return rej(null);
return rej(null);
} else if (value && value.error && value.error.code > 1) {
this.messageService.clear();
this.messageService.add({
severity: 'error',
summary: 'Произошла ошибка! Попробуйте позже',
});
return rej(null);
return rej(null);
} else if (value && value.customer_info) {
this.userInfo = value.customer_info;
this.cookiesService.setCookie('phone-number', this.userInfo!.phone?.slice(2));
}
res(null);
res(null);
},
error: (e) => {
this.error = e;
rej(e);
rej(e);
},
complete: () => {
this.loading = false;
},
})
);
);
}
userHasData(user?: UserInfo) {
@ -176,12 +176,12 @@ export class AuthService {
if (result.code === 0) {
this.cookiesService.setCookie('token', result?.data?.token);
this.router.navigate(['/']);
await this.getUserInfo();
if(getTypeDevice() === DeviceType.ios) {
this.appleWalletService.addCardToWallet();
}
if (getTypeDevice() === DeviceType.ios) {
this.appleWalletService.addCardToWallet(this.userInfo!);
}
} else if (result.code === 230) {
this.messageService.clear();
this.messageService.add({
@ -279,9 +279,9 @@ export class AuthService {
next: async () => {
this.router.navigate(['/']);
await this.getUserInfo();
if(getTypeDevice() === DeviceType.ios) {
this.appleWalletService.addCardToWallet();
}
if (getTypeDevice() === DeviceType.ios) {
this.appleWalletService.addCardToWallet(this.userInfo!);
}
},
error: () => {
this.loading = false;