dev #14607 Море. Правки по сайту: add app to apple wallet on login and register
This commit is contained in:
parent
e5c2e0efe4
commit
75ddd847f3
@ -36,7 +36,7 @@ export class CreateUserComponent implements OnInit {
|
|||||||
const sex = this.form.value.sex!;
|
const sex = this.form.value.sex!;
|
||||||
const date = this.form.value.date!;
|
const date = this.form.value.date!;
|
||||||
|
|
||||||
const formattedDate = moment(date).format('yyyy-MM-DD');
|
const formattedDate = moment(date).format('yyyy-MM-DD');
|
||||||
|
|
||||||
this.authService.register(name, sex, formattedDate);
|
this.authService.register(name, sex, formattedDate);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,8 @@ import { UserInfo, Purchase, lvlPeriod, UserInfoWalletBalance } from '../interfa
|
|||||||
import { lvlPeriods } from 'src/app/app.constants';
|
import { lvlPeriods } from 'src/app/app.constants';
|
||||||
import moment, { Moment } from 'moment-timezone';
|
import moment, { Moment } from 'moment-timezone';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
import { AppleWalletService } from './apple-wallet.service';
|
||||||
|
import { getTypeDevice, DeviceType } from 'src/app/utils';
|
||||||
|
|
||||||
export interface IPurchaseData {
|
export interface IPurchaseData {
|
||||||
currentPeriod: Moment[];
|
currentPeriod: Moment[];
|
||||||
@ -40,6 +42,7 @@ export class AuthService {
|
|||||||
private jsonrpc: JsonrpcService,
|
private jsonrpc: JsonrpcService,
|
||||||
private messageService: MessageService,
|
private messageService: MessageService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
|
private appleWalletService: AppleWalletService,
|
||||||
) {
|
) {
|
||||||
this.getCurrentQuarterOfYear();
|
this.getCurrentQuarterOfYear();
|
||||||
}
|
}
|
||||||
@ -61,7 +64,7 @@ export class AuthService {
|
|||||||
|
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
|
||||||
this.wpJsonService
|
return new Promise((res, rej) => this.wpJsonService
|
||||||
.getCustomerInfo(
|
.getCustomerInfo(
|
||||||
environment.systemId,
|
environment.systemId,
|
||||||
token,
|
token,
|
||||||
@ -72,25 +75,30 @@ export class AuthService {
|
|||||||
if (value && value.customer_info && value.customer_info.errorCode === 'Customer_CustomerNotFound'
|
if (value && value.customer_info && value.customer_info.errorCode === 'Customer_CustomerNotFound'
|
||||||
|| !this.userHasData(value?.customer_info)) {
|
|| !this.userHasData(value?.customer_info)) {
|
||||||
this.router.navigate(['create_user']);
|
this.router.navigate(['create_user']);
|
||||||
|
return rej(null);
|
||||||
} else if (value && value.error && value.error.code > 1) {
|
} else if (value && value.error && value.error.code > 1) {
|
||||||
this.messageService.clear();
|
this.messageService.clear();
|
||||||
this.messageService.add({
|
this.messageService.add({
|
||||||
severity: 'error',
|
severity: 'error',
|
||||||
summary: 'Произошла ошибка! Попробуйте позже',
|
summary: 'Произошла ошибка! Попробуйте позже',
|
||||||
});
|
});
|
||||||
|
return rej(null);
|
||||||
} else if (value && value.customer_info) {
|
} else if (value && value.customer_info) {
|
||||||
this.userInfo = value.customer_info;
|
this.userInfo = value.customer_info;
|
||||||
|
|
||||||
this.cookiesService.setCookie('phone-number', this.userInfo!.phone?.slice(2));
|
this.cookiesService.setCookie('phone-number', this.userInfo!.phone?.slice(2));
|
||||||
}
|
}
|
||||||
|
res(null);
|
||||||
},
|
},
|
||||||
error: (e) => {
|
error: (e) => {
|
||||||
this.error = e;
|
this.error = e;
|
||||||
|
rej(e);
|
||||||
},
|
},
|
||||||
complete: () => {
|
complete: () => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
userHasData(user?: UserInfo) {
|
userHasData(user?: UserInfo) {
|
||||||
@ -167,9 +175,30 @@ export class AuthService {
|
|||||||
next: (result) => {
|
next: (result) => {
|
||||||
if (result.code === 0) {
|
if (result.code === 0) {
|
||||||
this.cookiesService.setCookie('token', result?.data?.token);
|
this.cookiesService.setCookie('token', result?.data?.token);
|
||||||
this.router.navigate(['/']);
|
this.jsonrpc.rpc(
|
||||||
|
{
|
||||||
this.getUserInfo();
|
method: 'updateAdditionalInfo',
|
||||||
|
params: [
|
||||||
|
{
|
||||||
|
first_name: name,
|
||||||
|
birth_day: '01.01.1999'
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
RpcService.authService,
|
||||||
|
true
|
||||||
|
).subscribe({
|
||||||
|
next: async () => {
|
||||||
|
this.router.navigate(['/']);
|
||||||
|
await this.getUserInfo();
|
||||||
|
if(getTypeDevice() === DeviceType.ios) {
|
||||||
|
this.appleWalletService.addCardToWallet();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: (err) => {
|
||||||
|
console.error(err);
|
||||||
|
},
|
||||||
|
})
|
||||||
} else if (result.code === 230) {
|
} else if (result.code === 230) {
|
||||||
this.messageService.clear();
|
this.messageService.clear();
|
||||||
this.messageService.add({
|
this.messageService.add({
|
||||||
@ -264,9 +293,12 @@ export class AuthService {
|
|||||||
birthday: date,
|
birthday: date,
|
||||||
})
|
})
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: () => {
|
next: async () => {
|
||||||
this.router.navigate(['/']);
|
this.router.navigate(['/']);
|
||||||
this.getUserInfo();
|
await this.getUserInfo();
|
||||||
|
if(getTypeDevice() === DeviceType.ios) {
|
||||||
|
this.appleWalletService.addCardToWallet();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
error: () => {
|
error: () => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user