[text] promo ts

Viewer

copydownloadembedprintName: promo ts
  1. import { Component } from '@angular/core';
  2. import { App, IonicPage, ModalController, NavController, NavParams } from 'ionic-angular';
  3. import { PromoProvider } from '../../providers/promo/promo';
  4. import { GlobalProvider } from '../../providers/global/global';
  5. import { LoginProvider } from '../../providers/login/login';
  6. import { sha256 } from 'js-sha256';
  7. import * as moment from 'moment';
  8. import { AppsFlyerProvider } from '../../providers/apps-flyer/apps-flyer';
  9.  
  10. /**
  11.  * Generated class for the LandingPromoPage page.
  12.  *
  13.  * See https://ionicframework.com/docs/components/#navigation for more info on
  14.  * Ionic pages and navigation.
  15.  */
  16.  
  17. moment.locale('id');
  18. @IonicPage()
  19. @Component({
  20.   selector: 'page-landing-promo',
  21.   templateUrl: 'landing-promo.html',
  22. })
  23. export class LandingPromoPage {
  24.   dataNih: any;
  25.   promo_category: any;
  26.   promo_category_all: any;
  27.   conditionalDivider = false;
  28.   promo_category_child: any = [];
  29.   group_data_date: any = [];
  30.   dateConvertArray: any = [];
  31.   filteredItems: any = [];
  32.   dataList: any;
  33.   dataContent: any;
  34.   dataEmpty: any = '';
  35.   tabsActive: any;
  36.   filter: any = {
  37.     category: '',
  38.     sort: [],
  39.     brand: [],
  40.   };
  41.   page: number = 1;
  42.   limit: number = 10; // Set your desired limit
  43.   defaultCustName: string = "Bunga";
  44.   paginationSearch: any;
  45.   custName: any;
  46.   resultName: any;
  47.   loading: boolean = true;
  48.   tabsRekomendasi = true;
  49.   tampil = true;
  50.   floatingButtonShow = false;
  51.   emptyData: string;
  52.   tampilErrorEmptyData = true;
  53.   dataRekomendasi = [
  54.     {
  55.       category_id: 0,
  56.       category_name: "Rekomendasi"
  57.     }
  58.   ];
  59.  
  60.   constructor(public navCtrl: NavController,
  61.     public navParams: NavParams,
  62.     public promoprov: PromoProvider,
  63.     public global: GlobalProvider,
  64.     public modal: ModalController,
  65.     public app: App,
  66.     public loginProv: LoginProvider,
  67.     public appsFlyerProv: AppsFlyerProvider,
  68.   ) {
  69.     if (this.global.isLogin) {
  70.       this.setCustName();
  71.     }
  72.   }
  73.  
  74.  
  75.  
  76.   ionViewDidLoad() {
  77.     console.log('ionViewDidLoad LandingPromoPage');
  78.  
  79.     // this.dataRekomendasi
  80.     if (this.global.isLogin) {
  81.       this.loadPromo()
  82.     }
  83.   }
  84.  
  85.   ionViewDidEnter() {
  86.     if (this.global.isLogin) {
  87.       this.getListDataPromo()
  88.     } else {
  89.       this.global.getAlertBasic("Silahkan Login terlebih dahulu", "OK").onWillDismiss(() => {
  90.         this.global.app.getRootNav().push("LockscreenNewPage");
  91.       })
  92.     }
  93.   }
  94.  
  95.   ionViewWillEnter() {
  96.     if (this.global.isLogin) {
  97.       this.getListDataPromo()
  98.     }
  99.   }
  100.  
  101.   back() {
  102.     this.app.getRootNav().push("TabsPage");
  103.   }
  104.  
  105.   loadPromo(alias?) {
  106.     this.promoprov.checkUpdatePromo((isUpdate) => {
  107.       this.getBrgMega(isUpdate);
  108.       // if (this.global.isLogin) {
  109.       //   this.getListDataPromo();
  110.       // } else {
  111.       //   this.global.getAlertBasic("Silahkan Login terlebih dahulu","OK").onWillDismiss(()=>{
  112.       //     this.global.app.getRootNav().push("LockscreenNewPage");
  113.       //   })
  114.       // }
  115.     });
  116.     // this.getListDataPromo();
  117.   }
  118.  
  119.   setCustName() {
  120.     if (this.global.isLogin) {
  121.       this.defaultCustName = "";
  122.       this.custName = "";
  123.       this.global
  124.         .getSecureData(this.global.LOCAL_CUSTNAME)
  125.         .then((cust_name) => {
  126.           this.defaultCustName = this.global.SecureStorage.decrypt(
  127.             cust_name,
  128.             this.global.keys.secretKey
  129.           );
  130.           // this.global.log(this.defaultCustName,'name nih');
  131.           this.custName = this.defaultCustName.split(" ");
  132.           this.resultName = this.custName[0];
  133.           // const resultName = this.custName[0]
  134.           this.global.log(this.resultName, 'result name nih');
  135.           return this.resultName
  136.         });
  137.     }
  138.   }
  139.  
  140.   getBrgMega(isUpdate) {
  141.     this.promoprov
  142.       .getBrgMega(isUpdate)
  143.       .then((result: any) => {
  144.         // this.promo_category  = result.data;
  145.         this.loading = true
  146.         console.log(result, 'result nih');
  147.         let temp = result.data;
  148.         this.promo_category = [];
  149.  
  150.         // let temp_category = {
  151.         //   category_id: "0",
  152.         //   category_image: "https://ibank.bankmega.com/payget/imagepromo/dining.png",
  153.         //   category_name: "YOUR COUPON",
  154.         //   category_url: "https://msmiledev.bankmega.com/service/getpromobm?idcategory=13",
  155.         //   display_image: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAM4AAADOCAYAAAB2Hz3EAAAACXBIWXMAAAsSAAALEgHS3X78AAARfklEQVR42u2dS2wbxx2Hf5Yth2ZeK1gIKCRVxJPJoEVNAj7YERBLqA3YCGJb6cUKWjixWyAy8kCCAH0AiZMemiJtkSaQDm2dx6HOJZXliwPIheUASpyihSmjRUmfpCgOxKIKxLxkKpatHoaTXS53lrPkkuIufx9AWBaplTjcb/+Pmd3dsLa2hpo4PmIAOAhge+nxAIiajRuBSATo7BRfk/X6HD7Fxo1XsWXLR7jrrr/jRz/+yPLsTQDfAPgawDKAVdVmNngW5/jIbgBPAzjAT0GDzk4gGgU2beJYtCIbOr7ErdF3kU6/iR/suWp79isAn5WEqlEcIcwJRhYP3HqriDIkGESjf8WDD/4K3/3eF7Yo9F8ARW/iiJTsBICnOLIeuO024JZbOA5BjED33P0cfvLTSdsz/ytFIA1xjo/0AZgA8H2OKKVpu+jzs58/Z/vugow8anGOj2wHcAHAnRxFD2zeDNx+O8chDNxyyzkcOPCcJXW7CeATADc7KE0D6hoSDlZW9uDMmVcs3+kA0CW/cKpp3qI0NR2hgI4OjkPY5Hn511Z57oDiU36LNU2taRrrmlCyvPww/vTHvdYqtsMWbQ6C8zN1iNPJMQgrVz99Bf/+1x2l/22xR5xXOUI10klpQs3azdtx9qycktncYYk2RwDcyxEiRMFXXz2Kv527B8Ama8Q5wZEhpAqXLz8MyK6aaD8z2hBSPer80BQHOMIRIUSDGzfuxrvv3ifF2c4RIU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zawPWmcDoybvOYEm7t1q95rMh1ce+c4h7EVK3G4tupFrm/3/9CvxFRTLXNdFqsGohGzW6crJHkglJCcbRZXi4/Et/vMPnX318ZSVSFuZsMctJU9VonGd2259QSt75eHgDkAk7JC8+bETOREFJt7TYnYK/kmK5RnCrMz5dLIU8h+KB08loqXbm2y2n+RCcdsj+3VfOUBt3tOS3xkdHGyhNPivegSiv7+4HuCa4eoDg11Dlutcq5SXWNs7VbPw3UrYdkJLBHSHvdpdqe/W/VmeBk6sbmgK87yORk+ZHYnl5Zj/hudVA0WrkDS6nsNZZqm/aIY0/drliW4nhZ7WxdqU0YcRy5knNfZi/lyuVE+maXwS6eVYbFxfIIsS1hSqeSRrVN+bw9tUwkzOfs25R/6/KyOMXAes7O/Lx5TQXZHIhGzTSVtB0b1kYe3w1gikNBSKNSNUIIxSGE4hBCcQihOIRQHEIIxSGE4hBCcQihOIRQHEIoDoeAEIpDCMUhhOIQQnEIoTiEEIpDCMUhhOIQQnEIoTiEEIpDCMUhhOIQEhpx5jgMhHji/Q6MjlEcQrwxJ1O19zkWhGgzI8WZ4FgQos0ExSHEG5cxOlZK1USdw3SNkOq8BZS3o09wTAhx5fNKcUbHLjDqEOLKqxgdK9gjDgA8zbEhxJGPMTr2bVZWLs7o2AyAFzlGhFRw0PqfDWtra5UvOT5yAcADHCtCAACPYnTsLes3OlzsuszxIgRv26VRiyMKoN2Uh7Q5f8Do2BGnJ9Sro0153ub4kTZNz5TNMucap7LmOQjRv76T40lCzmUAR0qNMtQnjpDHgJgkfYpjS0LIxwBOONUz9YlTLtARiDmfezneJOCcATChK0zt4pRL1Feqg7aXHoQEgQsAZgBckCsBvPJ/WX56s1Vul80AAAAASUVORK5CYII=",
  156.         //   file_name: "dining.png",
  157.         //   file_type: "png",
  158.         //   dummy:true,
  159.         // }
  160.         // this.promo_category.push(temp_category);
  161.  
  162.         temp.forEach((item, index) => {
  163.           this.promo_category.push(item);
  164.         });
  165.  
  166.         this.promo_category.forEach((item, index) => {
  167.           if (index == 0) {
  168.             if (item.dummy) {
  169.               this.getApi_PromoNew(item.category_url, index, true, item.dummy);
  170.             } else {
  171.               this.getApi_PromoNew(item.category_url, index);
  172.             }
  173.           } else {
  174.             this.getApi_PromoNew(item.category_url, index, false);
  175.           }
  176.         });
  177.  
  178.         // this.search(this.promo_category[0], 0);
  179.         this.searchRekomendasi(this.dataRekomendasi[0], 0);
  180.         // if(this.dataRekomendasi[0]) {
  181.         //   this.appsFlyerProv.logAppsFlyer('af_promo_rekomendasi_screen', {});
  182.         // }
  183.         this.tabsRekomendasi = true;
  184.       })
  185.       .catch((err) => {
  186.         this.global.log("brgmega_err", err);
  187.       });
  188.   }
  189.  
  190.   getApi_PromoNew(url, index, pushdata = true, dummy = false) {
  191.     this.tabsRekomendasi = true;
  192.     if (url && dummy == false) {
  193.       this.promoprov.getBrgMegaDetailNew(url, (data) => {
  194.         // this.promo_category_child = [];
  195.         if (data) {
  196.           if (data.RC == "00") {
  197.             // this.tabsRekomendasi = false
  198.             this.loading = true;
  199.             var temp: any = data.data;
  200.             var array: any = [];
  201.             this.global.log(url, 'data detail');
  202.             this.global.log(temp, 'data detail berhasil');
  203.  
  204.             temp.forEach((item, index) => {
  205.               array.push(item);
  206.             });
  207.  
  208.             this.promo_category[index]["child"] = array;
  209.             if (pushdata) {
  210.               this.promo_category_child = array;
  211.             }
  212.           }
  213.         }
  214.       });
  215.     } else {
  216.       this.promo_category_child = [];
  217.       if (dummy) {
  218.         let temp_dummy = {
  219.           colour: "putih",
  220.           front_banner: "assets/dashboard2/kupon.png",
  221.           id: 2590,
  222.           id_category: 15,
  223.           language: "id",
  224.           // link_id: "www.bankmega.com/promo/samsung-po-galaxy-tab-s8-5g",
  225.           link_id: "",
  226.           name_category: "E-Commerce",
  227.           title: "Pre Order Samsung Galaxy Tab S8 Series 5G",
  228.           dummy: true,
  229.         };
  230.  
  231.         var array: any = [];
  232.         array.push(temp_dummy);
  233.         array.push(temp_dummy);
  234.         array.push(temp_dummy);
  235.  
  236.         this.promo_category[index]["child"] = array;
  237.         this.tabsRekomendasi = false
  238.         this.loading = true;
  239.         if (pushdata) {
  240.           this.promo_category_child = array;
  241.         }
  242.       }
  243.     }
  244.   }
  245.  
  246.   searchRekomendasi(data, index) {
  247.     this.global.log(data);
  248.     this.appsFlyerProv.logAppsFlyer('af_promo_rekomendasi', {});
  249.     this.tabsRekomendasi = true
  250.     this.floatingButtonShow = false;
  251.     this.filter.category = data.category_id;
  252.     // this.search(data,index);
  253.     // this.promo_category_child = []
  254.     this.getListDataPromo();
  255.     this.promo_category_child = [];
  256.     this.dateConvertArray = [];
  257.   }
  258.  
  259.   handlePromoAll() {
  260.     if (this.promo_category_all.category_url) {
  261.       this.app.getRootNav().push('PromoPage', {
  262.         cat_id: this.promo_category_all.category_id,
  263.         cat_name: this.promo_category_all.category_name,
  264.         cat_url: this.promo_category_all.category_url,
  265.         list_kategori: this.promo_category
  266.       });
  267.     }
  268.   }
  269.  
  270.   formatDate(date) {
  271.     return moment(date).format('dddd, DD MMMM YYYY')
  272.   }
  273.  
  274.   formatTime(time) {
  275.     return moment(time).format('HH:mm')
  276.   }
  277.  
  278.   search(data, index) {
  279.     this.filter.category = data.category_id;
  280.     this.promo_category_all = data;
  281.     this.global.log(data, 'data');
  282.     // this.tabsActive = data.category_name;
  283.     this.tabsActive = data.category_name;
  284.     this.global.log(this.tabsActive, 'data tabs appsflyer');
  285.     if (data.category_name == "Dining") {
  286.       this.appsFlyerProv.logAppsFlyer('af_promo_dining', {});
  287.       this.appsFlyerProv.logAppsFlyer('af_promo_dining_screen', {});
  288.     } else if (data.category_name == "Travel & Entertainment") {
  289.       this.appsFlyerProv.logAppsFlyer('af_promo_travel', {});
  290.       this.appsFlyerProv.logAppsFlyer('af_promo_travel_screen', {});
  291.     } else if (data.category_name == "E-commerce") {
  292.       this.appsFlyerProv.logAppsFlyer('af_promo_ecommerce', {});
  293.       this.appsFlyerProv.logAppsFlyer('af_promo_ecommerce_screen', {});
  294.     } else if (data.category_name == "Lifestyle") {
  295.       this.appsFlyerProv.logAppsFlyer('af_promo_lifestyle', {});
  296.       this.appsFlyerProv.logAppsFlyer('af_promo_lifestyle_screen', {});
  297.     } else if (data.category_name == "CT Corp Lifetime Benefit") {
  298.       this.appsFlyerProv.logAppsFlyer('af_promo_ctcorp', {});
  299.       this.appsFlyerProv.logAppsFlyer('af_promo_ctcorp_screen', {});
  300.     } else if (data.category_name == "Telecommunication & Utilities") {
  301.       this.appsFlyerProv.logAppsFlyer('af_promo_telco', {});
  302.       this.appsFlyerProv.logAppsFlyer('af_promo_telco_screen', {});
  303.     } else if (data.category_name == "Lainnya") {
  304.       this.appsFlyerProv.logAppsFlyer('af_promo_lainnya', {});
  305.       this.appsFlyerProv.logAppsFlyer('af_promo_lainnya_screen', {});
  306.     }
  307.     this.tabsRekomendasi = false
  308.     this.floatingButtonShow = true;
  309.     this.loading = true;
  310.     if (data.child) {
  311.       // this.promo_category_child = data.child;
  312.       this.global.log(this.promo_category_child,'promo category child');
  313.       const newGroup = [];
  314.       data.child.forEach((item) => {
  315.         const date = item.publishing_date;
  316.         const existingGroup = newGroup.findIndex(
  317.           (group) => group.date === date
  318.         );
  319.  
  320.         if (existingGroup > -1) {
  321.           newGroup[existingGroup].items.push(item);
  322.         } else {
  323.           newGroup.push({ date: date, items: [item] });
  324.         }
  325.       })
  326.       this.promo_category_child  = newGroup
  327.       // this.promo_category_child.forEach((item) => {
  328.       //   this.global.log(item,'item data nih');
  329.       //   const date = item.publishing_date;
  330.       //   const existingGroup = this.group_data_date.find(
  331.       //     (group) => group.date === date
  332.       //   );
  333.  
  334.       //   this.global.log(existingGroup,'grup existing');
  335.       //   if (existingGroup) {
  336.       //     existingGroup.items.push(item);
  337.       //   } else {
  338.       //     this.group_data_date.push({ date: date, items: [item] });
  339.       //   }
  340.       //   this.global.log(existingGroup,'grup existing');
  341.       //   this.global.log(this.group_data_date,'group_data_date  existing');
  342.       // })
  343.     } else {
  344.       this.loading = true;
  345.       this.getApi_PromoNew(data.category_url, index);
  346.     }
  347.   }
  348.  
  349.   getListDataPromo() {
  350.     if (this.global.isLogin) {
  351.       // let loader = this.global.loading();
  352.       // loader.present();
  353.       // this.loading = true;
  354.       let resultNumber = sha256(this.loginProv.mobile);
  355.       this.global.newRequestWs('api/v1/promo-recommendation', {
  356.         uuid: resultNumber,
  357.         page: this.page,
  358.         limit: this.limit,
  359.         SimInfo: {
  360.           simSerialNumber: this.global.AESNEW.encrypt(this.global.rsltSim.simSerialNumber, this.global.keys),
  361.           countryCode: this.global.rsltSim.countryCode,
  362.           subscriberId: this.global.rsltSim.subscriberId,
  363.           carrierName: this.global.rsltSim.carrierName,
  364.           deviceId: this.global.rsltSim.deviceId
  365.         },
  366.         DeviceInfo: {
  367.           model: this.global.devInfo.model,
  368.           platform: this.global.devInfo.platform,
  369.           uuid: this.global.devInfo.uuid,
  370.           version: this.global.devInfo.version
  371.         },
  372.         Latlon: this.global.rsltGps
  373.       }).then((res: any) => {
  374.         this.global.log('promo-recommendation res', res.data);
  375.         this.global.log('promo-recommendation res1', res.data.data);
  376.         this.dataContent = res.data.map((item, index) => {
  377.           return item.data.map((content, index) => {
  378.             return content
  379.           })
  380.         })
  381.         // loader.dismiss();
  382.         this.loading = false;
  383.         // this.dataList = [];
  384.         this.dataList = res.data;
  385.         this.promo_category_child = [];
  386.         // Increment the page for the next API call
  387.         // this.page++;
  388.  
  389.         // Complete the infinite scroll event
  390.         // if (event) {
  391.         //   this.loading = false;
  392.         //   event.complete();
  393.         // }
  394.       }).catch(err => {
  395.         this.global.log('recomendasi list', err);
  396.         // loader.dismiss();
  397.         this.emptyData = err.RCDesc
  398.         this.tampilErrorEmptyData = true
  399.         this.loading = true;
  400.         this.tampil = false;
  401.         this.dataList = [];
  402.       })
  403.     } else {
  404.       this.global.getAlertBasic("Silahkan Login terlebih dahulu", "OK").onWillDismiss(() => {
  405.         this.global.app.getRootNav().push("LockscreenNewPage");
  406.       })
  407.     }
  408.   }
  409.  
  410.  
  411.   getListDataPromoDetail(link, title, message) {
  412.     this.global.log(link, 'campaign_id');
  413.     let loader = this.global.loading();
  414.     loader.present();
  415.     let resultNumber = sha256(this.loginProv.mobile);
  416.     this.global.newRequestWs('api/v1/promo-recommendation/detail', {
  417.       uuid: resultNumber,
  418.       link: link,
  419.       SimInfo: {
  420.         simSerialNumber: this.global.AESNEW.encrypt(this.global.rsltSim.simSerialNumber, this.global.keys),
  421.         countryCode: this.global.rsltSim.countryCode,
  422.         subscriberId: this.global.rsltSim.subscriberId,
  423.         carrierName: this.global.rsltSim.carrierName,
  424.         deviceId: this.global.rsltSim.deviceId
  425.       },
  426.       DeviceInfo: {
  427.         model: this.global.devInfo.model,
  428.         platform: this.global.devInfo.platform,
  429.         uuid: this.global.devInfo.uuid,
  430.         version: this.global.devInfo.version
  431.       },
  432.       Latlon: this.global.rsltGps
  433.     }).then((res: any) => {
  434.       this.global.log('promo-recommendation detail res', res);
  435.       loader.dismiss();
  436.       if (res.RC == "00") {
  437.         this.global.app.getRootNav().push('LandingPromoIframePage', {
  438.           data_url: link,
  439.           title: title,
  440.           message: message
  441.         })
  442.       } else {
  443.         this.global.httpErrorHandler(res);
  444.       }
  445.     }).catch(err => {
  446.       this.global.log('listMasuk_err detail', err);
  447.       loader.dismiss();
  448.       // this.global.httpErrorHandler(err);
  449.     })
  450.   }
  451.  
  452.   getDetailCategory(link_id, title, message) {
  453.     this.global.log(link_id, 'link_id detail');
  454.     this.global.log(title, 'title detail');
  455.     this.global.log(message, 'message detail');
  456.     this.global.log(this.tabsActive, 'tabs active');
  457.  
  458.     if (this.tabsActive == "Dining") {
  459.       this.appsFlyerProv.logAppsFlyer('af_promo_dining_message', {
  460.         promo_title: title
  461.       });
  462.     } else if (this.tabsActive == "Travel & Entertainment") {
  463.       this.appsFlyerProv.logAppsFlyer('af_promo_travel_message', {
  464.         promo_title: title
  465.       });
  466.     } else if (this.tabsActive == "E-commerce") {
  467.       this.appsFlyerProv.logAppsFlyer('af_promo_ecommerce_message', {
  468.         promo_title: title
  469.       });
  470.     } else if (this.tabsActive == "Lifestyle") {
  471.       this.appsFlyerProv.logAppsFlyer('af_promo_lifestyle_message', {
  472.         promo_title: title
  473.       });
  474.     } else if (this.tabsActive == "CT Corp Lifetime Benefit") {
  475.       this.appsFlyerProv.logAppsFlyer('af_promo_ctcorp_message', {
  476.         promo_title: title
  477.       });
  478.     } else if (this.tabsActive == "Telecommunication & Utilities") {
  479.       this.appsFlyerProv.logAppsFlyer('af_promo_telco_message', {
  480.         promo_title: title
  481.       });
  482.     } else if (this.tabsActive == "Lainnya") {
  483.       this.appsFlyerProv.logAppsFlyer('af_promo_lainnya_message', {
  484.         promo_title: title
  485.       });
  486.     }
  487.     this.global.app.getRootNav().push('LandingPromoIframePage', {
  488.       data_url: link_id,
  489.       title: title,
  490.       message: message ? message.replace(/<[^>]*>/g, '') : null,
  491.     })
  492.   }
  493. }
  494.  

Editor

You can edit this paste and save as new:


File Description
  • promo ts
  • Paste Code
  • 29 Apr-2024
  • 22.08 Kb
You can Share it: