auto sms android IOS

sultan-q3
Sultan Khan 4 years ago
parent e765d81711
commit de93db93d5

@ -1,70 +1,142 @@
<app-generic-header <app-generic-header
showBack="true"
[headerText]="'verificationcode,verificationcode' | translate"> showBack="true"
[headerText]="'verificationcode,verificationcode' | translate">
</app-generic-header> </app-generic-header>
<ion-content padding> <ion-content padding>
<ion-grid>
<!-- <ion-row> <ion-grid>
<ion-col [size]="4">
<img [src]="logo" class="logo" /> <!-- <ion-row>
<ion-img class="centerDiv" src="../assets/imgs/CS.png"></ion-img> <ion-col [size]="4">
</ion-col>
</ion-row> --> <img [src]="logo" class="logo" />
<br/>
<br/>
<ion-row>
<ion-col> <ion-img class="centerDiv" src="../assets/imgs/CS.png"></ion-img>
<p class="headerTxt" > {{'verificationcode,verificationcode' | translate}}</p>
<br/> </ion-col>
<p class="leftDiv">{{'verificationcode,title' | translate}}
<span class="boldTxtNav">{{'verificationcode,verificationcode' | translate}}</span> </ion-row> -->
{{'verificationcode,by' | translate}}
<span *ngIf="loginType == 1 || activeType == 1" class="boldTxtNav">{{'verificationcode , sms' | translate}}, </span> <br/>
<span *ngIf="loginType == 4 || activeType == 4" class="boldTxtNav">{{'verificationcode , whatsapp' | translate}}, </span>
<br/>
{{'verificationcode,instruct' | translate}}
<span class="boldTxtNav">{{'general,submit' | translate}}</span <ion-row>
></p>
<!-- <p class="leftDiv">{{'verificationcode,title' | translate}}<span class="boldTxtNav">{{'verificationcode,verificationcode' | translate}}</span> {{'verificationcode,by' | translate}}<span class="boldTxtNav">{{'verificationcode,sms' | translate}}</span>{{'verificationcode,instruct' | translate}}<span class="boldTxtNav">{{'general,submit' | translate}}</span></p> --> <ion-col>
</ion-col>
</ion-row> <p class="headerTxt" > {{'verificationcode,verificationcode' | translate}}</p>
</ion-grid>
<br/><br/> <br/>
<!-- <p style="color: #c0c0c0; margin-left: 32%">{{'verificationcode.verificationcode' | translate}}</p> -->
<div> <p class="leftDiv">{{'verificationcode,title' | translate}}
<h1 text-center>{{displayTime}}</h1>
<br/><br/> <span class="boldTxtNav">{{'verificationcode,verificationcode' | translate}}</span>
<!-- <ion-item>
//<ion-label>{{'verificationcode,verificationcode' | translate}}</ion-label> {{'verificationcode,by' | translate}}
// <img class="item-icon" src="assets/imgs/password.png" item-start />
<ion-input required type="tel" maxlength="4" (keyup)="checkOTPLength()" placeholder="{{translate.trPK('verificationcode','verificationcode')}}" [(ngModel)]="activationCode"></ion-input> <span *ngIf="loginType == 1 || activeType == 1" class="boldTxtNav">{{'verificationcode , sms' | translate}}, </span>
</ion-item> -->
<span *ngIf="loginType == 4 || activeType == 4" class="boldTxtNav">{{'verificationcode , whatsapp' | translate}}, </span>
<ion-row class="sms_code" dir="ltr">
<ion-col [size]="12">
<ion-input type="tel" [(ngModel)]="smc_code[0]" maxLength="1" size="1" min="0" max="9" pattern="[0-9]{1}"
inputmode="tel" (ionInput)="goToNextInput($event)" (ionChange)="onChange()" #ref autofocus="true"> {{'verificationcode,instruct' | translate}}
</ion-input>
<span class="boldTxtNav">{{'general,submit' | translate}}</span
<ion-input type="tel" [(ngModel)]="smc_code[1]" maxLength="1" size="1" min="0" max="9" pattern="[0-9]{1}"
inputmode="tel" (ionInput)="goToNextInput($event)" (ionChange)="onChange()"></ion-input> ></p>
<ion-input type="tel" [(ngModel)]="smc_code[2]" maxLength="1" size="1" min="0" max="9" pattern="[0-9]{1}"
inputmode="tel" (ionInput)="goToNextInput($event)" (ionChange)="onChange()"></ion-input> <!-- <p class="leftDiv">{{'verificationcode,title' | translate}}<span class="boldTxtNav">{{'verificationcode,verificationcode' | translate}}</span> {{'verificationcode,by' | translate}}<span class="boldTxtNav">{{'verificationcode,sms' | translate}}</span>{{'verificationcode,instruct' | translate}}<span class="boldTxtNav">{{'general,submit' | translate}}</span></p> -->
<ion-input type="tel" [(ngModel)]="smc_code[3]" maxLength="1" size="1" min="0" max="9" pattern="[0-9]{1}"
inputmode="tel" (ionInput)="goToNextInput($event)" (ionChange)="onChange()"></ion-input> </ion-col>
</ion-row>
</ion-grid>
<br/><br/>
<!-- <p style="color: #c0c0c0; margin-left: 32%">{{'verificationcode.verificationcode' | translate}}</p> -->
<div>
<h1 text-center>{{displayTime}}</h1>
<br/><br/>
<!-- <ion-item>
//<ion-label>{{'verificationcode,verificationcode' | translate}}</ion-label>
// <img class="item-icon" src="assets/imgs/password.png" item-start />
<ion-input required type="tel" maxlength="4" (keyup)="checkOTPLength()" placeholder="{{translate.trPK('verificationcode','verificationcode')}}" [(ngModel)]="activationCode"></ion-input>
</ion-item> -->
<ion-row class="sms_code" dir="ltr">
<ion-col [size]="12">
<ion-input type="tel" [(ngModel)]="smc_code[0]" maxLength="4" size="4" min="0" max="9" pattern="[0-9]{1}"
inputmode="tel" (ionInput)="goToNextInput($event)" (ionChange)="onChange()" #ref autofocus="true">
</ion-input>
<ion-input type="tel" [(ngModel)]="smc_code[1]" maxLength="1" size="1" min="0" max="9" pattern="[0-9]{1}"
inputmode="tel" (ionInput)="goToNextInput($event)" (ionChange)="onChange()"></ion-input>
<ion-input type="tel" [(ngModel)]="smc_code[2]" maxLength="1" size="1" min="0" max="9" pattern="[0-9]{1}"
inputmode="tel" (ionInput)="goToNextInput($event)" (ionChange)="onChange()"></ion-input>
<ion-input type="tel" [(ngModel)]="smc_code[3]" maxLength="1" size="1" min="0" max="9" pattern="[0-9]{1}"
inputmode="tel" (ionInput)="goToNextInput($event)" (ionChange)="onChange()"></ion-input>
</ion-col> </ion-col>
</ion-row> </ion-row>
<div *ngIf="showErrorMessage"><p style="color: red; font-weight: bold; font-size: 14px; text-align: center;">{{messageValue}}</p></div> <div *ngIf="showErrorMessage"><p style="color: red; font-weight: bold; font-size: 14px; text-align: center;">{{messageValue}}</p></div>
</div> </div>
</ion-content> </ion-content>
<ion-footer> <ion-footer>
<div class="centerDiv">
<ion-button class="button-login" ion-button (click)="checkVerificationCode()">{{'general,submit' | translate}}</ion-button> <div class="centerDiv">
</div>
</ion-footer> <ion-button class="button-login" ion-button (click)="checkVerificationCode()">{{'general,submit' | translate}}</ion-button>
</div>
</ion-footer>

@ -1,335 +1,682 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { ElementRef } from '@angular/core'; import { ElementRef } from '@angular/core';
import { NavController, Platform } from '@ionic/angular'; import { NavController, Platform } from '@ionic/angular';
import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service'; import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service';
import { CommonService } from 'src/app/hmg-common/services/common/common.service'; import { CommonService } from 'src/app/hmg-common/services/common/common.service';
import { SharedDataService } from 'src/app/hmg-common/services/shared-data-service/shared-data.service'; import { SharedDataService } from 'src/app/hmg-common/services/shared-data-service/shared-data.service';
import { SMSCheckRequest } from 'src/app/hmg-common/services/authentication/models/smscheck.request'; import { SMSCheckRequest } from 'src/app/hmg-common/services/authentication/models/smscheck.request';
import { LoginModel } from '../models/LoginModel'; import { LoginModel } from '../models/LoginModel';
import { AuthenticationService } from 'src/app/hmg-common/services/authentication/authentication.service'; import { AuthenticationService } from 'src/app/hmg-common/services/authentication/authentication.service';
import { SMSCheckResponse } from 'src/app/hmg-common/services/authentication/models/smscheck.response'; import { SMSCheckResponse } from 'src/app/hmg-common/services/authentication/models/smscheck.response';
import { Password } from '../models/password'; 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'; 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',
styleUrls: ['./sms-page.page.scss'] styleUrls: ['./sms-page.page.scss']
}) })
export class SmsPageComponent implements OnInit { export class SmsPageComponent implements OnInit {
public static LOGIN_DATA = 'LOGIN_DATA'; public static LOGIN_DATA = 'LOGIN_DATA';
Channel = 0; Channel = 0;
activationCode: string; activationCode: string;
P_SESSION_ID: number; P_SESSION_ID: number;
P_USER_NAME: string; P_USER_NAME: string;
timeInSeconds: any; timeInSeconds: any;
time: any; time: any;
runTimer: any; runTimer: any;
hasStarted: any; hasStarted: any;
hasFinished: any; hasFinished: any;
remainingTime: any; remainingTime: any;
displayTime: any; displayTime: any;
loginTokenID: string; loginTokenID: string;
public isForgetPwd = false; public isForgetPwd = false;
public isExpiredPwd = false; public isExpiredPwd = false;
public count = 0; public count = 0;
private loginData = new LoginModel(); private loginData = new LoginModel();
public deviceToken: any; public deviceToken: any;
public loginTypeData: any; public loginTypeData: any;
public logo = 'assets/icon/login/password.png'; public logo = 'assets/icon/login/password.png';
// tslint:disable-next-line: variable-name // tslint:disable-next-line: variable-name
public smc_code: any = []; public smc_code: any = [];
code: any; code: any;
// tslint:disable-next-line: variable-name // tslint:disable-next-line: variable-name
user_name: string; user_name: string;
public isPostNoLoad = true; public isPostNoLoad = true;
loginType: any; loginType: any;
activeType: any; activeType: any;
public isNFCAvailable = false; public isNFCAvailable = false;
public showErrorMessage = false; public showErrorMessage = false;
public messageValue: string; public messageValue: string;
public businessInfo: object; public businessInfo: object;
public isAutoRead: boolean = false; public isAutoRead: boolean = false;
constructor( constructor(
public navCtrl: NavController, public navCtrl: NavController,
public translate: TranslatorService, public translate: TranslatorService,
public common: CommonService, public common: CommonService,
private elementRef: ElementRef, private elementRef: ElementRef,
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 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();
this.isForgetPwd = this.sharedData.getSharedData(Password.IS_FORGET_PSW) || false; this.isForgetPwd = this.sharedData.getSharedData(Password.IS_FORGET_PSW) || false;
this.isExpiredPwd = this.sharedData.getSharedData(Password.IS_EXPIRED_PSW) || false; this.isExpiredPwd = this.sharedData.getSharedData(Password.IS_EXPIRED_PSW) || false;
this.loginData = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false); this.loginData = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false);
this.deviceToken = this.common.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false); this.deviceToken = this.common.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false);
// tslint:disable-next-line: triple-equals // tslint:disable-next-line: triple-equals
if (this.deviceToken == undefined) { if (this.deviceToken == undefined) {
this.deviceToken = localStorage.getItem('deviceToken'); this.deviceToken = localStorage.getItem('deviceToken');
} }
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); console.log("loginType :" + this.loginTypeData.loginType);
} else { } else {
this.loginType = 1; this.loginType = 1;
} }
this.smsRetriever.startWatching() this.smsRetriever.startWatching()
.then((res: any) => this.checkActivation(res))
.then((res: any) => this.checkActivation(res, true))
.catch((error: any) => console.error(error)); .catch((error: any) => console.error(error));
} }
checkActivation(res) {
checkActivation(res, isAndroid) {
this.isAutoRead = true; this.isAutoRead = true;
var pattern = /\d+/g; var pattern = /\d+/g;
var code = res.Message.match(pattern)[0];
if (isAndroid)
var code = res.Message.match(pattern)[0];
else
var code = res;
this.activationCode = code this.activationCode = code
this.smc_code = code.split(''); this.smc_code = code.split('');
this.checkVerificationCode(); this.checkVerificationCode();
} }
initTimer() { initTimer() {
if (!this.timeInSeconds) { if (!this.timeInSeconds) {
this.timeInSeconds = 120; this.timeInSeconds = 120;
} }
this.time = this.timeInSeconds; this.time = this.timeInSeconds;
this.runTimer = false; this.runTimer = false;
this.hasStarted = false; this.hasStarted = false;
this.hasFinished = false; this.hasFinished = false;
this.remainingTime = this.timeInSeconds; this.remainingTime = this.timeInSeconds;
this.displayTime = this.common.getSecondsAsDigitalClock(this.remainingTime); this.displayTime = this.common.getSecondsAsDigitalClock(this.remainingTime);
} }
startTimer() { startTimer() {
this.runTimer = true; this.runTimer = true;
this.hasStarted = true; this.hasStarted = true;
this.timerTick(); this.timerTick();
} }
pauseTimer() { pauseTimer() {
this.runTimer = false; this.runTimer = false;
} }
resumeTimer() { resumeTimer() {
this.startTimer(); this.startTimer();
} }
timerTick() { timerTick() {
setTimeout(() => { setTimeout(() => {
if (!this.runTimer) { if (!this.runTimer) {
return; return;
} }
this.remainingTime--; this.remainingTime--;
this.displayTime = this.common.getSecondsAsDigitalClock(this.remainingTime); this.displayTime = this.common.getSecondsAsDigitalClock(this.remainingTime);
if (this.remainingTime > 0) { if (this.remainingTime > 0) {
this.timerTick(); this.timerTick();
} else { } else {
this.hasFinished = true; this.hasFinished = true;
this.pauseTimer(); this.pauseTimer();
this.navCtrl.pop(); this.navCtrl.pop();
} }
}, 1000); }, 1000);
} }
ionViewWillLeave() { ionViewWillLeave() {
this.pauseTimer(); this.pauseTimer();
} }
checkOTPLength() { checkOTPLength() {
// tslint:disable-next-line: triple-equals // tslint:disable-next-line: triple-equals
if (this.activationCode.length == 4) { if (this.activationCode.length == 4) {
this.checkVerificationCode(); this.checkVerificationCode();
} }
} }
checkVerificationCode() { checkVerificationCode() {
this.code = this.smc_code.join(''); this.code = this.smc_code.join('');
if (this.count < 3) { if (this.count < 3) {
// tslint:disable-next-line: triple-equals // tslint:disable-next-line: triple-equals
if (this.code == undefined || this.code == null || this.code == '') { if (this.code == undefined || this.code == null || this.code == '') {
// this.common.showAlert(this.translate.translate('verificationcode.emptyCode'));
// this.common.showAlert(this.translate.translate('verificationcode.emptyCode'));
} else { } else {
this.count = this.count + 1; this.count = this.count + 1;
if (this.isForgetPwd || this.isExpiredPwd) { if (this.isForgetPwd || this.isExpiredPwd) {
this.checkForgetPwdSMS(); this.checkForgetPwdSMS();
} else { } else {
this.checkSMS(); this.checkSMS();
} }
} }
} else { } else {
const msg: string = this.translate.trPK('general', 'noOfTriesLogin'); const msg: string = this.translate.trPK('general', 'noOfTriesLogin');
this.common.JustAlertDialog(this.translate.trPK('general', 'ok'), msg); this.common.JustAlertDialog(this.translate.trPK('general', 'ok'), msg);
} }
} }
async checkNFCStatus() { async checkNFCStatus() {
try { try {
let nfcStatus = await this.nfc.enabled(); let nfcStatus = await this.nfc.enabled();
console.log("nfc status >>>>>>>>>>" + nfcStatus); console.log("nfc status >>>>>>>>>>" + nfcStatus);
this.isNFCAvailable = true; this.isNFCAvailable = true;
} catch (err) { } catch (err) {
console.log("Error reading tag", err); console.log("Error reading tag", err);
if (err === "NO_NFC") { if (err === "NO_NFC") {
this.isNFCAvailable = false; this.isNFCAvailable = false;
} else if (err === "NFC_DISABLED") { } else if (err === "NFC_DISABLED") {
this.isNFCAvailable = true; this.isNFCAvailable = true;
} else { } else {
this.isNFCAvailable = false; this.isNFCAvailable = false;
} }
} }
} }
public checkSMS() { public checkSMS() {
this.showErrorMessage = false; this.showErrorMessage = false;
const data = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false); const data = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false);
const request = new SMSCheckRequest(); const request = new SMSCheckRequest();
request.LogInTokenID = data.LogInTokenID; request.LogInTokenID = data.LogInTokenID;
request.activationCode = this.code; // code;this.activationCode; request.activationCode = this.code; // code;this.activationCode;
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
this.businessInfo = { this.businessInfo = {
show_business: result.BusinessCardPrivilege, show_business: result.BusinessCardPrivilege,
name_en: result.MemberInformationList[0].EMPLOYEE_NAME_En, name_en: result.MemberInformationList[0].EMPLOYEE_NAME_En,
job_en: result.MemberInformationList[0].JOB_NAME_En, job_en: result.MemberInformationList[0].JOB_NAME_En,
name_ar: result.MemberInformationList[0].EMPLOYEE_NAME_Ar, name_ar: result.MemberInformationList[0].EMPLOYEE_NAME_Ar,
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
} }
// Wifi Credientials // Wifi Credientials
CommonService.MOHEMM_WIFI_SSID = result.Mohemm_Wifi_SSID; CommonService.MOHEMM_WIFI_SSID = result.Mohemm_Wifi_SSID;
CommonService.MOHEMM_WIFI_PASSWORD = result.Mohemm_Wifi_Password; CommonService.MOHEMM_WIFI_PASSWORD = result.Mohemm_Wifi_Password;
localStorage.setItem('bussiness-card-info', JSON.stringify(this.businessInfo)); localStorage.setItem('bussiness-card-info', JSON.stringify(this.businessInfo));
// this.common.sharedService.setSharedData(this.businessInfo,'bussiness-card-info'); // this.common.sharedService.setSharedData(this.businessInfo,'bussiness-card-info');
AuthenticationService.servicePrivilage = result.Privilege_List; AuthenticationService.servicePrivilage = result.Privilege_List;
this.authService.setAuthenticatedUser(result).subscribe(() => { this.authService.setAuthenticatedUser(result).subscribe(() => {
localStorage.setItem('emp-name', result.MemberInformationList[0].EMPLOYEE_NAME); localStorage.setItem('emp-name', result.MemberInformationList[0].EMPLOYEE_NAME);
this.user_name = result.MemberInformationList[0].EMPLOYEE_NAME; this.user_name = result.MemberInformationList[0].EMPLOYEE_NAME;
const currDateTime = moment().format('MMM DD , YYYY HH:mm'); const currDateTime = moment().format('MMM DD , YYYY HH:mm');
localStorage.setItem('login-at', currDateTime); localStorage.setItem('login-at', currDateTime);
if (this.platform.is('cordova')) { if (this.platform.is('cordova')) {
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 {
let errorResult: any; let errorResult: any;
errorResult = result; errorResult = result;
this.showErrorMessage = true; this.showErrorMessage = true;
this.messageValue = errorResult.ErrorEndUserMessage; this.messageValue = errorResult.ErrorEndUserMessage;
this.smc_code = []; this.smc_code = [];
(document.activeElement as HTMLElement).blur(); (document.activeElement as HTMLElement).blur();
setTimeout(() => { setTimeout(() => {
this.showErrorMessage = false; this.showErrorMessage = false;
}, 5000); }, 5000);
} }
}); });
} }
public insertMobileLogin() { public insertMobileLogin() {
const request = new GetLoginInfoRequest(); const request = new GetLoginInfoRequest();
this.authService.setPublicFields(request); this.authService.setPublicFields(request);
request.MobileNumber = this.loginData.MobileNumber; request.MobileNumber = this.loginData.MobileNumber;
request.P_USER_NAME = this.loginData.P_USER_NAME; request.P_USER_NAME = this.loginData.P_USER_NAME;
request.UserName = this.loginData.P_USER_NAME; request.UserName = this.loginData.P_USER_NAME;
request.LogInTokenID = this.loginData.LogInTokenID; request.LogInTokenID = this.loginData.LogInTokenID;
request.CompanyID = 1; // CompanyID request.CompanyID = 1; // CompanyID
request.DeviceType = this.common.getDeviceType(); request.DeviceType = this.common.getDeviceType();
request.DeviceToken = this.deviceToken; // "5ca8a69cf1804db55264c349edffb99b9d63acd9fa9b6b18956bcb2ad3f2ba36";//this.deviceToken; request.DeviceToken = this.deviceToken; // "5ca8a69cf1804db55264c349edffb99b9d63acd9fa9b6b18956bcb2ad3f2ba36";//this.deviceToken;
request.LoginType = this.loginTypeData.loginType; request.LoginType = this.loginTypeData.loginType;
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');
}); });
} }
public checkForgetPwdSMS() { public checkForgetPwdSMS() {
const data = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false); const data = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false);
const request = new SMSCheckRequest(); const request = new SMSCheckRequest();
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) {
this.common.openForgotPassword(); this.common.openForgotPassword();
} }
if (this.isExpiredPwd) { if (this.isExpiredPwd) {
this.sharedData.setSharedData(true, Password.IS_EXPIRED_PSW); this.sharedData.setSharedData(true, Password.IS_EXPIRED_PSW);
this.common.openChangePassword(); this.common.openChangePassword();
} }
} }
}); });
} }
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 && !this.isAutoRead) { if (filtered.length === 4 && !this.isAutoRead) {
this.checkVerificationCode(); this.checkVerificationCode();
} }
} }
goToNextInput(e) { goToNextInput(e) {
const key = e.which; const key = e.which;
const t = e.target; const t = e.target;
const sib = t.nextElementSibling; const sib = t.nextElementSibling;
const sibPre = t.previousElementSibling; const sibPre = t.previousElementSibling;
if (key === undefined) {
this.checkActivation(e.target.value, false);
}
if (key !== 9 && (key < 48 || key > 57)) { if (key !== 9 && (key < 48 || key > 57)) {
if (key === 8 || key === 46) { if (key === 8 || key === 46) {
return true; return true;
} else { } else {
e.preventDefault(); e.preventDefault();
return false; return false;
} }
} }
if (key === 9) { if (key === 9) {
return true; return true;
} }
if (sib) { if (sib) {
if (e.target.value === '') { if (e.target.value === '') {
sibPre.setFocus(); sibPre.setFocus();
} else { } else {
sib.setFocus(); sib.setFocus();
} }
} }
} }
} }

@ -73,6 +73,7 @@ select{
border: none !important; border: none !important;
position: relative; position: relative;
bottom: 5px; bottom: 5px;
background: transparent;
} }
.delete-icon{ .delete-icon{
position: absolute; position: absolute;

Loading…
Cancel
Save