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 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);
|
||||
}
|
||||
|
||||
@ -8,6 +8,8 @@ import { UserInfo, Purchase, lvlPeriod, UserInfoWalletBalance } from '../interfa
|
||||
import { lvlPeriods } from 'src/app/app.constants';
|
||||
import moment, { Moment } from 'moment-timezone';
|
||||
import { Router } from '@angular/router';
|
||||
import { AppleWalletService } from './apple-wallet.service';
|
||||
import { getTypeDevice, DeviceType } from 'src/app/utils';
|
||||
|
||||
export interface IPurchaseData {
|
||||
currentPeriod: Moment[];
|
||||
@ -40,6 +42,7 @@ export class AuthService {
|
||||
private jsonrpc: JsonrpcService,
|
||||
private messageService: MessageService,
|
||||
private router: Router,
|
||||
private appleWalletService: AppleWalletService,
|
||||
) {
|
||||
this.getCurrentQuarterOfYear();
|
||||
}
|
||||
@ -61,7 +64,7 @@ export class AuthService {
|
||||
|
||||
this.loading = true;
|
||||
|
||||
this.wpJsonService
|
||||
return new Promise((res, rej) => this.wpJsonService
|
||||
.getCustomerInfo(
|
||||
environment.systemId,
|
||||
token,
|
||||
@ -72,25 +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);
|
||||
} else if (value && value.error && value.error.code > 1) {
|
||||
this.messageService.clear();
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Произошла ошибка! Попробуйте позже',
|
||||
});
|
||||
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);
|
||||
},
|
||||
error: (e) => {
|
||||
this.error = e;
|
||||
rej(e);
|
||||
},
|
||||
complete: () => {
|
||||
this.loading = false;
|
||||
},
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
userHasData(user?: UserInfo) {
|
||||
@ -167,9 +175,30 @@ export class AuthService {
|
||||
next: (result) => {
|
||||
if (result.code === 0) {
|
||||
this.cookiesService.setCookie('token', result?.data?.token);
|
||||
this.router.navigate(['/']);
|
||||
|
||||
this.getUserInfo();
|
||||
this.jsonrpc.rpc(
|
||||
{
|
||||
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) {
|
||||
this.messageService.clear();
|
||||
this.messageService.add({
|
||||
@ -264,9 +293,12 @@ export class AuthService {
|
||||
birthday: date,
|
||||
})
|
||||
.subscribe({
|
||||
next: () => {
|
||||
next: async () => {
|
||||
this.router.navigate(['/']);
|
||||
this.getUserInfo();
|
||||
await this.getUserInfo();
|
||||
if(getTypeDevice() === DeviceType.ios) {
|
||||
this.appleWalletService.addCardToWallet();
|
||||
}
|
||||
},
|
||||
error: () => {
|
||||
this.loading = false;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user