· 5 years ago · Nov 22, 2020, 02:10 PM
1import { Country, GlobalService } from './../../deals/dealsServices/global/global.service';
2import { TouchIDPlugin } from './../../../plugins/TouchIDPlugin';
3import { BasePage } from './../../dashboard/BasePage';
4import { ActivateDeviceService } from './../../../services/ActivateDeviceService';
5import { fcmService } from './../../../services/fcmService';
6import { OverviewService } from './../../../services/OverviewService';
7import { Component, OnInit, NgZone, ElementRef, Inject, EventEmitter, Output, Input } from '@angular/core';
8import { AppEvents } from '../../../events/AppEvents';
9import { Router } from '@angular/router';
10import { Session } from '../../../models/Session';
11import { ModalCommonErrorEvent } from '../../../events/ModalCommonErrorEvent';
12import { AppDataModel } from '../../../models/AppDataModel';
13import { ConfirmModalEvent } from '../../../events/ConfirmModalEvent';
14import { ModalContainerEvent } from '../../../events/ModalContainerEvent';
15import { Utilities } from '../../../utilities/Utilities';
16import { DashboardPageUrl } from '../../../constants/DashboardPageConstant';
17import { UserModel } from '../../../models/UserModel';
18import { DuitNowMobileService } from '../../../services/DuitNowMobileService';
19import { UtilService } from '../../../services/util-service';
20import { nativeStorage } from '../../../plugins/NativeStoragePlugin';
21//import { nativeStorage } from '../../../plugins/NativeStoragePlugin';
22import { Http, Response } from '@angular/http';
23import { QRDataService } from '../../qrpay/service/qr-data-service';
24import { UserInquiryModel } from '../../../models/UserInquiryModel';
25import { Statics } from '../../../common/Statics';
26// import for deals
27import { Deal } from '../../deals/datastore/models/deal';
28import { DealsConfigService } from '../../deals/dealsServices/dealsConfigService.service';
29import c from '../../deals/utils/contants';
30import { environment } from '../../deals/environments/environment';
31import { filterExpiryDeal, calculateDistance } from '../../deals/utils';
32import { CategoryType, CategoryList, NearMeCategoryList } from '../../deals/datastore/models/category';
33const format = require('date-fns/format');
34import { EvaService, Reminder } from '../../../services/EvaService';
35import { EvaUtilities } from '../../eva-chat-page/EvaUtilities';
36import { isNullOrUndefined } from 'util';
37
38
39declare var onMessengerNewMessage: any;
40declare var decryptingUserId: any;
41declare var digitalData: any;
42declare var _satellite: any;
43declare var $: any;
44declare var moment: any;
45declare var window: any;
46declare var WL: any;
47digitalData.registration = {};
48// digitalData.skipClick = {};
49digitalData.transaction = {};
50digitalData.page = {};
51digitalData.page.pageInfo = {};
52// digitalData.campaign = {};
53// digitalData.errorPage = {};
54// digitalData.services = {};
55// digitalData.quickmenu = {};
56declare const _: any;
57declare let cordova: any;
58declare var MFPInit: any;
59declare var sliderObj;
60declare var dtrum;
61
62@Component({
63 selector: 'app-home',
64 templateUrl: './home.component.html',
65 styleUrls: ['./home.component.css']
66})
67export class HomeComponent extends BasePage implements OnInit {
68 @Output('onKeyPressAmount') eventEmitter: EventEmitter<any> = new EventEmitter();
69 maxLength: number = 20;
70 overlayScreen: boolean[] = [false, false, false, false, false, false, false, false, false];
71 urls: any;
72 $el: any;
73 subPostloginForm:any;
74 router: Router;
75 actionList: any;
76 subscription: any;
77 sessionModel: any;
78 isMobile: boolean = false;
79 subscriptionForAppEvent: any;
80 isLoaded: boolean = false;
81 currencyFlag: Array<any>;
82 flagChanged: boolean;
83 itemData: any = null;
84 selectedCountry: any;
85 selectedCurrency: any;
86 status: any;
87 actionItem: any = null;
88 flagClick: any = null;
89 displayName: string;
90 pageSession: any = null;
91 eventSession: any = null;
92 loggedUser: UserModel;
93 transferDuitAmount: any;
94 showPaymentPopup: boolean = false;
95 isSecurityQrFlag: boolean = false;
96
97 //FTL_Status: any; //native storage
98 //FTL_Entry: any; //native storage
99 isIOS: boolean = Utilities.isIOS();
100 //Added for iCams
101 iCamsOFU: Array<any> = [];
102 iCamsONM: Array<any> = [];
103 userName: string;
104 myhttp: any;
105 private userInfo: UserInquiryModel;
106 isEnterAmount: boolean = false;
107 doItNowLogoPath: any = "img/home/duitnow_icon_2.png";
108
109 //Deals
110 isDealCall = true;
111 dealsDetailsInfo: any;
112 currentCountryVal: any;
113 //nearMeArray: any;
114 loaderShow: any;
115 userLocation: any;
116 combinedArr = [];
117 public dealData: {
118 ['dining']?: Deal[],
119 ['featured']?: Deal[],
120
121 } = {};
122 dealsData: any;
123 assetsURL = environment.CMS_ASSET_URL;
124 public showFeatureCarousel: boolean = false;
125
126 //EVA Reminder Notification
127 tipReminderCount: number;
128 reminderList: Array<any> = null;
129 jomPayReminderCount: number = 0;
130 payLoanReminderCount: number = 0;
131 payCardReminderCount: number = 0;
132 payBillReminderCount: number = 0;
133 paymentReminderCount: number = 0;
134 paymentPayLoanAndCardsCount: number = 0;
135 showReminders: boolean = false;
136 currentSelectedOverlayRoute: any = null;
137 homePageBanner: any;
138 homePageMenuDynamicObj: any;
139 homeQuickLimitDynamicObj: any;
140
141 constructor(router: Router, @Inject(ElementRef) elementRef: ElementRef,
142 private _ngZone: NgZone,
143 private overviewService: OverviewService,
144 sessionModel: Session,
145 public appEvents: AppEvents,
146 public errorModalEvent: ModalCommonErrorEvent,
147 private appDataModel: AppDataModel,
148 private confirmModalEvent: ConfirmModalEvent,
149 public modalContainerEvent: ModalContainerEvent,
150 private activateService: ActivateDeviceService,
151 private http: Http,
152 private qrDataService: QRDataService,
153 public duitNowMobileService: DuitNowMobileService,
154 private dealService: DealsConfigService,
155 private globalService: GlobalService,
156 private evaService: EvaService,
157 public FCMService: fcmService,
158 ) {
159
160 super();
161 super.initData(appEvents, errorModalEvent, modalContainerEvent);
162 this.myhttp = http;
163 this.router = router;
164 this.$el = $(elementRef.nativeElement);
165 this.sessionModel = sessionModel;
166 this.subscriptionForAppEvent = this.appEvents.subscribe(this, this.onHandleAppEvent);
167
168 this.isMobile = Utilities.isMobile();
169
170
171 this.isLoaded = false;
172 this.loggedUser = sessionModel.userModel;
173 this.initData();
174 this.isSecurityQrFlag = false;
175
176 }
177
178 ngOnInit() {
179
180 this.subPostloginForm = this.appEvents.subscribe(this, (event:any) => {
181 if(event.type=="rebuild_slider_postlogin"){
182 console.log("unsubcribe by event ### --------------------->")
183 this.clickBackRebuildSlider();
184 }
185
186 });
187 let self=this;
188 localStorage.setItem("backToDeals", 'false');
189 this.globalService.set("selectedAccountNum",undefined);
190 this.globalService.set("selectedLoanAccountNum",undefined);
191
192
193 console.log('Home: oninit');
194 let urls: any = {};
195 for (let url in DashboardPageUrl) {
196 if (DashboardPageUrl[url]) {
197 urls[url] = DashboardPageUrl[url];
198 }
199 }
200 this.urls = urls;
201 console.log("userLoginType ", localStorage.getItem('userLoginType'))
202
203 //localStorage.setItem('homeScreen', 'home');
204 nativeStorage.setItem("homeScreen", "home"); //native local Storage
205 localStorage.setItem("session", "session"); //set session flag for active session
206 localStorage.setItem('appState', 'PostLogin'); //set appState to post login
207
208 //EVA Notification Routing Fix
209 QRDataService.evaNotificationTib = null;
210
211 localStorage.removeItem('homeAmount');
212 console.log('Homescreen get data :- ');
213 let userEnquiry: any = JSON.parse(localStorage.getItem('userEnquiry'));
214 this.displayName = userEnquiry.displayName;
215 this.appEvents.emit({
216 type: AppEvents.PAGE_TITLE,
217 pageTitle: 'Home',
218 isAccountOverview: true
219 });
220
221 this.appEvents.emit({
222 type: AppEvents.SHOW_BACK_BUTTON,
223 prevPage: "home",
224 qrFlag: false,
225 isShowBackButton: false
226 });
227
228 this.appEvents.emit({
229 type: AppEvents.HIDE_MENU_BACK_BUTTON,
230 isHideMenuBackButton: true
231 });
232
233 this.appEvents.emit({
234 type: AppEvents.SHOW_CLOSE_ICON,
235 isShowCloseIcon: false
236 });
237
238 this.appEvents.emit({
239 type: AppEvents.MODAL_HEADER,
240 isModalHeader: false
241 });
242 this.appEvents.emit({
243 type: AppEvents.HELPSUPPORT_ICON,
244 isShowHelpIcon: false
245 });
246 this.appEvents.emit({
247 type: AppEvents.SHOW_SETTING_ICON,
248 isShowSetting: true
249 });
250
251 this.appEvents.emit({ type: AppEvents.SHOW_HEADER });
252
253 //Adobe Analytic
254 digitalData.page = {
255 pageInfo: {
256 pageName: "app:Home Screen"
257 },
258 category: {
259 pageType: "content",
260 primaryCategory: "homeModule",
261 subCategory1: "Dashboard",
262 subCategory2: "",
263 subCategory3: ""
264 }
265 };
266
267
268 if (this.isIOS) {
269 window.cordova.exec(
270 function(data){
271 console.log("getTokenRefreshIos success")
272 console.log(data)
273 window.localStorage.setItem("fcmTokenRefresh",data);
274 self.updateFCMtoken();
275 },
276 function(data){
277 console.log("getTokenRefreshIos fail")
278 console.log(data)
279 },
280 "DeviceTokenPlugin",
281 "getRefreshToken", []);
282 }else{
283 this.updateFCMtoken();
284 }
285
286 // call fetch deal data fun
287 // this.fetchDeal('featured');
288 if (localStorage.getItem("selectedCountry") == null) {
289 localStorage.setItem("selectedCountry", Country.Malaysia);
290 this.currentCountryVal = Country.Malaysia;
291 this.globalService.changeCountry(Country.Malaysia);
292 }
293 //this.fetchDeal('featured');
294 if (this.isDealCall) {
295 this.combinedArr = [];
296 Utilities.getGeoLocation(() => {
297 console.log("getGeoLocation Succ");
298 //this.getCountryAsPerGps();
299 this.userLocation = { lat: localStorage.getItem("GeoLocationLat"), lng: localStorage.getItem("GeoLocationLong") };
300 this.IcamsDeals();
301 }, () => {
302 console.log("getGeoLocation Failure");
303 // this.getCountryAsPerGps();
304 this.IcamsDeals();
305 });
306 this.isDealCall = false;
307 }
308
309
310 if(this.qrDataService.homePageBanner && this.qrDataService.homePageMenuDynamicObj)
311 {
312 console.log(" support existing call object===== ");
313 if(this.qrDataService.homePageBanner){
314 this.homePageBanner = this.qrDataService.homePageBanner;
315 console.log("this.homePageBanner ==== ",this.homePageBanner);
316 }
317
318 if(this.qrDataService.homePageMenuDynamicObj){
319 this.homePageMenuDynamicObj = this.qrDataService.homePageMenuDynamicObj;
320 console.log("this.homePageMenuDynamicObj ==== ",this.homePageMenuDynamicObj);
321
322 }
323 }
324 else
325 {
326 console.log("new support center call ===== ");
327 this.supportCenterCall();
328 }
329
330 this.checkReminderCall();
331 this.hideLoader();
332 setTimeout(() => {
333 self.initSlider();
334 })
335 self._ngZone.runOutsideAngular(() => {
336 $("#title-head-block").addClass("mainPageHeaderHeight");
337 });
338 }
339
340 initSlider(){
341 let self=this;
342 console.log("###initslider");
343self._ngZone.runOutsideAngular(() => {
344
345 try{
346 sliderObj.destroy();
347 console.log("destroy slider on init ----->");
348 }catch(e){
349 console.log("catch - destroy slider on init ----->",e);
350 }finally{
351 console.log("finally - slider on init ----->");
352 sliderObj =$("#light-slider").lightSlider({
353 item: 1,
354 enableTouch:true,
355 enableDrag:true,
356 freeMove:true,
357 swipeThreshold: 40,
358 controls: false,
359 loop: true
360 });
361 $("#headerOneApp").addClass("forceGrayHeader");
362 $("#shrinkTextHeader").addClass("forceShrinkTextBlack");
363 $("#iconHeader").addClass("forceShrinkTextBlack");
364 $("#postloginLogoutIcon").addClass("icon--logout-black");
365 $("#postloginLogoutIcon").removeClass("icon--logout");
366
367 }
368
369
370});
371 }
372
373 IcamsDeals() {
374 console.log("IcamsDeals :: ");
375 this.userName = decryptingUserId(localStorage.getItem('SuperUserid'), "SuperUserid", 'invoking from homecomponent1');
376 var configData = JSON.parse(localStorage.getItem('configData'));
377 var data = {
378 "userId": this.userName,
379 "requestVer":"1.1",
380 "channelId": "clicks1App",
381 "maxOffers": 5,
382 "latitude": localStorage.getItem("GeoLocationLat"),
383 "longitude": localStorage.getItem("GeoLocationLong")
384 }
385 try {
386 console.log("IcamsDeals :data: ",data , configData.icams);
387 this.myhttp.post(configData.icams + '/get_next_best_offers', data, { headers: { 'Content-Type': 'application/json' } }).subscribe((res: Response) => this.icamsres(res));
388 } catch (e) {
389 console.log("error while calling icams");
390 }
391
392
393
394 console.log("icamssss");
395 }
396 private icamsres(res: Response) {
397 console.log("icamsres ", res);
398 this.iCamsOFU = [];
399 this.iCamsONM = [];
400 let body = res.json();
401 console.log("icams response",body);
402 // console.log("cheking the array",Array.isArray(body));
403 // console.log('icams Data: ' + JSON.stringify(body));
404
405 if(Array.isArray(body))
406 {
407 this.iCamsOFU = _.sortBy(body, "Priority");
408 }
409 if(body.OFY && Array.isArray(body.OFY) && body.OFY.length > 0)
410 {
411 this.iCamsOFU = _.sortBy(body.OFY, "Priority");
412 let index = 0;
413 for(let key in this.iCamsOFU)
414 {
415 if(this.iCamsOFU[key].ImageURL == "")
416 {
417 this.iCamsOFU[key].ImageURL = "img/icams/Chevron banner-"+index+".jpg";
418 }
419 index ++;
420 }
421 }
422 if(body.ONM && Array.isArray(body.ONM) && body.ONM.length > 0)
423 {
424 this.iCamsONM = _.sortBy(body.ONM, "Priority");
425 }
426
427
428 console.log("this.iCamsOFU ", this.iCamsOFU);
429 console.log("this.iCamsONM ", this.iCamsONM);
430 }
431
432 ONMFlag = false;
433 dealaccept(deals,resType , selectedCarousel?) {
434 console.log("this.ONMFlag ",this.ONMFlag);
435 if(this.ONMFlag)
436 {
437 this.ONMFlag = false;
438 return;
439 }
440 this.ONMFlag = true;
441 console.log("this.ONMFlag 1 ",this.ONMFlag);
442 console.log("icams accept deals",deals , resType);
443 this.userName = decryptingUserId(localStorage.getItem('SuperUserid'), 'SuperUserid', 'invoking from homecomponent2');
444 var configData = JSON.parse(localStorage.getItem('configData'));
445 var data = {
446 "userId": this.userName,
447 "channelId": "clicks1App",
448 "ResponseType":resType,
449 "offerId": deals.OfferID
450 }
451 try {
452 console.log("data ",data );
453 this.myhttp.post(configData.icams + '/offer_accepted', data).subscribe((res: Response) => this.offer_accepted(res));
454 } catch (e) {
455 // No content response..
456 console.log("pronlem while calling");
457 }
458 let option: string = 'location=yes,toolbarposition=top';
459 let dBrowser: string = '_system'
460 if (this.isIOS) {
461 option = 'location=no,toolbarposition=top,fullscreen=yes';
462 dBrowser = '_blank'
463 }
464
465 //let url = "http://google.com";
466 if(resType == "ONM")
467 {
468 this.showLoader();
469 this.getDealsDetailsFromServer(deals.Header2, deals.ActionUrl, deals.Category , deals, selectedCarousel);
470 }
471 else
472 {
473 cordova.exec(null, null, 'InAppBrowser', 'open', [deals.ActionUrl, dBrowser, option]);
474 }
475 }
476 offer_accepted(res: Response) {
477 // console.log("offers accepted reponse",res);
478 }
479
480 dealsArray: any = [];
481 getDealsDetailsFromServer(merchant_name : string, id : string, categoryVal : string , deal : any , selectedCarousel : any)
482 {
483
484 console.log("getDealsDetailsFromServer ",id );
485 this.dealService.getDealDetailV2(id).subscribe((data: any) => {
486
487 console.log('in this.dealService.getDealDetailV2');
488 console.log('data====', data);
489
490 if (data._title || data.field_description) {
491 this.dealsArray.push(data);
492 console.log('length of this.deals===', this.dealsArray);
493 if (this.dealsArray.length <= 0) {
494 console.log('Inside if condition this.deals.length===', this.dealsArray.length);
495 }
496 console.log('deals category====', categoryVal);
497 if (!isNullOrUndefined(categoryVal)) {
498 console.log('deals category this.dealsArray.length====', this.dealsArray.length);
499 if (this.dealsArray.length > 0) {
500 console.log('deals category this.dealsArray====', this.dealsArray);
501 this.globalService.set(categoryVal.toString().toLowerCase(), this.dealsArray);
502 this.callDealsDetails(data.field_merchant, data.id, categoryVal , data, selectedCarousel)
503 }
504 }
505 } else {
506 console.log('else length of loadMoreDeals===');
507 let error = this.dealService.apiFailureMessagesetGet();
508 if (error.message == 'Timeout has occurred') {
509 this.dealService.apiFailureMessageSet(error.message);
510 this.hideLoader();
511 } else {
512 this.dealService.apiFailureMessageSet(error);
513 this.hideLoader();
514 }
515
516 }
517
518 }, (error) => {
519 console.log("Errorrrrrr ");
520 });
521 }
522
523 blackoutHeader(bool: boolean) {
524 this.appEvents.emit({
525 type: AppEvents.BLACKOUT_HEADER,
526 blackoutHeader: bool,
527 showEvaTooltip: false,
528 isNewHomeScreenheader: true
529 });
530 }
531
532 blackoutReminderHeader(bool: boolean, showReminderClose: boolean) {
533 console.log("Blackout is Activated", bool, showReminderClose);
534 this.appEvents.emit({
535 type: AppEvents.BLACKOUT_HEADER,
536 blackoutHeader: bool,
537 showEvaTooltip: false,
538 showBlackoutCloseIcon: showReminderClose,
539 isNewHomeScreenheader: true
540 });
541 }
542
543 blackoutReminderHeader_old(bool: boolean, showReminderClose: boolean) {
544 console.log("Blackout is Activated", bool, showReminderClose);
545 this.appEvents.emit({
546 type: AppEvents.BLACKOUT_HEADER,
547 blackoutHeader: bool,
548 showEvaTooltip: false,
549 showBlackoutCloseIcon: showReminderClose,
550 });
551 }
552
553 ngAfterViewInit() {
554 if (localStorage.getItem('toolTipFlag') != 'true') {
555 console.log("IN Update display");
556 this.showOverlayWelcome();
557 this.blackoutHeader(true);
558 nativeStorage.setItem('toolTipFlag', 'true');
559 //EVA Tooltip
560 nativeStorage.setItem('showEvaTip', 'true');
561 }
562 }
563
564 onHandleAppEvent(data: any): void {
565 console.log("onHandleAppEvent data :: ", data);
566 this._ngZone.run(() => {
567 if (data.type === AppEvents.RESET_DATA_TRANSFER && !data.disableInitData) {
568 this.initData();
569 }
570 //For EVA Reminders
571 else
572 if (data.type === AppEvents.CLOSE_ICON_BLACKOUT) {
573 this.onCloseReminder();
574 }
575 else
576 if (data.type === AppEvents.POST_AND_PARTIAL_LOGIN_SETTINGS_NAVIGATE) {
577 this.onChooseItem(null, DashboardPageUrl.SETTING_URL, null);
578 }
579 if (data.type === AppEvents.POST_AND_PARTIAL_LOGIN_FD_NAVIGATE) {
580 this.onChooseItem(null, DashboardPageUrl.FIXED_DEPOSIT_URL, null);
581 }
582 if (data.type === AppEvents.POST_AND_PARTIAL_LOGIN_QRPAY_NAVIGATE) {
583 this.onChooseItem(null, DashboardPageUrl.QR_PAY_URL, null);
584 }
585
586 });
587 }
588
589
590 initData(): void {
591 let self: any = this;
592 this.showLoader();
593 console.log('Show loader ...');
594 console.log('initData');
595
596 //check for any pre login activation flows
597 if (localStorage.getItem('userEnquiry')) {
598 var userEnquiryObj = JSON.parse(localStorage.getItem('userEnquiry'));
599 // console.log('FTL flag', userEnquiryObj.deviceFTLFlag);
600 var TEMP = true; //!userEnquiryObj.deviceFTLFlag
601
602 if (!userEnquiryObj.deviceFTLFlag) {
603 // console.log('activateSession >>> ', localStorage.getItem('activateSession'));
604 if (localStorage.getItem('activateSession') && localStorage.getItem("LoginType")) {
605 // console.log('There is something to activate', localStorage.getItem('activateSession'));
606 if (localStorage.getItem('activateSession') === 'tom' && localStorage.getItem("LoginType") === 'normal') {
607 console.log('TIME to Activate TOM');
608 self.activateTAC();
609 }
610 }
611 }
612 }
613
614
615
616 this.showLoader();
617 this._ngZone.runOutsideAngular(() => {
618
619 });
620 localStorage.setItem('DetailsType', 'normal');
621
622
623 onMessengerNewMessage();
624
625 }
626
627
628
629 showUserPopupMenu() {
630 this._ngZone.run(() => {
631 console.log('showUserPopupMenu');
632 document.getElementById('myDropdown').classList.toggle('show-home');
633 });
634 }
635
636 // showOverlayEva() {
637 // this._ngZone.run(() => {
638 // console.log('showOverlayEva');
639 // this.overlayScreen = [true, false, false, false, false, false, false, false, false];
640 // });
641 // }
642
643 showOverlayWelcome() {
644 this._ngZone.run(() => {
645 console.log('showOverlayWelcome');
646 this.overlayScreen = [false, false, false, false, false, true, false, false, false];
647 });
648 }
649
650 // showOverlaySwitch() {
651 // this._ngZone.run(() => {
652 // console.log('showOverlaySwitch');
653 // this.overlayScreen = [false, false, true, false, false, false, false, false, false];
654 // });
655 // }
656
657 showOverlayDoItNow() {
658 this._ngZone.run(() => {
659 console.log('showOverlayDoItNow');
660 this.overlayScreen = [false, false, false, true, false, false, false, false, false];
661 });
662 }
663
664 // showOverlayQR() {
665 // this._ngZone.run(() => {
666 // console.log('showOverlayQR');
667 // this.overlayScreen = [false, false, false, false, true, false, false, false, false];
668 // });
669 // }
670
671 showOverlayPayment() {
672 this._ngZone.run(() => {
673 console.log('showOverlayPayment');
674 this.overlayScreen = [false, false, false, false, false, false, true, false, false];
675 });
676 }
677
678 showOverlayMenu() {
679 this._ngZone.run(() => {
680 console.log('showOverlayMenu');
681 this.overlayScreen = [false, false, false, true, false, false, false, false, false];
682 });
683 }
684
685 showOverlaySettings() {
686 this._ngZone.run(() => {
687 console.log('showOverlaySettings');
688 this.overlayScreen = [false, false, false, false, false, false, false, true, false];
689 // this.appEvents.emit({
690 // type: AppEvents.BLACKOUT_HEADER,
691 // showEvaTooltip: true,
692 // blackoutHeader: true
693 // });
694 });
695 }
696
697 showOverlayChallenge() {
698 this._ngZone.run(() => {
699 console.log('showOverlayChallenge');
700 this.overlayScreen = [false, false, false, false, false, false, false, true, false];
701 });
702 }
703
704 hideAllOverlays() {
705 this._ngZone.run(() => {
706 this.overlayScreen = [false, false, false, false, false, false, false, false, false];
707 this.blackoutHeader(false);
708 });
709
710 this.userInfo = new UserInquiryModel();
711 this.userInfo.fetchData();
712
713 console.log("isTouchIdActivate ", this.userInfo.isTouchIdActivate(), this.userInfo.isTouchIdRemind())
714 // if(this.userInfo.isTouchIdActivate() || this.userInfo.isTouchIdRemind())
715 // {
716 // this.navigateToTouchTransaction();
717 // }
718 TouchIDPlugin.isAvailable(() => {
719 console.log("navigateToTouchTransaction available ");
720 this.navigateToTouchTransaction();
721 }, () => {
722 console.log("navigateToTouchTransaction not available ");
723 })
724 }
725
726 navigateToTouchTransaction() {
727 console.log('in navigateToTouchTransaction');
728 this.qrDataService.navigateQrData("ftl");
729 this.router.navigate([DashboardPageUrl.TOUCH_SET_TRANSATION_LIMIT_URL]);
730 }
731
732
733 navToLogin() {
734 this.router.navigate(['login']);
735 // this.loginForm.togglePreLoginScreen('GUEST');
736 }
737
738 showDuitNow() {
739
740 // this.router.navigate(['duitNow-mobile']);
741 this.router.navigate([DashboardPageUrl.DASHBOARD_PAGE_URL, DashboardPageUrl.DUITNOW_MOBILE_URL]);
742 }
743
744 onChooseItem(e: Event, pageName: string, duitAmount: any): any {
745 this.blackoutHeader(false);
746 console.log('PageName', pageName);
747 let configData = JSON.parse(localStorage.getItem('configData'));
748 console.log('login_link', configData.login_link)
749 // console.log("transferDuitAmount=========", duitAmount);
750 // this.showPaymentPopup = false;
751
752 // if(this.homePageMenuDynamicObj ){
753
754 // }
755 let self=this;
756 if (typeof pageName !== 'string') {
757 return;
758 }
759 if(this.homePageMenuDynamicObj){
760 for(let i=0; i < this.homePageMenuDynamicObj.length; i++){
761 console.log('this.homePageMenuDynamicObj[i].itemName === ', this.homePageMenuDynamicObj[i].itemName.split('|')[0]);
762 if(this.homePageMenuDynamicObj[i].itemName.split('|')[0] === pageName){
763 console.log('homePageMenuDynamicObj true === ');
764 if(this.homePageMenuDynamicObj[i].itemValue === "D"){
765 console.log('homePageMenuDynamicObj itemValue === ');
766
767 WL.SimpleDialog.show(
768 "Alert",
769 this.homePageMenuDynamicObj[i].itemName.split('|')[1],
770 [
771 {
772 text: "Ok",
773 handler: function () {
774 // console.log("testing");
775 // WL.Client.reloadApp();
776 }
777 }
778 ]
779 );
780 return false;
781 }
782
783 }
784 }
785 }
786
787
788
789 if (pageName == 'duitNow-mobile' && duitAmount != null) {
790 this.duitNowMobileService.setDatatoAmountField(duitAmount);
791 }
792
793 //Adobe Analytic
794 digitalData.registration = {};
795 digitalData.skipClick = {};
796 digitalData.transaction = {};
797 digitalData.campaign = {};
798 digitalData.errorPage = {};
799 digitalData.services = {};
800 digitalData.quickmenu = {};
801 let qrFtlFLag = false;
802 let dealsFLag = false;
803 let evaVal = "";
804 let actionDt_pageName = dtrum.enterAction('Home Module Page Name : '+pageName, 'click', null, 'info');
805 dtrum.leaveAction(actionDt_pageName);
806 switch (pageName) {
807 case 'home':
808 digitalData.page = {
809 pageInfo: {
810 pageName: "app:AccountSummaryPage"
811 },
812 category: {
813 pageType: "content",
814 primaryCategory: "DashboardModule",
815 subCategory1: "AccountSummary",
816 subCategory2: "",
817 subCategory3: ""
818 }
819 };
820 break;
821 case 'setting':
822 digitalData.page = {
823 pageInfo: {
824 pageName: "app:settingPage"
825 },
826 category: {
827 pageType: "content",
828 primaryCategory: "settingModule",
829 subCategory1: "SettingPage",
830 subCategory2: "",
831 subCategory3: ""
832 }
833 };
834 break;
835 case 'services':
836 digitalData.page = {
837 pageInfo: {
838 pageName: "app:servicesPage"
839 },
840 category: {
841 pageType: "content",
842 primaryCategory: "servicesModule",
843 subCategory1: "ServicesPage",
844 subCategory2: "",
845 subCategory3: ""
846 }
847 };
848 break;
849 case 'duitNow-mobile':
850
851 digitalData.page = {
852 pageInfo: {
853 pageName: "app:DuitNowMobilInputPage"
854 },
855 category: {
856 pageType: "input",
857 primaryCategory: "DuitNowMobilePageModule",
858 subCategory1: "DuitNowMobilnput",
859 subCategory2: "",
860 subCategory3: ""
861 }
862 };
863 break;
864 case 'fund-transfer':
865 digitalData.page = {
866 pageInfo: {
867 pageName: "app:TransferMoneyInputPage"
868 },
869 category: {
870 pageType: "input",
871 primaryCategory: "TransferMoneyModule",
872 subCategory1: "TransferMoneyInput",
873 subCategory2: "",
874 subCategory3: ""
875 }
876 };
877 digitalData.transaction = {
878 type: "Transfer Money",
879 step: "Step1: Input",
880 startTime: moment().format('YYYY/MM/DD hh:mm:ss')
881 };
882 //Adobe Analytic Tracking
883 if (typeof _satellite != 'undefined') {
884 _satellite.track('app:transaction start');
885 console.log('Adobe Analytic Tracking: app:transaction start');
886 }
887 break;
888 case 'pay-bills':
889 digitalData.page = {
890 pageInfo: {
891 pageName: "app:PayBillInputPage",
892 },
893 category: {
894 pageType: "input",
895 primaryCategory: "PayBillModule",
896 subCategory1: "PayBillInput",
897 subCategory2: "",
898 subCategory3: ""
899 }
900 };
901 digitalData.transaction = {
902 type: "Pay Bill",
903 step: "Step1: Input",
904 startTime: moment().format('YYYY/MM/DD hh:mm:ss')
905 };
906 //Adobe Analytic Tracking
907 if (typeof _satellite != 'undefined') {
908 _satellite.track('app:transaction start');
909 console.log('Adobe Analytic Tracking: app:transaction start');
910 }
911 break;
912 case 'pay-loan':
913 digitalData.page = {
914 pageInfo: {
915 pageName: "app:PayLoan&CardInputPage",
916 },
917 category: {
918 pageType: "input",
919 primaryCategory: "PayLoan&CardModule",
920 subCategory1: "PayLoan&CardInput",
921 subCategory2: "",
922 subCategory3: ""
923 }
924 };
925 digitalData.transaction = {
926 type: "Pay Loan & Card",
927 step: "Step1: Input",
928 startTime: moment().format('YYYY/MM/DD hh:mm:ss')
929 };
930 //Adobe Analytic Tracking
931 if (typeof _satellite != 'undefined') {
932 _satellite.track('app:transaction start');
933 console.log('Adobe Analytic Tracking: app:transaction start');
934 }
935
936 break;
937 case 'jom-pay':
938 digitalData.page = {
939 pageInfo: {
940 pageName: "app:JomPAYInputPage",
941 },
942 category: {
943 pageType: "input",
944 primaryCategory: "JomPAYModule",
945 subCategory1: "JomPAYInput",
946 subCategory2: "",
947 subCategory3: ""
948 }
949 };
950 digitalData.transaction = {
951 type: "JomPAY",
952 step: "Step1: Input",
953 startTime: moment().format('YYYY/MM/DD hh:mm:ss')
954 };
955 //Adobe Analytic Tracking
956 if (typeof _satellite != 'undefined') {
957 _satellite.track('app:transaction start');
958 console.log('Adobe Analytic Tracking: app:transaction start');
959 }
960 break;
961 case 'topup':
962 digitalData.page = {
963 pageInfo: {
964 pageName: "app:TopupInputPage",
965 },
966 category: {
967 pageType: "input",
968 primaryCategory: "TopupModule",
969 subCategory1: "TopupInput",
970 subCategory2: "",
971 subCategory3: ""
972 }
973 };
974 digitalData.transaction = {
975 type: "Topup",
976 step: "Step1: Input",
977 startTime: moment().format('YYYY/MM/DD hh:mm:ss')
978 };
979 //Adobe Analytic Tracking
980 if (typeof _satellite != 'undefined') {
981 _satellite.track('app:transaction start');
982 console.log('Adobe Analytic Tracking: app:transaction start');
983 }
984 break;
985 case 'fixed-deposit':
986 digitalData.page = {
987 pageInfo: {
988 pageName: "app:ApplyFDInputPage",
989 },
990 category: {
991 pageType: "input",
992 primaryCategory: "FDModule",
993 subCategory1: "ApplyFDInput",
994 subCategory2: "",
995 subCategory3: ""
996 }
997 };
998 digitalData.transaction = {
999 type: "Apply FD",
1000 step: "Step1: Input",
1001 startTime: moment().format('YYYY/MM/DD hh:mm:ss')
1002 };
1003 //Adobe Analytic Tracking
1004 if (typeof _satellite != 'undefined') {
1005 _satellite.track('app:transaction start');
1006 console.log('Adobe Analytic Tracking: app:transaction start');
1007 }
1008 break;
1009 case 'qr-pay':
1010
1011 // console.log("QR FTL FLOW " + localStorage.getItem('qrFtlFlag'));
1012 qrFtlFLag = true;
1013
1014
1015 digitalData.page = {
1016 pageInfo: {
1017 pageName: "app:QrpayInputPage",
1018 },
1019 category: {
1020 pageType: "input",
1021 primaryCategory: "QrpayModule",
1022 subCategory1: "QrpayInput",
1023 subCategory2: "",
1024 subCategory3: ""
1025 }
1026 };
1027 digitalData.transaction = {
1028 type: "Qrpay",
1029 step: "Step1: Input",
1030 startTime: moment().format('YYYY/MM/DD hh:mm:ss')
1031 };
1032 //Adobe Analytic Tracking
1033 if (typeof _satellite != 'undefined') {
1034 _satellite.track('app:transaction start');
1035 console.log('Adobe Analytic Tracking: app:transaction start');
1036 }
1037 break;
1038 case 'deals':
1039 this.callDealsApp();
1040 dealsFLag = true;
1041 console.log('Deals entry ======', dealsFLag);
1042
1043 break;
1044 case 'evaInsight':
1045 console.log("eva Insight");
1046 evaVal = "0";
1047 digitalData.page = {
1048 pageInfo: {
1049 pageName: "app:EvaPage",
1050 },
1051 category: {
1052 pageType: "input",
1053 primaryCategory: "EvaModule",
1054 subCategory1: "EvaInsight",
1055 subCategory2: "",
1056 subCategory3: ""
1057 }
1058 };
1059 digitalData.transaction = {
1060 type: "Eva",
1061 step: "Step1: Input",
1062 startTime: moment().format('YYYY/MM/DD hh:mm:ss')
1063 };
1064 //Adobe Analytic Tracking
1065 if (typeof _satellite != 'undefined') {
1066 _satellite.track('app:transaction start');
1067 console.log('Adobe Analytic Tracking: app:transaction start');
1068 }
1069
1070 break;
1071 case 'evaNotification':
1072 evaVal = "1";
1073 console.log("eva Notifications");
1074
1075 digitalData.page = {
1076 pageInfo: {
1077 pageName: "app:EvaPage",
1078 },
1079 category: {
1080 pageType: "input",
1081 primaryCategory: "EvaModule",
1082 subCategory1: "EvaNotification",
1083 subCategory2: "",
1084 subCategory3: ""
1085 }
1086 };
1087 digitalData.transaction = {
1088 type: "Eva",
1089 step: "Step1: Input",
1090 startTime: moment().format('YYYY/MM/DD hh:mm:ss')
1091 };
1092 //Adobe Analytic Tracking
1093 if (typeof _satellite != 'undefined') {
1094 _satellite.track('app:transaction start');
1095 console.log('Adobe Analytic Tracking: app:transaction start');
1096 }
1097 break;
1098
1099 case 'rewards':
1100 console.log("eva Notifications");
1101
1102 digitalData.page = {
1103 pageInfo: {
1104 pageName: "app:ClicksChallengesPage",
1105 },
1106 category: {
1107 pageType: "input",
1108 primaryCategory: "ClicksChallengesModule",
1109 subCategory1: "ClicksChallengesPage",
1110 subCategory2: "",
1111 subCategory3: ""
1112 }
1113 };
1114 digitalData.transaction = {
1115 type: "Rewaards",
1116 step: "Step1: Input",
1117 startTime: moment().format('YYYY/MM/DD hh:mm:ss')
1118 };
1119 //Adobe Analytic Tracking
1120 if (typeof _satellite != 'undefined') {
1121 _satellite.track('app:transaction start');
1122 console.log('Adobe Analytic Tracking: app:transaction start');
1123 }
1124 break;
1125 }
1126
1127 if (pageName != "eva")
1128 this.showLoader();
1129
1130
1131 this.pageSession = pageName;
1132 this.eventSession = e;
1133
1134 // reset the account number
1135 this.appDataModel.previousAccessAccountNumber = null;
1136
1137 //Check whether it is normal login or quick balance
1138 // if (localStorage.getItem('LoginType') && localStorage.getItem('LoginType') === 'quick') {
1139 // this.showLoader();
1140 // this._ngZone.runOutsideAngular(() => {
1141 // this.overviewService.callForSecureWord(this.onSecureWordSuccess.bind(this), this.failureCallBack.bind(this));
1142 // });
1143 // } else {
1144 // this.appEvents.emit({ type: AppEvents.SHOW_LOADING });
1145 // this.navigateToUrl(pageName, this.loggedUser.isQuickbalanceMode(), e);
1146 // }
1147 if (pageName != "eva")
1148 this.appEvents.emit({ type: AppEvents.SHOW_LOADING });
1149 if (pageName == 'setting') {
1150 if (localStorage.getItem('LoginType') == "quick") {
1151 this._ngZone.runOutsideAngular(() => {
1152 this.overviewService.callForSecureWord(this.onSecureWordSuccess.bind(this), this.failureCallBack.bind(this));
1153 });
1154 }
1155 else {
1156 this.router.navigate(['dashboard', DashboardPageUrl.SETTING_URL, false], {});
1157 }
1158
1159 }
1160 else if (pageName == 'services') {
1161 if (localStorage.getItem('LoginType') == "quick") {
1162 this._ngZone.runOutsideAngular(() => {
1163 this.overviewService.callForSecureWord(this.onSecureWordSuccess.bind(this), this.failureCallBack.bind(this));
1164 });
1165 }
1166 else {
1167 this.router.navigate(['dashboard', DashboardPageUrl.SERVICES_URL], {});
1168 }
1169
1170 }
1171 else if (pageName == 'fixed-deposit') {
1172 if (localStorage.getItem('LoginType') == "quick") {
1173 this._ngZone.runOutsideAngular(() => {
1174 this.overviewService.callForSecureWord(this.onSecureWordSuccess.bind(this), this.failureCallBack.bind(this));
1175 });
1176 }
1177 else {
1178 this.navigateToUrl(pageName, this.loggedUser.isQuickbalanceMode(), e);
1179 }
1180 }
1181 else if (qrFtlFLag) // For QR navigation
1182 {
1183 if (localStorage.getItem('qrFtlFlag') == "true") {
1184 var countVal = sessionStorage.getItem("passcodeMaximumValidCount");
1185 console.log("passcodeMaximumValidCount ", countVal);
1186 self.hideLoader();
1187 if("true" == countVal && "quick" == localStorage.getItem("LoginType"))
1188 {
1189 self.blackoutHeader(true);
1190 self.showConfirmation("Password is Required", "Maximum passcode limit reached", function() {
1191 console.log("alert Proceed clicked");
1192 self.blackoutHeader(false);
1193 self._ngZone.runOutsideAngular(() => {
1194 self.overviewService.callForSecureWord(self.onSecureWordSuccess.bind(self), self.failureCallBack.bind(self));
1195 });
1196 }, function() {
1197 console.log("alert Cancel clicked");
1198 self.blackoutHeader(false);
1199 self.hideLoader()
1200 }, false, "Proceed", "Cancel");
1201 }
1202 else if ("true" == countVal)
1203 {
1204 self.blackoutHeader(true);
1205 self.showConfirmation("Alert", "Reset Passcode", function() {
1206 console.log("alert Reset Passcode clicked");
1207 self.blackoutHeader(false);
1208 self.qrDataService.navigateQrData("MaxCountPasscode");
1209 self.router.navigate([DashboardPageUrl.QR_CREATE_PASSCODE_ACC_URL, {}]);
1210 }, function() {
1211 console.log("alert Cancel clicked");
1212 self.blackoutHeader(false);
1213 }, true, "Ok", "Cancel");
1214 }
1215 else {
1216 let tempUrl = DashboardPageUrl.QR_ENTER_PASSCODE_URL;
1217 this.router.navigate([tempUrl, {}]);
1218 }
1219 }
1220 else {
1221
1222 if (localStorage.getItem('LoginType') == "quick") {
1223 this._ngZone.runOutsideAngular(() => {
1224 this.overviewService.callForSecureWord(this.onSecureWordSuccess.bind(this), this.failureCallBack.bind(this));
1225 });
1226 }
1227 else {
1228 this.router.navigate([DashboardPageUrl.QR_PAY_ONBOARDING_URL]);
1229 }
1230
1231
1232 }
1233
1234
1235 }
1236 else if (evaVal != "") {
1237 console.log("evaVal :: ", evaVal);
1238 if (evaVal == "1") {
1239 this.router.navigate(['dashboard', DashboardPageUrl.EVA_URL, false]);
1240 }
1241 else {
1242 this.router.navigate(['dashboard', DashboardPageUrl.EVA_URL, true]);
1243 }
1244
1245 }
1246 else {
1247 //EVA Reminder Notification
1248 this.checkReminderOverlayDisplay(pageName, e);
1249
1250 //BAU //TODO ; Merge uncommented earlier branch
1251 //this.navigateToUrl(pageName, this.loggedUser.isQuickbalanceMode(), e);
1252 }
1253
1254
1255 }
1256
1257 openInAppUrl(f_url) {
1258
1259 var isIos = /iPad|iPhone|iPod/.test(navigator.userAgent);
1260 if (f_url) {
1261 if (window.cordova && window.cordova.exec) {
1262 //to show registration page in In app browser must as requested from Apple store.
1263 var url = f_url;
1264 var option = 'location=yes,toolbarposition=top,hidden=yes,clearcache=yes';
1265 var target = '_system';
1266 if (isIos) {
1267 console.log(">>>>>>>inside ios");
1268 option = 'location=no,toolbarposition=top,fullscreen=yes';
1269 target = '_blank';
1270 }
1271 window.cordova.exec(null, null, 'InAppBrowser', 'open', [url, target, option]);
1272 }
1273 else if (WL) {
1274 // use Worklight API to open link when WL is available
1275 console.log("first");
1276 WL.App.openURL(f_url, '_blank');
1277 } else {
1278 // fallback use window to open
1279 console.log("second");
1280 window.open(f_url, '_blank');
1281 }
1282 //Adobe Analytic Tracking
1283 digitalData.registration = {
1284 regType: "app:account-register"
1285 };
1286 if (typeof _satellite != 'undefined') {
1287 _satellite.track("registration-start");
1288 console.log("Adobe Analytic Tracking: registration-start");
1289 }
1290 } else {
1291 // put warn if registration_link is null and don't do any action
1292 console.warn("_config.registration_link value:", f_url);
1293 }
1294 };
1295
1296 /**
1297 * Navigate to specific url
1298 * @param {string} url [description]
1299 */
1300 navigateToUrl(url: string, quickBalance?: boolean, event?: Event/*, data?: any*/): void {
1301 if (!url) {
1302 return;
1303 }
1304
1305 if (quickBalance) {
1306 this.appEvents.emit({
1307 type: AppEvents.GOTO_PAGE_FROM_QUICKBALANCE,
1308 options: {
1309 url: url,
1310 param: {}
1311 }
1312 });
1313 return;
1314 }
1315 // if ($('body').hasClass('mobile')) {
1316 // this.closeSideBar(event);
1317 // }
1318 let param = {};
1319 // let userEnquiry: any = JSON.parse(localStorage.getItem('st_userEnquiry'));
1320 // var STstatus = userEnquiry.deviceSettingStatus.st;
1321 // var stI = userEnquiry.stIndicator;
1322 // var Customerstatus = localStorage.getItem('CustomerStatus');
1323 // console.log("Customerstatus loginstatus", Customerstatus);
1324 // console.log("STstatus in login page", STstatus);
1325 // var stored_ezaccount = localStorage.getItem("Store_Eztoken");
1326 // console.log("stored_ezaccount login", stored_ezaccount);
1327 // // if(stI=="TRUE" && ((Customerstatus=="owner" && !userEnquiry.deviceFTLFlag)&&(((STstatus=="N" || STstatus==null)|| STstatus=="A" ) && (stored_ezaccount==null || stored_ezaccount==undefined)))){
1328 // // localStorage.setItem("Page_Navigation",url);
1329 // // this.router.navigate(['ST',{}]);
1330 // // }
1331 // if (stI == "TRUE" && ((Customerstatus == "owner" && !userEnquiry.deviceFTLFlag) && ((stored_ezaccount == null || stored_ezaccount == undefined) || STstatus == "D"))) {
1332 // localStorage.setItem("Page_Navigation", url);
1333 // if (stored_ezaccount == null || stored_ezaccount == undefined) {
1334 // localStorage.setItem("Uninstall_Status", "true");
1335 // }
1336 // this.router.navigate(['FTL', {}]);
1337 // } else {
1338
1339 this.router.navigate(['dashboard', url], param);
1340 // }
1341
1342 }
1343
1344 togglePayment() {
1345 console.log("toggle fun call ========");
1346 this.showPaymentPopup = !this.showPaymentPopup;
1347 if (this.showPaymentPopup) {
1348 this.blackoutHeader(true);
1349 }
1350 else //EVA Reminders
1351 if(this.showReminders){
1352 this.blackoutReminderHeader_old(true,true);//this.blackoutReminderHeader(true,true);
1353 } else {
1354 this.blackoutHeader(false);
1355 }
1356 }
1357
1358
1359 onKeyUpAmount(event: Event): void {
1360 let el: any = event.target;
1361
1362 if (!el) {
1363 return;
1364 }
1365
1366 let val: string = el.value;
1367 let self: any = this;
1368 this.appEvents.emit({ type: AppEvents.CALC_AMOUNT });
1369
1370 setTimeout(function (): void {
1371 if (val === '') {
1372 self.paymentItem.amount = null;
1373 return;
1374 }
1375 self.paymentItem.amount = UtilService.convertToDecimal(val);
1376 }, 100);
1377 }
1378
1379 onAmountFocus(event: Event): void {
1380 let el: any = event.target;
1381
1382 if (!el) {
1383 return;
1384 }
1385
1386 let value: string = el.value;
1387
1388 if (!isNaN(<any>value)) {
1389 var val: number = parseInt(value, 10);
1390 if (val === 0) {
1391 el.value = '';
1392 }
1393 } else {
1394 el.value = '';
1395 }
1396 }
1397
1398 onMouseWheel(e: Event): void {
1399 if (!Utilities.isMobile()) {
1400 e.preventDefault();
1401 e.stopPropagation();
1402 }
1403 }
1404
1405 checkOnlyNumber(e: Event) {
1406 var key = (<any>e).keyCode || (<any>e).which;
1407 // Don't validate the input if below arrow, delete and backspace keys were pressed
1408 if (key == 37 || key == 38 || key == 39 || key == 40 || key == 8 || key == 46) { // Left / Up / Right / Down Arrow, Backspace, Delete keys
1409 return;
1410 }
1411
1412 key = String.fromCharCode(key);
1413 var regex = /[0-9¾]/g;
1414
1415 if (!regex.test(key)) {
1416 e.returnValue = false;
1417 if (e.preventDefault) {
1418 e.preventDefault();
1419 }
1420 }
1421 }
1422
1423 onKeyPressAmount(e: any): void {
1424 console.log('home onKeyPressAmount');
1425
1426
1427 if (e.key === "&" || e.key === "%" || e.key === "(") {
1428 e.target.value = e.target.value.replace(e.key, "");
1429 }
1430
1431 if(this.transferDuitAmount > 0){
1432 this.isEnterAmount = true
1433 this.doItNowLogoPath= "img/duitNow/duitnow-logo_old.png";
1434 } else{
1435 this.isEnterAmount = false
1436 this.doItNowLogoPath= "img/home/duitnow_icon_2.png";
1437 }
1438
1439 // this.eventEmitter.next(e);
1440 }
1441
1442 onBlurInputAmount(event: Event): void {
1443 console.log("login onBlurInputAmount");
1444 if(! (this.transferDuitAmount > 0)) {
1445 this.isEnterAmount = false;
1446 this.doItNowLogoPath= "img/home/duitnow_icon_2.png";
1447 }
1448 }
1449
1450 goToUrlGurestLogin() {
1451 document.getElementById('myDropdown').classList.toggle('show-home');
1452 let configData = JSON.parse(localStorage.getItem('configData'));
1453 console.log('login_link', configData.login_link)
1454 let self = this;
1455 WL.SimpleDialog.show(
1456 "Log in as Guest", "You will be redirected to CIMB Clicks mobile website.",
1457 [{
1458 text: "Proceed", handler: function () {
1459 self.goToUrl(configData.login_link);
1460 }
1461 },
1462 {
1463 text: "Cancel", handler: function () {
1464
1465 }
1466 }]
1467 );
1468 }
1469
1470 goToUrl(url) {
1471 console.log("navigator", navigator.userAgent);
1472 let option: string = 'location=yes,toolbarposition=top';
1473 let dBrowser: string = '_system';
1474 if (this.isIOS) {
1475 option = 'location=no,toolbarposition=top,fullscreen=yes';
1476 dBrowser = '_blank';
1477 }
1478 cordova.exec(null, null, 'InAppBrowser', 'open', [url, dBrowser, option]);
1479 }
1480
1481 //Retrieve the secure word
1482 onSecureWordSuccess(result: any) {
1483 this._ngZone.run(() => {
1484 this.hideLoader();
1485 // console.log('SecureWOrd Result change account', result);
1486
1487 this.showQuickSecurity(result.secureWord);
1488 });
1489 }
1490
1491 showQuickSecurity(secureWord: string): void {
1492
1493 // console.log('showQuickSecurity Result change account', secureWord);
1494
1495 this.appEvents.emit({
1496 type: AppEvents.HIDE_HEADER
1497 });
1498
1499
1500
1501 let dataModel: any = {
1502 secureWord: secureWord,
1503 password: ''
1504 };
1505
1506 this._ngZone.run(() => {
1507 this.isSecurityQrFlag = true;
1508 });
1509 let self = this;
1510 // console.log('going to call incremental auth ', this.isSecurityQrFlag);
1511 let nextFunction = function () {
1512 self._ngZone.run(() => {
1513 //call a service to pass password
1514 self.showLoader();
1515 self._ngZone.runOutsideAngular(() => {
1516 self.overviewService.callIncrementalAuth(dataModel.password, self.onIncrementalSuccess.bind(self), self.failureCallBack.bind(self));
1517 });
1518 });
1519 };
1520 this.sessionModel.dataForModal = {
1521 backFunction: null,
1522 nextFunction: nextFunction,
1523 data: dataModel
1524 }
1525
1526 }
1527
1528 onIncrementalSuccess(result: any) {
1529 // console.log(">>>>onIncrementalSuccess is coming", result, result.access_token);
1530 let self=this;
1531 this._ngZone.run(() => {
1532 this.hideLoader();
1533 // console.log('we got auth data', result.access_token);
1534 if (result.access_token) {
1535 this.showLoader();
1536 localStorage.setItem('LoginType', 'normal');
1537 console.log(">>>>>>>>going to Account Page ", this.isSecurityQrFlag, this.pageSession);
1538 this.isSecurityQrFlag = false;
1539 this.isLoaded = true;
1540 this.appEvents.emit({
1541 type: AppEvents.SHOW_HEADER
1542 });
1543
1544 if (this.pageSession == "setting") {
1545 this.router.navigate(['dashboard', DashboardPageUrl.SETTING_URL, false], {});
1546 }
1547 else if (this.pageSession == "qr-pay" && "true" == sessionStorage.getItem("passcodeMaximumValidCount")) {
1548
1549 WL.SimpleDialog.show("Alert", "Reset Passcode", [{
1550 text: "Proceed",
1551 handler: function() {
1552 console.log("alert Reset Passcode clicked");
1553 //Utilities.changeSecurityHeader(false);
1554 self.qrDataService.navigateQrData("MaxCountPasscode");
1555 self.router.navigate([DashboardPageUrl.QR_CREATE_PASSCODE_ACC_URL, {}])
1556 }
1557 }]);
1558 }
1559 else if (this.pageSession == "qr-pay") {
1560 this.router.navigate([DashboardPageUrl.QR_PAY_ONBOARDING_URL]);
1561 }
1562 else {
1563 this.navigateToUrl(this.pageSession, this.loggedUser.isQuickbalanceMode(), null);
1564 }
1565
1566 }
1567 });
1568 }
1569
1570
1571 onCloseSecurityHandler() {
1572 console.log("==onCloseSecurityHandler==");
1573 this.isSecurityQrFlag = false;
1574 this.appEvents.emit({
1575 type: AppEvents.PAGE_TITLE,
1576 pageTitle: 'Home',
1577 isAccountOverview: true
1578 });
1579
1580 this.appEvents.emit({
1581 type: AppEvents.SHOW_BACK_BUTTON,
1582 prevPage: "home",
1583 qrFlag: false,
1584 isShowBackButton: false
1585 });
1586
1587 this.appEvents.emit({
1588 type: AppEvents.HIDE_MENU_BACK_BUTTON,
1589 isHideMenuBackButton: true
1590 });
1591
1592 this.appEvents.emit({
1593 type: AppEvents.SHOW_CLOSE_ICON,
1594 isShowCloseIcon: false
1595 });
1596
1597 this.appEvents.emit({
1598 type: AppEvents.MODAL_HEADER,
1599 isModalHeader: false
1600 });
1601 this.appEvents.emit({
1602 type: AppEvents.SHOW_SETTING_ICON,
1603 isShowSetting: true
1604 });
1605
1606 this.appEvents.emit({ type: AppEvents.SHOW_HEADER });
1607 }
1608
1609 //Deals START
1610 callDealsApp() {
1611 //Defect Fixes for Post/Quick Login Deals to Home Navigation
1612 let logintype = localStorage.getItem('LoginType');
1613 if(logintype == 'quick'){
1614 localStorage.setItem('LoginType', 'quick');
1615 }
1616 else{
1617 localStorage.setItem('LoginType', 'postLogin');
1618 }
1619 this.router.navigate([DashboardPageUrl.DEALS_LAND_URL, {}]);
1620 }
1621 // fetch Deal data
1622 private fetchDeal(categoryName: string) {
1623 console.log('in fetch deal function');
1624 this.dealService.getDealsByCategoryV3("Latest", categoryName, c.HOME_PAGE_DEALS_COUNT).subscribe((data: any) => {
1625 this.globalService.set(categoryName, data.jsonApiModels && data.jsonApiModels.length > 0 ? data.jsonApiModels : []);
1626 setTimeout(() => {
1627 this.dealData[categoryName] = data.jsonApiModels;
1628 }, 1000);
1629 data.jsonApiModels.length > 0 ? this.showFeatureCarousel = true : this.showFeatureCarousel = false;
1630 });
1631 }
1632
1633 callDealsDetails(merchant_name, id, categoryVal, deal, selectedCarousel?) {
1634 localStorage.setItem('LoginType', 'postLogin');
1635 console.log("callDealsDetails :: merchant_name : ", merchant_name ," id: ",id ," categoryVal: ", categoryVal , deal , selectedCarousel);
1636 this.dealsDetailsInfo = {
1637 dealsMerchantName: merchant_name,
1638 dealId: id,
1639 countryCode: this.currentCountryVal,
1640 categoryName: categoryVal,
1641 backPath: 'postLogin',
1642 dealDetailsInfo: deal
1643 };
1644
1645 let currentCarouselIndex = selectedCarousel + 1;
1646 var self = this;
1647
1648 //Added for icams
1649 if(!deal._title)
1650 {
1651 deal._title= deal.Header1;
1652 }
1653
1654
1655 let internalPromotionBanner = categoryVal + ":carousel" + currentCarouselIndex + ":" + merchant_name + ":" + deal._title;
1656 let location="NA" + "," + "NA";
1657 if(self.userLocation)
1658 {
1659 location=self.userLocation.lat + "," + self.userLocation.lng;
1660 }
1661
1662 //Adobe Analytic
1663 digitalData.page = {
1664 pageInfo: {
1665 pageName: "app:HomeScreen",
1666 country: self.currentCountryVal,
1667 location: location,
1668 internalPromotionBanner : internalPromotionBanner
1669 }
1670 };
1671 console.log("internalPromotionBanner :: ",internalPromotionBanner);
1672
1673
1674 //Adobe Analytic Tracking
1675 if(typeof _satellite != 'undefined'){
1676 _satellite.track('bannerID');
1677 console.log('Adobe Analytic Tracking: bannerID', digitalData);
1678 }
1679
1680
1681 self.dealService.dealDetailsDataSet(self.dealsDetailsInfo);
1682 // this.router.navigate(['deals-details'], {});
1683 // Defect Fix for Post/Quick login Navigation from Deals to Home
1684 let logintype = localStorage.getItem('LoginType');
1685 if(logintype == 'quick'){
1686 localStorage.setItem('LoginType', 'quick');
1687 }
1688 else{
1689 localStorage.setItem('LoginType', 'postLogin');
1690 }
1691 this.router.navigate([DashboardPageUrl.DEALS_Details_URL]);
1692 // this.router.navigate(['deals-details']);
1693 }
1694
1695 navToViewAll(val) {
1696 // Defect Fix for Post/Quick login Navigation from Deals to Home
1697 let logintype = localStorage.getItem('LoginType');
1698 if(logintype == 'quick'){
1699 localStorage.setItem('LoginType', 'quick');
1700 }
1701 else{
1702 localStorage.setItem('LoginType', 'postLogin');
1703 }
1704 this.router.navigate([DashboardPageUrl.DEALS_view_allDeals_URL, val]);
1705 }
1706 public formatedExpiryDate(end_value) {
1707 let rs = '';
1708 if (end_value) {
1709 rs = format(end_value, c.DATE_FORMAT);
1710 }
1711
1712 return `Valid until ${rs}`;
1713 }
1714
1715 getCountryAsPerGps() {
1716 console.log('in getCountryAsPerGps');
1717 let lat = localStorage.getItem("GeoLocationLat");
1718 let long = localStorage.getItem("GeoLocationLong");
1719 console.log('lat long ', lat, long);
1720 let self = this;
1721 if (lat !== undefined && long !== undefined) {
1722 let apiKey = 'AIzaSyD83Xk8GmRUzzxsW6jy0Y2TVtV--Ipl4-k' // google palces api key
1723 let url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng=' + lat + ',' + long + '&key=' + apiKey
1724 $.ajax({
1725 type: "GET"
1726 , url: url
1727 , dataType: "json"
1728 , cache: false
1729 , headers: { "cache-control": "no-cache" }
1730
1731 , success: function (response) {
1732 let country;
1733 console.log('google places response', response);
1734 if (response.results.length > 0) {
1735 response.results[0].address_components.forEach(element => {
1736 if (element.types[0] == 'country') {
1737 country = element.long_name;
1738 console.log('country based on google response', country);
1739 }
1740 });
1741 localStorage.setItem("selectedCountry", country);
1742 self.globalService.changeCountry(country);
1743 self.currentCountryVal = country;
1744 let allDeals = self.globalService.get("3_deals" + country);
1745 console.log("allDeals", allDeals.length, allDeals);
1746 if (allDeals && allDeals.length > 0) {
1747 console.log("allDeals if");
1748 //self.nearMeFilter(allDeals); //Removed for icams
1749 } else {
1750 console.log("allDeals else");
1751 //self.downloadAllDeals("3_deals" + country);
1752 }
1753 }
1754 else {
1755 console.log('google places response default country set', response);
1756 localStorage.setItem("selectedCountry", country);
1757 self.currentCountryVal = country;
1758 }
1759
1760 // call fetch deal data fun
1761 self.globalService.changeCountry(country);
1762 //self.fetchDeal('featured');
1763
1764 }
1765 , error: function () {
1766 console.log('google places api error');
1767 localStorage.setItem("selectedCountry", Country.Malaysia);
1768 self.currentCountryVal = Country.Malaysia;
1769 // call fetch deal data fun
1770 self.globalService.changeCountry(Country.Malaysia);
1771 //self.fetchDeal('featured');
1772
1773 }
1774 });
1775 } else {
1776 console.log('lat long undefined');
1777 localStorage.setItem("selectedCountry", Country.Malaysia);
1778 this.currentCountryVal = Country.Malaysia;
1779 // call fetch deal data fun
1780 this.globalService.changeCountry(Country.Malaysia);
1781 //this.fetchDeal('featured');
1782
1783 }
1784 }
1785
1786 arrayLength = 0;
1787 private cnt = 0;
1788 private categoryList = NearMeCategoryList;
1789 downloadAllDeals(key, url?: string) {
1790 console.log('downloadAllDeals');
1791 this.globalService.isSearchReady.next(false);
1792 this.dealService.getDealsByCategoryV3(c.SORTDIRECTIONLATEST, this.categoryList[this.cnt], 50).subscribe((data: any) => {
1793 if (data && data.jsonApiModels.length != 0) {
1794 // ready to search
1795 if (data.jsonApiModels) {
1796 const newDealData = filterExpiryDeal(data.jsonApiModels);
1797 // console.log('new response length data filtered===', newDealData.length);
1798 this.combinedArr = [...this.combinedArr, ...newDealData];
1799 // console.log('Combined array length data===', this.combinedArr.length);
1800 this.arrayLength = this.arrayLength + data.jsonApiModels.length;
1801 // console.log('ARRRRRAy Length ======', this.arrayLength);
1802
1803 this.globalService.set(this.categoryList[this.cnt], newDealData);
1804 if (this.cnt < (this.categoryList.length - 1)) {
1805 this.cnt++;
1806 this.downloadAllDeals(key, data.metaData.links.next.href);
1807 } else {
1808 // console.log("all deals downloaded ", this.combinedArr);
1809 //this.nearMeFilter(this.combinedArr);
1810 this.loaderShow = false;
1811 }
1812 }
1813 else {
1814 this.loaderShow = false;
1815 // to do
1816 }
1817 }
1818 else {
1819 this.loaderShow = false;
1820 }
1821 }, (error) => {
1822 this.loaderShow = false;
1823 console.log('downloadAllDeals error', error);
1824 });
1825 }
1826
1827 setImage(deal) {
1828 if (deal.thumbnail !== undefined) {
1829 return this.assetsURL + deal.thumbnail.file.uri.url;
1830 } else if (deal.field_deal_image != null) {
1831 return deal.field_deal_image;
1832 } else {
1833 return "";
1834 }
1835 }
1836
1837 setIcamsImage(deal) {
1838 return deal.ImageURL;
1839}
1840
1841 //Deals END
1842 supportCenterCall(){
1843 console.log("supportCenterCall start=====");
1844 this.callWhatsNewService(); // testing for whats new data
1845 }
1846
1847
1848 // ******* EVA Reminder Notifications ********/
1849 /*
1850 * This Method checks if Service call for Reminders
1851 * is required
1852 */
1853 checkReminderCall() {
1854 //Reset ReminderItem
1855 this.qrDataService.reminderItemData = null;
1856 QRDataService.isReminderRouted = false;
1857
1858 //Reset refreshReminderCall in Overview Service to Rerun service call
1859 console.log("checkReminderCall Refresh=====", this.qrDataService.refreshReminderCall);
1860 if (this.qrDataService.refreshReminderCall == true) {
1861
1862 this.callWevServicetoGetTipByPaternMoneyThorRec();
1863 }
1864 else {
1865 console.log("Skip Reminders Refresh", this.qrDataService.moneyThorRemindersData);
1866 EvaUtilities.refreshCounters(this);
1867 }
1868 }
1869
1870
1871 /* Service call to get what's new data for First time
1872 * On success Parse the response
1873 * On Failure Activate Default Failure handling
1874 */
1875
1876 callWhatsNewService(): void{
1877 let self: any = this;
1878 self.showLoader();
1879 // var data = {
1880 // "ACCOUNT_NO": setAccNo,
1881 // "ACCOUNT_TYPE":setAccType
1882 // }
1883 let successCallBack: any = function (res: any) {
1884 self._ngZone.run(() => {
1885 console.log('callWhatsNewService Success====',res);
1886 self.getHomeDataFromServer(res);
1887 self.hideLoader();
1888
1889 });
1890 }
1891 this._ngZone.runOutsideAngular(() => {
1892 this.evaService.getWhatsNewService(successCallBack, this.failureCallBack.bind(this));
1893 });
1894 }
1895
1896
1897 getHomeDataFromServer(resObj){
1898 console.log("getHomeDataFromServer === ",resObj);
1899 if(resObj)
1900 {
1901 // localStorage.setItem('supportCenterData', 'true');
1902 if(resObj[0].onlineAcqWhatsNewCampaignsBO){
1903
1904 this.homePageBanner = resObj[0].onlineAcqWhatsNewCampaignsBO;
1905 // nativeStorage.setItem("homeWhatsNewBannerData",resObj[0].onlineAcqWhatsNewCampaignsBO);
1906 }
1907
1908 if(resObj[1]){
1909 this.homePageMenuDynamicObj = resObj[1];
1910 // nativeStorage.setItem("homePageMenuData",resObj[1]);
1911 console.log("res[1] ===== ",this.homePageMenuDynamicObj);
1912 }
1913
1914 if(resObj[2]){
1915 // this.homePageMenuDynamicObj = resObj.responseJSON.array[2];
1916 console.log("resObj[2] ===== ",resObj[2]);
1917 // nativeStorage.setItem("homePageTouchData",resObj[2]);
1918 }
1919
1920 if(resObj[3]){
1921 this.homeQuickLimitDynamicObj = resObj[3];
1922 console.log("res[3] ===== ",this.homeQuickLimitDynamicObj.itemValue);
1923 // nativeStorage.setItem("touchTranscationLimit", this.homeQuickLimitDynamicObj.itemValue);
1924 // nativeStorage.setItem("touchTranscationLimit", "300"); // temp check only
1925
1926 }
1927
1928
1929 }
1930 }
1931 /*
1932 * Make Service Call to Get Tip keys
1933 * from moneythor
1934 */
1935 callWevServicetoGetTipByPaternMoneyThorRec() {
1936 console.log("gettipsbypattern >>>>>>>>>>>>>>>>>");
1937 let self: any = this;
1938 var today = new Date();
1939 var minDate = new Date(today.setDate(today.getDate() - 5))
1940 .toISOString()
1941 .substr(0, 10); //min_date=2015-01-01 yyyy-mm-dd
1942 //debugger
1943 var reqDet = {};
1944 reqDet["operation"] = "gettipsbypattern";
1945 reqDet["postFlag"] = true;
1946 reqDet["criteria"] =
1947 "min_date=" + minDate + "&type=regexp&match=.*&expand_tip=true";
1948 //reqDet["criteria"] = 'type=regexp&match=.*&expand_tip=true'; //TEMP ENABLED FOR TESTING
1949 let successCallback: any = function (result: any) {
1950 self._ngZone.run(() => {
1951 console.log("Success Callback for Get Tip keys");
1952 self.hideLoader();
1953 //Reeset reminder List
1954 self.reminderList = [];
1955 self.qrDataService.moneyThorRemindersData = [];
1956 //Set Reminder Flag to False
1957 self.qrDataService.refreshReminderCall = false;
1958 EvaUtilities.resetReminderCounters(self);
1959 console.log("Call Flag is : ", self.qrDataService.refreshReminderCall);
1960 let response = self.evaService.getTipsResponse.response;
1961 EvaUtilities.parseReminderTips(self, response);
1962 });
1963 };
1964
1965 let failureCallback: any = function (result: any) {
1966 self._ngZone.run(() => {
1967 console.log("Get tips by Pattern Reminders failed");
1968 self.reminderList = [];
1969 self.hideLoader();
1970 });
1971 };
1972
1973 let source = reqDet["operation"];
1974 this._ngZone.runOutsideAngular(() => {
1975 this.showLoader();
1976 this.evaService.postMoneyThorTipsService(
1977 source,
1978 reqDet,
1979 successCallback,
1980 //this.failureCallBack.bind(this)
1981 failureCallback
1982 );
1983 });
1984
1985 }
1986
1987 /*
1988 * Router to Navigate on Reminder Click
1989 * Performs Array Splicing of Selected Data from List in MoneyThor
1990 */
1991 onReminderNavigate(reminderData: any){
1992 console.log("Starting Navigation to :: ", reminderData.title);
1993 //Set Reminder Data in service
1994 this.qrDataService.reminderItemData = reminderData;
1995 console.log("Data in Shared Service:: ", this.qrDataService.reminderItemData);
1996 //Remove Reminder Selected from Overlay List
1997 this.qrDataService.removeReminder(reminderData);
1998
1999 this.blackoutReminderHeader(false, false);
2000 //Set Reminder Routing true except for Pay loans and Cards
2001 if(this.qrDataService.reminderItemData.route != DashboardPageUrl.PAY_LOAN_URL &&
2002 this.qrDataService.reminderItemData.jsRoute != 'OR'){
2003 QRDataService.isReminderRouted = true;
2004 }
2005 this.navigateToUrl(reminderData.route, this.loggedUser.isQuickbalanceMode());
2006 }
2007
2008 //Close Reminder Overlay
2009 onCloseReminder(){
2010 this._ngZone.run(() => {
2011 this.showReminders = false;
2012 $('.page-container').attr('style', '-webkit-overflow-scrolling: touch !important ');
2013 this.blackoutReminderHeader(false, false);
2014 this.navigateToUrl(this.currentSelectedOverlayRoute, this.loggedUser.isQuickbalanceMode(), null);
2015 });
2016 }
2017
2018 /*
2019 * This method Handles routing for reminder flow
2020 * Junction Decides whether to Show Reminder overlay or Route to Page
2021 */
2022 checkReminderOverlayDisplay(routeSelected: any, _e: any) {
2023 this.currentSelectedOverlayRoute = routeSelected;
2024 this.hideLoader();
2025 EvaUtilities.createReminderList(this, routeSelected, _e);
2026 console.log("Reminder count:: ", this.reminderList.length);
2027 console.log("routeSelected :: ", routeSelected);
2028
2029 if (this.reminderList && this.reminderList.length > 0) {
2030
2031 if(routeSelected == 'JP' || routeSelected == 'jom-pay'){
2032 console.log("Routing to Jompay");
2033 localStorage.setItem('MoneythorJompayServiceCall', 'true'); // for moneythor Jompay data population testing
2034 }
2035 else if(routeSelected == 'NV' || routeSelected == 'pay-bills'){
2036 console.log("Routing to PayBill");
2037 localStorage.setItem('MoneythorServiceCall', 'true'); // for moneythor data population testing
2038 }
2039 else{
2040 console.log("Routing to Pay loans & Cards");
2041 }
2042
2043 this._ngZone.run(() => {
2044 $('.page-container').attr('style', '-webkit-overflow-scrolling: auto !important');
2045 console.log("Showing Reminders");
2046 this.blackoutReminderHeader_old(true,true);//this.blackoutReminderHeader(true, true);
2047 this.showReminders = true;
2048 });
2049 }
2050 else {
2051 console.log("No Reminders of Type: ", routeSelected);
2052 //Standard Navigation
2053 /*
2054 Added this to enble support center touch enable disable
2055 */
2056 console.log("getTouchEnableDisableFlag : ",this.getTouchEnableDisableFlag() , localStorage.getItem('LoginType'));
2057 if(this.getTouchEnableDisableFlag() && localStorage.getItem('LoginType') == "quick" && routeSelected != "account" && routeSelected != "rewards")
2058 {
2059 this._ngZone.runOutsideAngular(() => {
2060 this.overviewService.callForSecureWord(this.onSecureWordSuccess.bind(this), this.failureCallBack.bind(this));
2061 });
2062 }
2063 else if(routeSelected == "rewards"){
2064 this.routeToClicksChallenges();
2065 }
2066 else
2067 {
2068 if (routeSelected == "setting") { //Added to fix setting flow
2069 this.router.navigate(['dashboard', DashboardPageUrl.SETTING_URL, false], {});
2070 }
2071 else
2072 {
2073 this.navigateToUrl(routeSelected, this.loggedUser.isQuickbalanceMode(), _e);
2074 }
2075 }
2076
2077 }
2078 }
2079
2080 getTouchEnableDisableFlag(): boolean{
2081 let flag = false;
2082 if(this.qrDataService.homePageTouchEDMenuDynamicObj){
2083 for(let i=0; i < this.qrDataService.homePageTouchEDMenuDynamicObj.length; i++){
2084 console.log('this.touchEDMenuDynamicObj[i].itemName === ', this.qrDataService.homePageTouchEDMenuDynamicObj[i].itemName);
2085
2086 if (this.isIOS) {
2087 if(this.qrDataService.homePageTouchEDMenuDynamicObj[i].itemName === "Faceid.menu.enabledisable.flag"){
2088 console.log('isIOS touchEDMenuDynamicObj true === ')
2089 if(this.qrDataService.homePageTouchEDMenuDynamicObj[i].itemValue == 'D'){
2090 flag = true;
2091 return flag;
2092 }
2093 }
2094 }else{
2095 if(this.qrDataService.homePageTouchEDMenuDynamicObj[i].itemName === "Touchid.menu.enabledisable.flag"){
2096 console.log('isAndroid touchEDMenuDynamicObj true === ')
2097 if(this.qrDataService.homePageTouchEDMenuDynamicObj[i].itemValue == 'D'){
2098 flag = true;
2099 return flag;
2100 }
2101 }
2102 }
2103
2104
2105 }
2106 }
2107 console.log("getTouchEnableDisableFlag ",flag);
2108 return flag;
2109 }
2110
2111 /***************** Reminders End ************/
2112
2113 updateFCMtoken(){
2114 console.log("in updateFCMtoken function")
2115 if( !localStorage.getItem("cmId") || !localStorage.getItem("CMPushID") || !localStorage.getItem("fcmTokenRefresh")){
2116 console.log("fcm update abort,no data")
2117 return false;
2118 }
2119 if(localStorage.getItem("CMPushID")===localStorage.getItem("fcmTokenRefresh")){
2120 console.log("token ok");
2121 return false;
2122 }else{
2123 // alert("initiate fcm token update")
2124 }
2125
2126 let loginType = localStorage.getItem('LoginType');
2127 if(loginType == 'preLogin'){
2128 console.log("### preLogin - abort update token")
2129 return false;
2130 }
2131 console.log("### initiate updateFCMtoken")
2132 //let self: any = this;
2133 var fcmData={
2134 cmId:localStorage.getItem("cmId"),
2135 oldToken:localStorage.getItem("CMPushID"),
2136 newToken:localStorage.getItem("fcmTokenRefresh")//localStorage.getItem("fcmTokenRefresh")
2137 }
2138 console.log("fcmData="+fcmData)
2139
2140 let successCallback: any = function (result: any) {
2141 console.log("FCM token update success")
2142 console.log(JSON.stringify(result))
2143 localStorage.setItem("CMPushID",localStorage.getItem("fcmTokenRefresh"))
2144 //alert("fcm token update success!")
2145 };
2146
2147 let failureCallback: any = function (err:any,result: any) {
2148 console.log("FCM token update fail")
2149 console.log(JSON.stringify(result))
2150 console.log(JSON.stringify(err))
2151 //alert("fcm token update fail!")
2152 };
2153 this.FCMService.updateFCMtokenService("fcm-token-refresh",fcmData,successCallback,failureCallback);
2154 }
2155 ngOnDestroy(){
2156 console.log("leave homepage")
2157 let self=this;
2158 self._ngZone.runOutsideAngular(() => {
2159
2160 $("#title-head-block").removeClass("mainPageHeaderHeight");
2161 $("#headerOneApp").removeClass("forceGrayHeader");
2162 $("#shrinkTextHeader").removeClass("forceShrinkTextBlack");
2163 $("#iconHeader").removeClass("forceShrinkTextBlack");
2164 $("#postloginLogoutIcon").removeClass("icon--logout-black");
2165 $("#postloginLogoutIcon").addClass("icon--logout");
2166 });
2167 try{
2168 sliderObj.destroy();
2169 }catch(e){
2170 console.log("error on destroy slider",e)
2171 }
2172 this.subPostloginForm.unsubscribe();
2173 }
2174
2175 clickBackRebuildSlider(){
2176 let self=this;
2177 console.log("###clickBackRebuildSlider");
2178 self._ngZone.runOutsideAngular(() => {
2179 setTimeout(() => {
2180 console.log("rebuilding slider");
2181 try{
2182 sliderObj.destroy();
2183 }catch(e){
2184
2185 }
2186
2187 sliderObj=$("#light-slider").lightSlider({
2188 item: 1,
2189 enableTouch:true,
2190 enableDrag:true,
2191 freeMove:true,
2192 swipeThreshold: 40,
2193 controls: false,
2194 loop: true
2195 })
2196
2197 }, 300);
2198
2199 $("#headerOneApp").addClass("forceGrayHeader");
2200 $("#shrinkTextHeader").addClass("forceShrinkTextBlack");
2201 $("#iconHeader").addClass("forceShrinkTextBlack");
2202 $("#postloginLogoutIcon").addClass("icon--logout-black");
2203 $("#postloginLogoutIcon").removeClass("icon--logout");
2204
2205 });
2206
2207 }
2208
2209 gotoSettingByEvent(){
2210 console.log("gotoSettingByEvent");
2211
2212 this.appEvents.emit({ type: 'goto-setting-event' });
2213
2214 }
2215
2216 /***************** ESaver Clicks Challenges Banner *********/
2217
2218 routeToClicksChallenges(){
2219 this.router.navigate([DashboardPageUrl.ESAVER_CLICKS_CHALLENGES_URL], {});
2220 }
2221
2222 showConfirmation = function (tl, msg, yesCb, noCb, isOneButton, yesLabel, noLabel) {
2223 var md;
2224 md = $('#modal-confirm-mobile');
2225 md.find('#header h1').text(tl);
2226 md.find('#content p').html(msg);
2227 if (yesLabel) {
2228 md.find('.btn-yes').text(yesLabel);
2229 }
2230 if (noLabel) {
2231 md.find('.btn-no').text(noLabel);
2232 }
2233 md.fadeIn();
2234 md.find('.btn-yes').on('click', function () {
2235 md.fadeOut();
2236 md.find('.btn-yes').off('click');
2237 md.find('.btn-no').off('click');
2238 if (typeof yesCb === 'function') {
2239 yesCb();
2240 }
2241 });
2242 md.find('.btn-no').on('click', function () {
2243 md.fadeOut();
2244 md.find('.btn-yes').off('click');
2245 md.find('.btn-no').off('click');
2246 if (typeof noCb === 'function') {
2247 noCb();
2248 }
2249 });
2250 if (isOneButton) {
2251 md.find('.btn-yes').addClass('btn-full');
2252 md.find('.btn-no').hide();
2253 } else {
2254 md.find('.btn-yes').removeClass('btn-full');
2255 md.find('.btn-no').show();
2256 }
2257 };
2258}
2259