|
|
|
@ -13,7 +13,7 @@ import { Password } from '../models/password';
|
|
|
|
import { GetLoginInfoRequest } from 'src/app/hmg-common/services/authentication/models/get-login-info.request';
|
|
|
|
import { GetLoginInfoRequest } from 'src/app/hmg-common/services/authentication/models/get-login-info.request';
|
|
|
|
import * as moment from 'moment';
|
|
|
|
import * as moment from 'moment';
|
|
|
|
import { NFC } from "@ionic-native/nfc/ngx";
|
|
|
|
import { NFC } from "@ionic-native/nfc/ngx";
|
|
|
|
|
|
|
|
import { SmsRetriever } from '@ionic-native/sms-retriever/ngx';
|
|
|
|
@Component({
|
|
|
|
@Component({
|
|
|
|
selector: 'app-sms-page',
|
|
|
|
selector: 'app-sms-page',
|
|
|
|
templateUrl: './sms-page.page.html',
|
|
|
|
templateUrl: './sms-page.page.html',
|
|
|
|
@ -53,7 +53,7 @@ export class SmsPageComponent implements OnInit {
|
|
|
|
public showErrorMessage = false;
|
|
|
|
public showErrorMessage = false;
|
|
|
|
public messageValue: string;
|
|
|
|
public messageValue: string;
|
|
|
|
public businessInfo: object;
|
|
|
|
public businessInfo: object;
|
|
|
|
|
|
|
|
public isAutoRead: boolean = false;
|
|
|
|
constructor(
|
|
|
|
constructor(
|
|
|
|
public navCtrl: NavController,
|
|
|
|
public navCtrl: NavController,
|
|
|
|
public translate: TranslatorService,
|
|
|
|
public translate: TranslatorService,
|
|
|
|
@ -62,15 +62,16 @@ export class SmsPageComponent implements OnInit {
|
|
|
|
public authService: AuthenticationService,
|
|
|
|
public authService: AuthenticationService,
|
|
|
|
public sharedData: SharedDataService,
|
|
|
|
public sharedData: SharedDataService,
|
|
|
|
public platform: Platform,
|
|
|
|
public platform: Platform,
|
|
|
|
private nfc: NFC
|
|
|
|
private nfc: NFC,
|
|
|
|
) {}
|
|
|
|
private smsRetriever: SmsRetriever
|
|
|
|
|
|
|
|
) { }
|
|
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
ngOnInit() {
|
|
|
|
this.checkNFCStatus();
|
|
|
|
this.checkNFCStatus();
|
|
|
|
this.activeType=this.common.getActiveTypeLogin();
|
|
|
|
this.activeType = this.common.getActiveTypeLogin();
|
|
|
|
console.log("active "+ this.common.sharedService.getSharedData('active-type',true));
|
|
|
|
console.log("active " + this.common.sharedService.getSharedData('active-type', true));
|
|
|
|
|
|
|
|
|
|
|
|
console.log("activeType :"+this.activeType);
|
|
|
|
console.log("activeType :" + this.activeType);
|
|
|
|
this.count = 0;
|
|
|
|
this.count = 0;
|
|
|
|
this.initTimer();
|
|
|
|
this.initTimer();
|
|
|
|
this.startTimer();
|
|
|
|
this.startTimer();
|
|
|
|
@ -84,16 +85,25 @@ export class SmsPageComponent implements OnInit {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log('deviceToken :' + this.deviceToken);
|
|
|
|
console.log('deviceToken :' + this.deviceToken);
|
|
|
|
this.loginTypeData = this.common.sharedService.getSharedData(SMSCheckRequest.SHARED_DATA, false);
|
|
|
|
this.loginTypeData = this.common.sharedService.getSharedData(SMSCheckRequest.SHARED_DATA, false);
|
|
|
|
if( this.loginTypeData){
|
|
|
|
if (this.loginTypeData) {
|
|
|
|
this.loginType=this.loginTypeData.loginType;
|
|
|
|
this.loginType = this.loginTypeData.loginType;
|
|
|
|
|
|
|
|
|
|
|
|
console.log("loginType :"+this.loginTypeData.loginType);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
this.loginType=1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log("loginType :" + this.loginTypeData.loginType);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
this.loginType = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.smsRetriever.startWatching()
|
|
|
|
|
|
|
|
.then((res: any) => this.checkActivation(res))
|
|
|
|
|
|
|
|
.catch((error: any) => console.error(error));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
checkActivation(res) {
|
|
|
|
|
|
|
|
this.isAutoRead = true;
|
|
|
|
|
|
|
|
var pattern = /\d+/g;
|
|
|
|
|
|
|
|
var code = res.Message.match(pattern)[0];
|
|
|
|
|
|
|
|
this.activationCode = code
|
|
|
|
|
|
|
|
this.smc_code = code.split('');
|
|
|
|
|
|
|
|
this.checkVerificationCode();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
initTimer() {
|
|
|
|
initTimer() {
|
|
|
|
if (!this.timeInSeconds) {
|
|
|
|
if (!this.timeInSeconds) {
|
|
|
|
this.timeInSeconds = 120;
|
|
|
|
this.timeInSeconds = 120;
|
|
|
|
@ -194,7 +204,7 @@ export class SmsPageComponent implements OnInit {
|
|
|
|
request.P_USER_NAME = data.P_USER_NAME;
|
|
|
|
request.P_USER_NAME = data.P_USER_NAME;
|
|
|
|
request.MobileNumber = data.MobileNumber;
|
|
|
|
request.MobileNumber = data.MobileNumber;
|
|
|
|
request.IsDeviceNFC = this.isNFCAvailable;
|
|
|
|
request.IsDeviceNFC = this.isNFCAvailable;
|
|
|
|
this.authService.checkSMS(request, () => {}, this.translate.trPK('general', 'ok'), true).subscribe((result: SMSCheckResponse) => {
|
|
|
|
this.authService.checkSMS(request, () => { }, this.translate.trPK('general', 'ok'), true).subscribe((result: SMSCheckResponse) => {
|
|
|
|
if (this.common.validResponse(result)) {
|
|
|
|
if (this.common.validResponse(result)) {
|
|
|
|
|
|
|
|
|
|
|
|
//save business card info
|
|
|
|
//save business card info
|
|
|
|
@ -206,7 +216,7 @@ export class SmsPageComponent implements OnInit {
|
|
|
|
job_ar: result.MemberInformationList[0].JOB_NAME_Ar,
|
|
|
|
job_ar: result.MemberInformationList[0].JOB_NAME_Ar,
|
|
|
|
mobile: result.MemberInformationList[0].MobileNumberWithZipCode,
|
|
|
|
mobile: result.MemberInformationList[0].MobileNumberWithZipCode,
|
|
|
|
qr: result.MemberInformationList[0].BusinessCardQR,
|
|
|
|
qr: result.MemberInformationList[0].BusinessCardQR,
|
|
|
|
company_logo: result.BC_Logo ? result.BC_Logo: result.CompanyImageURL,
|
|
|
|
company_logo: result.BC_Logo ? result.BC_Logo : result.CompanyImageURL,
|
|
|
|
company_url: result.BC_Domain,
|
|
|
|
company_url: result.BC_Domain,
|
|
|
|
company_type: result.CompanyMainCompany,
|
|
|
|
company_type: result.CompanyMainCompany,
|
|
|
|
email: result.MemberInformationList[0].EMPLOYEE_EMAIL_ADDRESS
|
|
|
|
email: result.MemberInformationList[0].EMPLOYEE_EMAIL_ADDRESS
|
|
|
|
@ -228,7 +238,7 @@ export class SmsPageComponent implements OnInit {
|
|
|
|
this.insertMobileLogin();
|
|
|
|
this.insertMobileLogin();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.common.sharedService.setSharedData(result.MemberInformationList[0].PAYROLL_CODE, "projcet-code");
|
|
|
|
this.common.sharedService.setSharedData(result.MemberInformationList[0].PAYROLL_CODE, "projcet-code");
|
|
|
|
this.activeType =this.common.setActiveTypeLogin(0);
|
|
|
|
this.activeType = this.common.setActiveTypeLogin(0);
|
|
|
|
this.common.openHome();
|
|
|
|
this.common.openHome();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@ -259,7 +269,7 @@ export class SmsPageComponent implements OnInit {
|
|
|
|
request.EmployeeName = this.user_name;
|
|
|
|
request.EmployeeName = this.user_name;
|
|
|
|
this.authService.insertMobileLoginInfo(request, () => { }, this.translate.trPK('general', 'ok'), this.isPostNoLoad)
|
|
|
|
this.authService.insertMobileLoginInfo(request, () => { }, this.translate.trPK('general', 'ok'), this.isPostNoLoad)
|
|
|
|
.subscribe((result: any) => {
|
|
|
|
.subscribe((result: any) => {
|
|
|
|
console.log('successful insertMobileLogin' );
|
|
|
|
console.log('successful insertMobileLogin');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -269,7 +279,7 @@ export class SmsPageComponent implements OnInit {
|
|
|
|
request.LogInTokenID = data.LogInTokenID;
|
|
|
|
request.LogInTokenID = data.LogInTokenID;
|
|
|
|
request.activationCode = this.code; // this.activationCode;
|
|
|
|
request.activationCode = this.code; // this.activationCode;
|
|
|
|
request.P_USER_NAME = data.P_USER_NAME;
|
|
|
|
request.P_USER_NAME = data.P_USER_NAME;
|
|
|
|
this.authService.checkForgetSMS(request, () => {}, this.translate.trPK('general', 'ok')).subscribe((result: SMSCheckResponse) => {
|
|
|
|
this.authService.checkForgetSMS(request, () => { }, this.translate.trPK('general', 'ok')).subscribe((result: SMSCheckResponse) => {
|
|
|
|
if (this.common.validResponse(result)) {
|
|
|
|
if (this.common.validResponse(result)) {
|
|
|
|
this.sharedData.setSharedData(result, 'checkSMSResponse');
|
|
|
|
this.sharedData.setSharedData(result, 'checkSMSResponse');
|
|
|
|
if (this.isForgetPwd) {
|
|
|
|
if (this.isForgetPwd) {
|
|
|
|
@ -285,12 +295,12 @@ export class SmsPageComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
|
|
onChange() {
|
|
|
|
onChange() {
|
|
|
|
// tslint:disable-next-line: only-arrow-functions
|
|
|
|
// tslint:disable-next-line: only-arrow-functions
|
|
|
|
const filtered = this.smc_code.filter(function(el) {
|
|
|
|
const filtered = this.smc_code.filter(function (el) {
|
|
|
|
if (el) {
|
|
|
|
if (el) {
|
|
|
|
return el;
|
|
|
|
return el;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
if (filtered.length === 4) {
|
|
|
|
if (filtered.length === 4 && !this.isAutoRead) {
|
|
|
|
this.checkVerificationCode();
|
|
|
|
this.checkVerificationCode();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|