|
|
|
|
@ -18,57 +18,56 @@ import { AlertController } from '@ionic/angular';
|
|
|
|
|
styleUrls: ['./smsdialog.page.scss'],
|
|
|
|
|
})
|
|
|
|
|
export class SmsdialogPage implements OnInit {
|
|
|
|
|
public timeInSeconds : number ;
|
|
|
|
|
public time : number;
|
|
|
|
|
public runTimer : boolean;
|
|
|
|
|
public timeInSeconds: number;
|
|
|
|
|
public time: number;
|
|
|
|
|
public runTimer: boolean;
|
|
|
|
|
public static SHARED_DATA = 'h2o-login-details';
|
|
|
|
|
public hasStarted : boolean;
|
|
|
|
|
public hasStarted: boolean;
|
|
|
|
|
public countryCode: CountryCode;
|
|
|
|
|
public hasFinished : boolean;
|
|
|
|
|
public remainingTime : number;
|
|
|
|
|
public displayTime : string = "";
|
|
|
|
|
public hasFinished: boolean;
|
|
|
|
|
public remainingTime: number;
|
|
|
|
|
public displayTime: string = "";
|
|
|
|
|
// public userData: UserDetailsModel;
|
|
|
|
|
public mobile : string;
|
|
|
|
|
public country_code : string;
|
|
|
|
|
public id : string;
|
|
|
|
|
public MobileNumber : string;
|
|
|
|
|
public token : string;
|
|
|
|
|
public resend : boolean = false;
|
|
|
|
|
public smc_code : any;
|
|
|
|
|
public mobile: string;
|
|
|
|
|
public country_code: string;
|
|
|
|
|
public id: string;
|
|
|
|
|
public MobileNumber: string;
|
|
|
|
|
public token: string;
|
|
|
|
|
public resend: boolean = false;
|
|
|
|
|
public smc_code: any;
|
|
|
|
|
constructor(public cs: CommonService,
|
|
|
|
|
public ts: TranslatorService,
|
|
|
|
|
public alertController: AlertController,
|
|
|
|
|
public smsService: SmsReaderService,
|
|
|
|
|
public sharedData: SharedDataService,
|
|
|
|
|
private modalCtrl:ModalController,
|
|
|
|
|
private modalCtrl: ModalController,
|
|
|
|
|
// private navParams: NavParams,
|
|
|
|
|
public smsservice: SMSDialogService) {
|
|
|
|
|
// this.country_code = this.navParams.get("c_code");
|
|
|
|
|
// this.MobileNumber = this.navParams.get('mobile');
|
|
|
|
|
// this.mobile = this.navParams.get('mobile');
|
|
|
|
|
// this.id = this.navParams.get('id');
|
|
|
|
|
// this.smsservice.sendActivationCode(this.id, this.mobile,
|
|
|
|
|
// this.country_code, () => { },
|
|
|
|
|
// this.ts.trPK('general', 'ok')).subscribe((result: SendValidationResponse) => {
|
|
|
|
|
// if (this.cs.validResponse(result)) {
|
|
|
|
|
// if (result.isSMSSent) {
|
|
|
|
|
// this.token = result.LogInTokenID;
|
|
|
|
|
// this.initTimer();
|
|
|
|
|
// this.startTimer();
|
|
|
|
|
// } else {
|
|
|
|
|
// this.stopSMSMonitoring();
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// this.stopSMSMonitoring();
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
}
|
|
|
|
|
public smsservice: SMSDialogService) {
|
|
|
|
|
// this.country_code = this.navParams.get("c_code");
|
|
|
|
|
// this.MobileNumber = this.navParams.get('mobile');
|
|
|
|
|
// this.mobile = this.navParams.get('mobile');
|
|
|
|
|
// this.id = this.navParams.get('id');
|
|
|
|
|
// this.smsservice.sendActivationCode(this.id, this.mobile,
|
|
|
|
|
// this.country_code, () => { },
|
|
|
|
|
// this.ts.trPK('general', 'ok')).subscribe((result: SendValidationResponse) => {
|
|
|
|
|
// if (this.cs.validResponse(result)) {
|
|
|
|
|
// if (result.isSMSSent) {
|
|
|
|
|
// this.token = result.LogInTokenID;
|
|
|
|
|
// this.initTimer();
|
|
|
|
|
// this.startTimer();
|
|
|
|
|
// } else {
|
|
|
|
|
// this.stopSMSMonitoring();
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// this.stopSMSMonitoring();
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
closeModal()
|
|
|
|
|
{
|
|
|
|
|
closeModal() {
|
|
|
|
|
this.modalCtrl.dismiss();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -77,8 +76,8 @@ export class SmsdialogPage implements OnInit {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
initTimer() {
|
|
|
|
|
if (!this.timeInSeconds) {
|
|
|
|
|
this.timeInSeconds = 60;
|
|
|
|
|
if (!this.timeInSeconds) {
|
|
|
|
|
this.timeInSeconds = 60;
|
|
|
|
|
}
|
|
|
|
|
this.time = this.timeInSeconds;
|
|
|
|
|
this.runTimer = false;
|
|
|
|
|
@ -87,22 +86,22 @@ export class SmsdialogPage implements OnInit {
|
|
|
|
|
this.remainingTime = this.timeInSeconds;
|
|
|
|
|
this.displayTime = this.getSecondsAsDigitalClock(this.remainingTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
startTimer() {
|
|
|
|
|
this.runTimer = true;
|
|
|
|
|
this.hasStarted = true;
|
|
|
|
|
this.resend = false;
|
|
|
|
|
this.timerTick();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pauseTimer() {
|
|
|
|
|
this.runTimer = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resumeTimer() {
|
|
|
|
|
this.startTimer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
timerTick() {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
if (!this.runTimer) { return; }
|
|
|
|
|
@ -117,7 +116,7 @@ export class SmsdialogPage implements OnInit {
|
|
|
|
|
}
|
|
|
|
|
}, 1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getSecondsAsDigitalClock(inputSeconds: number) {
|
|
|
|
|
var sec_num = parseInt(inputSeconds.toString(), 10); // don't forget the second param
|
|
|
|
|
var hours = Math.floor(sec_num / 3600);
|
|
|
|
|
@ -132,13 +131,12 @@ export class SmsdialogPage implements OnInit {
|
|
|
|
|
return minutesString + ':' + secondsString;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
validate()
|
|
|
|
|
{
|
|
|
|
|
validate() {
|
|
|
|
|
this.checkSMSActivationCode(this.smc_code);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public presentSMSPasswordDialog() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async presentAlert() {
|
|
|
|
|
@ -153,21 +151,20 @@ export class SmsdialogPage implements OnInit {
|
|
|
|
|
|
|
|
|
|
private checkSMSActivationCode(smsCode: string) {
|
|
|
|
|
this.smsservice.validateActivationCode(this.token, smsCode,
|
|
|
|
|
() => {}, this.ts.trPK('settings', 'incorrect_otp')).subscribe((result: Response) => {
|
|
|
|
|
if (this.cs.validResponse(result)) {
|
|
|
|
|
this.stopSMSMonitoring();
|
|
|
|
|
this.modalCtrl.dismiss();
|
|
|
|
|
SMSDialogService.modal_success = true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
() => { }, this.ts.trPK('settings', 'incorrect_otp')).subscribe((result: Response) => {
|
|
|
|
|
if (this.cs.validResponse(result)) {
|
|
|
|
|
//this.stopSMSMonitoring();
|
|
|
|
|
this.modalCtrl.dismiss();
|
|
|
|
|
SMSDialogService.modal_success = true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public stopSMSMonitoring() {
|
|
|
|
|
this.smsService.stopSMSMonitoring();
|
|
|
|
|
this.smsService.stopSMSMonitoring();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ResendOTP()
|
|
|
|
|
{
|
|
|
|
|
public ResendOTP() {
|
|
|
|
|
// this.smsservice.sendActivationCode(this.id, this.mobile,
|
|
|
|
|
// this.country_code, () => { },
|
|
|
|
|
// this.ts.trPK('general', 'ok')).subscribe((result: SendValidationResponse) => {
|
|
|
|
|
|