Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component } from '@angular/core';
- import { NavController, NavParams,ViewController } from 'ionic-angular';
- import { MyApp } from '../../app/app.component';
- import { AddShowcaseSalesPage } from '../add-showcase-sales/add-showcase-sales';
- import { EditShowcaseSalesPage } from '../edit-showcase-sales/edit-showcase-sales';
- import { HttpService } from '../../providers/http-service';
- import { Session } from '../../providers/session';
- /**
- * Generated class for the ShopShowcaseSalesPage page.
- *
- * See https://ionicframework.com/docs/components/#navigation for more info on
- * Ionic pages and navigation.
- */
- @Component({
- selector: 'page-shop-showcase-sales',
- templateUrl: 'shop-showcase-sales.html',
- })
- export class ShopShowcaseSalesPage {
- public searchbarShow: boolean = false;
- public data;
- public static TAG = "Shop ShowCase";
- public dataList;
- public isDataLoad: boolean = false;
- public dataListReady: boolean = false;
- constructor(
- public navCtrl: NavController,
- public navParams: NavParams,
- public http: HttpService,
- public session: Session,
- public viewCtrl: ViewController)
- {
- try{
- this.data = {};
- }catch(error) {
- MyApp.consoleLog("some error happen", error)
- }
- }
- ionViewDidLoad() {
- console.log('ionViewDidLoad ShopShowcaseSalesPage');
- }
- Search(){
- this.searchbarShow = true;
- }
- hideSearchbar(){
- this.searchbarShow = false;
- }
- back(event: Event) {
- this.navCtrl.pop();
- }
- navigateToAddShowcase(){
- this.navCtrl.push(AddShowcaseSalesPage);
- }
- ionViewDidEnter(){
- try{
- this.loadShowcase();
- }catch(error) {
- MyApp.consoleLog("Some Error Happen", error);
- }
- }
- loadShowcase(){
- let link = "http://localhost/phpscring/shop_showcase_sales/load_showcase";
- let user;
- user = {};
- user.id = this.session.getUserID();
- let postParams = {
- "link": link,
- "data": user
- }
- this.http.postService(postParams).then((data)=> {
- let response;
- response ={};
- response.data = data;
- MyApp.consoleLog(ShopShowcaseSalesPage.TAG, "data", data);
- MyApp.consoleLog(ShopShowcaseSalesPage.TAG, "response", response);
- if(this.isDataLoad == true) {
- this.dataListReady =false;
- this.buildData(response);
- }else{
- this.isDataLoad = true;
- this.dataListReady = false;
- this.buildData(response);
- }
- }, (error) => {
- MyApp.consoleError(ShopShowcaseSalesPage.TAG + "Couldn't connect to server", error);
- });
- }
- buildData(response){
- this.dataList = [];
- if(response.data.length != 0){
- for(let i=0; i<response.data.length; i++){
- this.dataList[i] = response.data[i]
- }
- MyApp.consoleLog(ShopShowcaseSalesPage.TAG, "list data", this.dataList);
- }
- }
- deleteShowcase(id: any){
- let link = "http://localhost/phpscring/shop_showcase_sales/delete_showcase";
- MyApp.consoleLog(ShopShowcaseSalesPage.TAG, "id ", id);
- let deleteShowcase;
- deleteShowcase = {};
- deleteShowcase.id = id;
- let postParams = {
- "link": link,
- "data": deleteShowcase
- }
- MyApp.consoleLog(ShopShowcaseSalesPage.TAG, "postParams ", postParams);
- this.http.postService(postParams).then((data)=>{
- this.data.response = data;
- MyApp.consoleLog(ShopShowcaseSalesPage.TAG, " data response ", data);
- this.viewCtrl._didEnter();
- }, error => {
- MyApp.consoleError(ShopShowcaseSalesPage.TAG, error);
- });
- MyApp.consoleLog("ShopShowcase", "Delete Showcase");
- }
- editShowcase(id: any){
- this.navCtrl.push(EditShowcaseSalesPage, {"id": id});
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement