Пример #1
0
var BuyerTabsPage = /** @class */ (function () {
    function BuyerTabsPage(db, fireAuth, navCtrl) {
        var _this = this;
        this.db = db;
        this.fireAuth = fireAuth;
        this.navCtrl = navCtrl;
        this.homeRoot = BuyerHomepagePage;
        this.feedsRoot = BuyerMessagesPage;
        this.notificationsRoot = BuyerNotificationsPage;
        this.moreOptionsRoot = BuyerMoreOptionsPage;
        this.notif = 0;
        //Counts unread notifications
        db.list('users/' + fireAuth.auth.currentUser.uid + '/notifications/').valueChanges().subscribe(function (data) {
            _this.notif = 0;
            data.forEach(function (notif) {
                if (notif.notificationUnread == 1) {
                    _this.notif++;
                }
            });
        });
        console.log(this.notif);
    }
    BuyerTabsPage = __decorate([
        IonicPage(),
        Component({
            selector: 'page-buyer-tabs',
            templateUrl: 'buyer-tabs.html'
        }),
        __metadata("design:paramtypes", [AngularFireDatabase,
            AngularFireAuth,
            NavController])
    ], BuyerTabsPage);
    return BuyerTabsPage;
}());
Пример #2
0
var ListPage = /** @class */ (function () {
    function ListPage(navCtrl, navParams, auth, afs, op, viewCtrl) {
        this.navCtrl = navCtrl;
        this.navParams = navParams;
        this.afs = afs;
        this.op = op;
        this.viewCtrl = viewCtrl;
        this.groupvar = 'variety';
        this.ordervar = 'unitCost';
        this.listType = navParams.get('type');
        this.user = auth.user$.value;
    }
    ListPage.prototype.ionViewDidLoad = function () {
        this.productsList$ = this.afs.col$("business/" + this.user.busId + "/" + this.listType);
    };
    ListPage.prototype.detail = function (id) {
        this.navCtrl.push('ProductFormPage', { id: id });
    };
    ListPage.prototype.closeModal = function () {
        this.viewCtrl.dismiss();
    };
    ListPage = __decorate([
        IonicPage(),
        Component({
            selector: 'page-list',
            templateUrl: 'list.html',
        }),
        __metadata("design:paramtypes", [NavController, NavParams, AuthProvider, FirestoreProvider, OrdersProvider, ViewController])
    ], ListPage);
    return ListPage;
}());
var BuyerBillingAddressPage = /** @class */ (function () {
    function BuyerBillingAddressPage(navCtrl, navParams) {
        this.navCtrl = navCtrl;
        this.navParams = navParams;
    }
    BuyerBillingAddressPage.prototype.ionViewDidLoad = function () {
        console.log('ionViewDidLoad BuyerBillingAddressPage');
    };
    BuyerBillingAddressPage = __decorate([
        IonicPage(),
        Component({
            selector: 'page-buyer-billing-address',
            templateUrl: 'buyer-billing-address.html',
        }),
        __metadata("design:paramtypes", [NavController, NavParams])
    ], BuyerBillingAddressPage);
    return BuyerBillingAddressPage;
}());
Пример #4
0
var RegisterPage = /** @class */ (function () {
    function RegisterPage(navCtrl, navParams) {
        this.navCtrl = navCtrl;
        this.navParams = navParams;
    }
    RegisterPage.prototype.ionViewDidLoad = function () {
        console.log('ionViewDidLoad RegisterPage');
    };
    RegisterPage = __decorate([
        IonicPage(),
        Component({
            selector: 'page-register',
            templateUrl: 'register.html',
        }),
        __metadata("design:paramtypes", [NavController, NavParams])
    ], RegisterPage);
    return RegisterPage;
}());
Пример #5
0
var OrderDetailPage = /** @class */ (function () {
    function OrderDetailPage(navCtrl, navParams) {
        this.navCtrl = navCtrl;
        this.navParams = navParams;
    }
    OrderDetailPage.prototype.ionViewDidLoad = function () {
        console.log('ionViewDidLoad OrderDetailPage');
    };
    OrderDetailPage = __decorate([
        IonicPage(),
        Component({
            selector: 'page-order-detail',
            templateUrl: 'order-detail.html',
        }),
        __metadata("design:paramtypes", [NavController, NavParams])
    ], OrderDetailPage);
    return OrderDetailPage;
}());
Пример #6
0
        this.tabToShow = [true, true, true, true, true, true, true, true, true];
        this.scrollableTabsopts = {};
        this.obj_CategorysListData = [];
        this.obj_GoodsListData = [];
        this.tabsPlacement = "top";
        this.Image_head_Url = Constants_1.GOODLIST_head_URL;
    }
    TabBroadcastPage.prototype.ionViewDidLoad = function () {
        var _this = this;
        this.lookservice.getAllcategory().subscribe(function (countries) { return _this.obj_CategorysListData = countries; }, function (error) { return _this.errorMessage = error; }, function complete() {
        });
        this.lookservice.getGoodsList().subscribe(function (countries) { return _this.obj_GoodsListData = countries; }, function (error) { return _this.errorMessage = error; }, function complete() {
        });
    };
    TabBroadcastPage.prototype.selectedFriends = function (index) {
        console.log("Segment changed to", index);
    };
    return TabBroadcastPage;
}());
__decorate([
    core_1.ViewChild('mySlider')
], TabBroadcastPage.prototype, "slider", void 0);
TabBroadcastPage = __decorate([
    ionic_angular_1.IonicPage(),
    core_1.Component({
        selector: 'page-tab-broadcast-page',
        templateUrl: 'tab-look-page.html',
    })
], TabBroadcastPage);
exports.TabBroadcastPage = TabBroadcastPage;
Пример #7
0
var BuyerDriverListPage = /** @class */ (function () {
    function BuyerDriverListPage(modalCtrl, db, fireAuth, viewCtrl, navCtrl, navParams) {
        var _this = this;
        this.modalCtrl = modalCtrl;
        this.db = db;
        this.fireAuth = fireAuth;
        this.viewCtrl = viewCtrl;
        this.navCtrl = navCtrl;
        this.navParams = navParams;
        this.driversArray = [];
        this.driversBackup = [];
        this.driversRef = db.list('users/', function (ref) { return ref.orderByChild('userType').equalTo('d'); });
        this.shopLat = navParams.data.shopLat;
        this.shopLong = navParams.data.shopLong;
        this.userLat = navParams.data.lat;
        this.userLng = navParams.data.long;
        this.driversRef.snapshotChanges().pipe(map(function (changes) {
            return changes.map(function (c) { return (__assign({ key: c.payload.key }, c.payload.val(), { distance: _this.getDistance(c.payload.val()), price: _this.getPrice(c.payload.val()) })); });
        })).subscribe(function (datas) {
            datas.forEach(function (data) {
                console.log(data);
                if (data.driverStatus == "Available") {
                    _this.driversArray.push(data);
                    _this.driversBackup.push(data);
                }
            });
        });
        this.drivers = Observable.of(this.driversArray.sort(this.compare));
        console.log(this.drivers);
        console.log(this.driversArray);
    }
    BuyerDriverListPage.prototype.ionViewDidLoad = function () {
        console.log('ionViewDidLoad BuyerDriverListPage');
    };
    BuyerDriverListPage.prototype.initializeDrivers = function () {
        this.driversArray = this.driversBackup;
    };
    BuyerDriverListPage.prototype.checkDetails = function (dID, lat, long) {
        var _this = this;
        this.driverModal = this.modalCtrl.create(BuyerDriverInfoPage, { driverID: dID, userLat: this.userLat, userLng: this.userLng, driverLat: lat, driverLng: long, shopLat: this.shopLat, shopLong: this.shopLong });
        this.driverModal.present();
        this.driverModal.onDidDismiss(function (driver) {
            if (driver != null) {
                console.log(driver);
                _this.viewCtrl.dismiss(driver);
            }
        });
    };
    BuyerDriverListPage.prototype.searchDrivers = function (searchbar) {
        // Reset items back to all of the items
        this.initializeDrivers();
        // set q to the value of the searchbar
        var q = searchbar.srcElement.value;
        // if the value is an empty string don't filter the items
        if (!q) {
            this.drivers = Observable.of(this.driversArray);
            return;
        }
        this.driversArray = this.driversArray.filter(function (v) {
            if (v.name && q) {
                if (v.name.toLowerCase().indexOf(q.toLowerCase()) > -1) {
                    return true;
                }
                return false;
            }
        });
        this.drivers = Observable.of(this.driversArray);
        console.log(q, this.driversArray.length);
    };
    BuyerDriverListPage.prototype.getPrice = function (distance) {
        return 50 * this.getDistance(distance);
    };
    BuyerDriverListPage.prototype.getDistance = function (location) {
        var lat1 = this.userLat;
        var lon1 = this.userLng;
        var lat2 = location.lat;
        var lon2 = location.long;
        console.log(location);
        var R = 6371; // Radius of the earth in km
        var dLat = this.deg2rad(lat2 - lat1); // deg2rad below
        var dLon = this.deg2rad(lon2 - lon1);
        var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
            Math.cos(this.deg2rad(lat1)) * Math.cos(this.deg2rad(lat2)) *
                Math.sin(dLon / 2) * Math.sin(dLon / 2);
        var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
        var d = R * c; // Distance in km
        console.log(d);
        return d;
    };
    BuyerDriverListPage.prototype.deg2rad = function (deg) {
        return deg * (Math.PI / 180);
    };
    BuyerDriverListPage.prototype.compare = function (a, b) {
        if (a.distance < b.distance)
            return -1;
        if (a.distance > b.distance)
            return 1;
        return 0;
    };
    BuyerDriverListPage.prototype.close = function () {
        this.viewCtrl.dismiss();
    };
    BuyerDriverListPage = __decorate([
        IonicPage(),
        Component({
            selector: 'page-buyer-driver-list',
            templateUrl: 'buyer-driver-list.html',
        }),
        __metadata("design:paramtypes", [ModalController,
            AngularFireDatabase,
            AngularFireAuth,
            ViewController,
            NavController,
            NavParams])
    ], BuyerDriverListPage);
    return BuyerDriverListPage;
}());
Пример #8
0
var BuyerHomepagePage = /** @class */ (function () {
    function BuyerHomepagePage(db, fireAuth, navCtrl, navParams, menuCtrl, platform, loadingCtrl) {
        var _this = this;
        this.db = db;
        this.fireAuth = fireAuth;
        this.navCtrl = navCtrl;
        this.navParams = navParams;
        this.menuCtrl = menuCtrl;
        this.loadingCtrl = loadingCtrl;
        // For Segments
        this.segments = "availableProducts";
        this.isAndroid = false;
        this.productsArray = [];
        this.productsBackup = [];
        this.messageNotif = 0;
        this.basketNotif = 0;
        this.notif = 0;
        this.loadingStatus = true;
        // For Segments
        this.isAndroid = platform.is('android');
        this.productsRef = db.list('/products', function (ref) { return ref.orderByChild('status').equalTo('Available'); });
        this.productsRef.snapshotChanges().pipe(map(function (changes) {
            return changes.map(function (c) { return (__assign({ key: c.payload.key }, c.payload.val(), { rating: _this.ratings(c.payload.val()) })); });
        })).subscribe(function (datas) {
            datas.forEach(function (data) {
                var truth = 0;
                for (var i = 0; i < _this.productsArray.length; i++) {
                    if (_this.productsArray[i].key == data.key) {
                        _this.productsArray[i] = data;
                        _this.productsBackup[i] = data;
                        truth = 1;
                    }
                }
                if (truth == 0) {
                    _this.productsArray.push(data);
                    _this.productsBackup.push(data);
                }
            });
            _this.loadingStatus = false;
        });
        this.products = Observable.of(this.productsArray);
        console.log(this.productsArray);
        db.list('chats/', function (ref) { return ref.orderByChild('buyer').equalTo(_this.fireAuth.auth.currentUser.uid); }).valueChanges().subscribe(function (data) {
            _this.messageNotif = 0;
            data.forEach(function (message) {
                if (message.buyerUnseen == 1) {
                    _this.messageNotif += 1;
                }
            });
        });
        //Counts user's basket/Cart.
        db.list('users/' + fireAuth.auth.currentUser.uid + '/cart/').valueChanges().subscribe(function (data) {
            _this.basketNotif = 0;
            data.forEach(function (message) {
                _this.basketNotif += 1;
            });
        });
        // //Counts unread notifications
        // db.list('users/'+fireAuth.auth.currentUser.uid+'/notifications/').valueChanges().subscribe(data=>{
        // 	this.notif = 0;
        // 	data.forEach((notif: any) =>{
        // 		if(notif.notificationUnread == 1){
        // 			this.notif ++;
        // 		}
        // 	});
        // });
    }
    BuyerHomepagePage.prototype.ionViewDidLoad = function () {
        console.log('ionViewDidLoad BuyerHomepagePage');
    };
    // For Segments
    BuyerHomepagePage.prototype.ionViewWillEnter = function () {
        this.testing = "availableProducts";
    };
    BuyerHomepagePage.prototype.initializeProducts = function () {
        this.productsArray = this.productsBackup;
    };
    BuyerHomepagePage.prototype.ionViewDidEnter = function () {
        this.menuCtrl.enable(true, 'buyerMenu');
    };
    BuyerHomepagePage.prototype.menuToggle = function () {
        this.menuCtrl.open('buyerMenu');
    };
    BuyerHomepagePage.prototype.menuUnToggle = function () {
        this.menuCtrl.close('buyerMenu');
    };
    BuyerHomepagePage.prototype.goToOrders = function () {
        var _this = this;
        var loader = this.loadingCtrl.create({
            spinner: 'hide',
            content: "<img src='assets/icon/loader.gif'>",
            duration: 1000
        });
        loader.present();
        setTimeout(function () {
            _this.navCtrl.push(BuyerOrdersPage);
        }, 1000);
    };
    BuyerHomepagePage.prototype.goToNotifications = function () {
        var _this = this;
        var loader = this.loadingCtrl.create({
            spinner: 'hide',
            content: "<img src='assets/icon/loader.gif'>",
            duration: 1000
        });
        loader.present();
        setTimeout(function () {
            _this.navCtrl.push(BuyerNotificationsPage);
        }, 1000);
    };
    BuyerHomepagePage.prototype.goToMessagesList = function () {
        var _this = this;
        var loader = this.loadingCtrl.create({
            spinner: 'hide',
            content: "<img src='assets/icon/loader.gif'>",
            duration: 1000
        });
        loader.present();
        setTimeout(function () {
            _this.navCtrl.push(BuyerMessagesListPage);
        }, 1000);
    };
    BuyerHomepagePage.prototype.goToBasket = function () {
        var _this = this;
        var loader = this.loadingCtrl.create({
            spinner: 'hide',
            content: "<img src='assets/icon/loader.gif'>",
            duration: 1000
        });
        loader.present();
        setTimeout(function () {
            _this.navCtrl.push(BuyerBasketPage);
        }, 1000);
    };
    BuyerHomepagePage.prototype.goToSettings = function () {
        var _this = this;
        var loader = this.loadingCtrl.create({
            spinner: 'hide',
            content: "<img src='assets/icon/loader.gif'>",
            duration: 1000
        });
        loader.present();
        setTimeout(function () {
            _this.navCtrl.push(BuyerSettingsPage);
        }, 1000);
    };
    BuyerHomepagePage.prototype.goToHelp = function () {
        var _this = this;
        var loader = this.loadingCtrl.create({
            spinner: 'hide',
            content: "<img src='assets/icon/loader.gif'>",
            duration: 1000
        });
        loader.present();
        setTimeout(function () {
            _this.navCtrl.push(BuyerHelpPage);
        }, 1000);
    };
    BuyerHomepagePage.prototype.goToVouchers = function () {
        var _this = this;
        var loader = this.loadingCtrl.create({
            spinner: 'hide',
            content: "<img src='assets/icon/loader.gif'>",
            duration: 1000
        });
        loader.present();
        setTimeout(function () {
            _this.navCtrl.push(BuyerVouchersPage);
        }, 1000);
    };
    BuyerHomepagePage.prototype.goToSingleProduct = function (productID) {
        var _this = this;
        var loader = this.loadingCtrl.create({
            spinner: 'hide',
            content: "<img src='assets/icon/loader.gif'>",
            duration: 1000
        });
        loader.present();
        setTimeout(function () {
            _this.navCtrl.push(BuyerSingleProductPage, { pID: productID });
        }, 1000);
    };
    BuyerHomepagePage.prototype.goToMyOrders = function () {
        var _this = this;
        var loader = this.loadingCtrl.create({
            spinner: 'hide',
            content: "<img src='assets/icon/loader.gif'>",
            duration: 1000
        });
        loader.present();
        setTimeout(function () {
            _this.navCtrl.push(BuyerOrdersPage);
        }, 1000);
    };
    //Search stuffs
    BuyerHomepagePage.prototype.searchProducts = function (searchbar) {
        // Reset items back to all of the items
        this.initializeProducts();
        // set q to the value of the searchbar
        var q = searchbar.srcElement.value;
        // if the value is an empty string don't filter the items
        if (!q) {
            this.products = Observable.of(this.productsArray);
            return;
        }
        this.productsArray = this.productsArray.filter(function (v) {
            if (v.name && q) {
                if (v.name.toLowerCase().indexOf(q.toLowerCase()) > -1) {
                    return true;
                }
                return false;
            }
        });
        this.products = Observable.of(this.productsArray);
        console.log(q, this.productsArray.length);
    };
    BuyerHomepagePage.prototype.goToSearch = function () {
        this.navCtrl.push(BuyerSearchPage);
    };
    BuyerHomepagePage.prototype.ratings = function (ratings) {
        if (ratings.reviews) {
            console.log(ratings);
            var r1 = 0;
            var r2 = 0;
            var r3 = 0;
            var r4 = 0;
            var r5 = 0;
            var totalR = 0;
            for (var key in ratings.reviews) {
                console.log(key, ratings.reviews[key].rating);
                switch (ratings.reviews[key].rating) {
                    case 5:
                        r5++;
                        break;
                    case 4:
                        r4++;
                        break;
                    case 3:
                        r3++;
                        break;
                    case 2:
                        r2++;
                        break;
                    default:
                        r1++;
                        break;
                }
                totalR++;
            }
            console.log(r1, r2, r3, r4, r5, totalR);
            var a = ((1 * r1) + (2 * r2) + (3 * r3) + (4 * r4) + (5 * r5)) / totalR;
            console.log(a);
            return a;
        }
        else {
            return 0;
        }
    };
    BuyerHomepagePage = __decorate([
        IonicPage(),
        Component({
            selector: 'page-buyer-homepage',
            templateUrl: 'buyer-homepage.html',
        }),
        __metadata("design:paramtypes", [AngularFireDatabase,
            AngularFireAuth,
            NavController,
            NavParams,
            MenuController,
            Platform,
            LoadingController])
    ], BuyerHomepagePage);
    return BuyerHomepagePage;
}());
Пример #9
0
var BuyerAddAddressPage = /** @class */ (function () {
    function BuyerAddAddressPage(fireAuth, db, formBuilder, zone, maps, platform, geolocation, viewCtrl, navCtrl, navParams) {
        this.fireAuth = fireAuth;
        this.db = db;
        this.formBuilder = formBuilder;
        this.zone = zone;
        this.maps = maps;
        this.platform = platform;
        this.geolocation = geolocation;
        this.viewCtrl = viewCtrl;
        this.navCtrl = navCtrl;
        this.navParams = navParams;
        this.query = '';
        this.places = [];
        this.searchDisabled = true;
        this.saveDisabled = true;
        this.locationInfo = this.formBuilder.group({
            name: ['', Validators.required],
            contact: ['', Validators.required],
            long: ['', Validators.required],
            lat: ['', Validators.required],
            address: ['', Validators.required]
        });
    }
    BuyerAddAddressPage.prototype.ionViewDidLoad = function () {
        var _this = this;
        var mapLoaded = this.maps.init(this.mapElement.nativeElement, this.pleaseConnect.nativeElement).then(function () {
            _this.autocompleteService = new google.maps.places.AutocompleteService();
            _this.placesService = new google.maps.places.PlacesService(_this.maps.map);
            _this.searchDisabled = false;
        });
    };
    BuyerAddAddressPage.prototype.selectPlace = function (place) {
        var _this = this;
        this.places = [];
        var location = {
            lat: null,
            lng: null,
            name: place.description
        };
        this.placesService.getDetails({ placeId: place.place_id }, function (details) {
            _this.zone.run(function () {
                location.lat = details.geometry.location.lat();
                location.lng = details.geometry.location.lng();
                _this.saveDisabled = false;
                _this.maps.map.setCenter({ lat: location.lat, lng: location.lng });
                _this.longitude = location.lng;
                _this.latitude = location.lat;
                _this.location = location;
                _this.locationDetail = location.name;
            });
        });
    };
    BuyerAddAddressPage.prototype.searchPlace = function () {
        var _this = this;
        this.saveDisabled = true;
        if (this.query.length > 0 && !this.searchDisabled) {
            var config = {
                types: ['geocode'],
                input: this.query
            };
            this.autocompleteService.getPlacePredictions(config, function (predictions, status) {
                if (status == google.maps.places.PlacesServiceStatus.OK && predictions) {
                    _this.places = [];
                    predictions.forEach(function (prediction) {
                        _this.places.push(prediction);
                    });
                }
            });
        }
        else {
            this.places = [];
        }
    };
    BuyerAddAddressPage.prototype.save = function () {
        var _this = this;
        console.log(this.location);
        if (this.locationInfo.value.name != "" && this.locationInfo.value.contact != "" && this.longitude != null && this.latitude != null) {
            Promise.resolve(this.db.list('users/' + this.fireAuth.auth.currentUser.uid + '/addresses').push({
                address: this.locationDetail,
                long: this.longitude,
                lat: this.latitude,
                name: this.locationInfo.value.name,
                contact: this.locationInfo.value.contact
            }).then(function (success) {
                _this.viewCtrl.dismiss(_this.location);
            }, function (error) { alert(error); })).catch(function (error) {
                alert(error);
            });
        }
        else {
            alert("Please fill up all the informations needed and select your address.");
        }
    };
    BuyerAddAddressPage.prototype.close = function () {
        this.viewCtrl.dismiss();
    };
    __decorate([
        ViewChild('map'),
        __metadata("design:type", ElementRef)
    ], BuyerAddAddressPage.prototype, "mapElement", void 0);
    __decorate([
        ViewChild('pleaseConnect'),
        __metadata("design:type", ElementRef)
    ], BuyerAddAddressPage.prototype, "pleaseConnect", void 0);
    BuyerAddAddressPage = __decorate([
        IonicPage(),
        Component({
            selector: 'page-buyer-add-address',
            templateUrl: 'buyer-add-address.html',
        }),
        __metadata("design:paramtypes", [AngularFireAuth,
            AngularFireDatabase,
            FormBuilder,
            NgZone,
            GoogleMapsProvider,
            Platform,
            Geolocation,
            ViewController,
            NavController,
            NavParams])
    ], BuyerAddAddressPage);
    return BuyerAddAddressPage;
}());
Пример #10
0
var BuyerWalletPage = /** @class */ (function () {
    function BuyerWalletPage(db, formBuilder, fireAuth, ngZone, loadingCtrl, toastCtrl, appCtrl, payPal, navCtrl, navParams) {
        var _this = this;
        this.db = db;
        this.formBuilder = formBuilder;
        this.fireAuth = fireAuth;
        this.ngZone = ngZone;
        this.loadingCtrl = loadingCtrl;
        this.toastCtrl = toastCtrl;
        this.appCtrl = appCtrl;
        this.payPal = payPal;
        this.navCtrl = navCtrl;
        this.navParams = navParams;
        this.currentMoney = 0;
        this.transactionHistory = [];
        this.loadingStatus = true;
        this.loading = loadingCtrl.create({
            spinner: 'hide',
            content: "<img src='assets/icon/loader.gif'>",
        });
        this.loading.present();
        this.loadingStatus = true;
        this.user = db.object('users/' + fireAuth.auth.currentUser.uid).valueChanges();
        this.transactions = db.list('users/' + fireAuth.auth.currentUser.uid + "/transactions", function (ref) { return ref.orderByChild('timeCreated'); }).valueChanges();
        this.db.object("users/" + this.fireAuth.auth.currentUser.uid + "/transactions/0/").update({
            currentAmount: 0,
            key: this.fireAuth.auth.currentUser.uid,
            timeCreated: 0
        }).then(function (data) {
            // gets the transactions
            _this.transactions.subscribe(function (data) {
                _this.transactionHistory = [];
                console.log(data);
                data.forEach(function (transaction) {
                    _this.transactionHistory.push(transaction);
                });
                console.log(_this.transactionHistory);
                _this.currentMoney = _this.transactionHistory[_this.transactionHistory.length - 1].currentAmount;
                if (_this.loadingStatus == true) {
                    _this.loading.dismiss();
                    _this.loadingStatus = false;
                }
            });
        });
        this.formCtrl = this.formBuilder.group({
            quantity: [0, Validators.required],
        });
    }
    BuyerWalletPage.prototype.addMoney = function () {
        var _this = this;
        var payPalEnvironmentSandbox = 'AT305vLOagTklhmxCnE_6jYJsq0-5i4zY-47q2otpDJ0ynpLKYvMoMRT8LGlo8iD4WGvs5Y_3Xf1RIwo';
        var payPalEnvironmentProduction = '';
        var payment = new PayPalPayment(this.formCtrl.value.quantity, 'PHP', 'Ecrotion E-wallet', 'sale');
        var currencies = ['EUR', 'USD', 'PHP'];
        var payPalEnvironment = 'payPalEnvironmentSandbox';
        this.loading = this.loadingCtrl.create({
            spinner: 'hide',
            content: "<img src='assets/icon/loader.gif'>",
        });
        this.loading.present();
        this.loadingStatus = true;
        var update = {};
        var timeCreated = firebase.database.ServerValue.TIMESTAMP;
        var latestBlock = this.transactionHistory[this.transactionHistory.length - 1];
        var latestBlockHash = sha512.sha512(this.transactionHistory[this.transactionHistory.length - 1].toString());
        var description = "Added " + this.formCtrl.value.quantity + " to your account.";
        var key = sha512.sha512(this.formCtrl.value.quantity + description + latestBlockHash + timeCreated);
        this.payPal.init({
            PayPalEnvironmentProduction: "Config.payPalEnvironmentProduction",
            PayPalEnvironmentSandbox: "AT305vLOagTklhmxCnE_6jYJsq0-5i4zY-47q2otpDJ0ynpLKYvMoMRT8LGlo8iD4WGvs5Y_3Xf1RIwo"
        }).then(function () {
            _this.payPal.prepareToRender(payPalEnvironment, new PayPalConfiguration({})).then(function () {
                _this.payPal.renderSinglePaymentUI(payment).then(function (response) {
                    alert("Successfuly added " + _this.formCtrl.value.quantity + " php to your E-wallet");
                    _this.db.list('users/' + _this.fireAuth.auth.currentUser.uid + '/transactions/').push({
                        currentAmount: parseInt(_this.formCtrl.value.quantity) + parseInt(_this.transactionHistory[_this.transactionHistory.length - 1].currentAmount),
                        description: description,
                        key: key,
                        timeCreated: timeCreated,
                        previousKey: latestBlockHash
                    });
                    console.log(response);
                }, function () {
                    console.error('Error or render dialog closed without being successful');
                    _this.loading.dismiss();
                    _this.loadingStatus = false;
                });
            }, function () {
                console.error('Error in configuration');
                _this.loading.dismiss();
                _this.loadingStatus = false;
            });
        }, function () {
            console.error('Error in initialization, maybe PayPal isn\'t supported or something else');
            _this.loading.dismiss();
            _this.loadingStatus = false;
        });
    };
    BuyerWalletPage.prototype.ionViewDidLoad = function () {
        console.log('ionViewDidLoad BuyerWalletPage');
    };
    BuyerWalletPage.prototype.ngOnDestroy = function () {
        if (this.loadingStatus) {
            this.loading.dismiss();
        }
    };
    BuyerWalletPage = __decorate([
        IonicPage(),
        Component({
            selector: 'page-buyer-wallet',
            templateUrl: 'buyer-wallet.html',
        }),
        __metadata("design:paramtypes", [AngularFireDatabase,
            FormBuilder,
            AngularFireAuth,
            NgZone,
            LoadingController,
            ToastController,
            App,
            PayPal,
            NavController,
            NavParams])
    ], BuyerWalletPage);
    return BuyerWalletPage;
}());
Пример #11
0
var BuyerDriverInfoPage = /** @class */ (function () {
    function BuyerDriverInfoPage(viewCtrl, zone, fireAuth, db, loadingCtrl, navCtrl, navParams) {
        this.viewCtrl = viewCtrl;
        this.zone = zone;
        this.fireAuth = fireAuth;
        this.db = db;
        this.loadingCtrl = loadingCtrl;
        this.navCtrl = navCtrl;
        this.navParams = navParams;
        this.start = 'chicago, il';
        this.end = 'chicago, il';
        this.directionsService = new google.maps.DirectionsService;
        this.directionsDisplay = new google.maps.DirectionsRenderer;
        this.driverLatLng = {
            lat: 0,
            lng: 0,
        };
        this.totalDistance = 0;
        this.totalPrice = 0;
        this.totalTime = 0;
        this.loadingStatus = loadingCtrl.create({
            spinner: 'hide',
            content: "<img src='assets/icon/loader.gif'>"
        });
        this.loadingStatus.present();
        this.shopLat = navParams.data.shopLat;
        this.shopLong = navParams.data.shopLong;
        this.driverID = navParams.data.driverID;
        this.userLat = navParams.data.userLat;
        this.userLng = navParams.data.userLng;
        this.driver = db.object('users/' + this.driverID).valueChanges();
        this.driverLat = navParams.data.driverLat;
        this.driverLng = navParams.data.driverLng;
        // this.driverLatLng.lat= 120.5953;
        // this.driverLatLng.lng = 16.403585;
        console.log("Lng: " + this.driverLng, "Lat : " + this.driverLat, "Oi " + this.userLat, "Pre " + this.userLng);
        console.log(new google.maps.LatLng(this.driverLat, this.driverLng));
    }
    BuyerDriverInfoPage.prototype.ionViewDidLoad = function () {
        console.log('ionViewDidLoad BuyerDriverInfoPage');
        this.initMap();
    };
    BuyerDriverInfoPage.prototype.initMap = function () {
        this.map = new google.maps.Map(this.mapElement.nativeElement, {
            zoom: 7,
            center: { lat: 120.5953, lng: 16.403585 }
        });
        this.directionsDisplay.setMap(this.map);
        this.calculateAndDisplayRoute();
    };
    BuyerDriverInfoPage.prototype.calculateAndDisplayRoute = function () {
        var _this = this;
        var items = ["Benguet"];
        var waypoints = [];
        for (var i = 0; i < items.length; i++) {
            var address = items[i];
            if (address !== "") {
                waypoints.push({
                    location: address,
                    stopover: true
                });
            }
        }
        this.directionsService.route({
            origin: { lat: this.driverLat, lng: this.driverLng },
            destination: { lat: this.userLat, lng: this.userLng },
            waypoints: waypoints,
            optimizeWaypoints: true,
            travelMode: google.maps.TravelMode['DRIVING']
        }, function (response, status) {
            if (status === google.maps.DirectionsStatus.OK) {
                _this.directionsDisplay.setDirections(response);
                var route = response.routes[0];
                //  alert(route.legs[1].duration.text);
                // For each route, display summary information.
                for (var i = 0; i < route.legs.length; i++) {
                    var routeSegment = i + 1;
                    console.log(routeSegment);
                    console.log(route.legs[i].start_location);
                    console.log(route.legs[i].end_location);
                    console.log(route.legs[i].duration);
                    _this.totalDistance += route.legs[i].distance.value;
                    _this.totalTime += route.legs[i].duration.value;
                }
                _this.calculatePrice();
            }
            else {
                window.alert('Directions request failed due to ' + status);
            }
        });
    };
    BuyerDriverInfoPage.prototype.calculatePrice = function () {
        var _this = this;
        this.zone.run(function () {
            _this.totalDistance = Math.round(_this.totalDistance / 1000);
            _this.totalTime = Math.round(_this.totalTime / 60 / 60);
            _this.totalPrice = Math.round((_this.totalDistance) * 20);
        });
        console.log(this.totalPrice);
        this.loadingStatus.dismiss();
    };
    BuyerDriverInfoPage.prototype.latLangUser = function (user) {
        this.userLat = user.lat;
        this.userLng = user.lang;
        console.log(this.userLat);
        return true;
    };
    BuyerDriverInfoPage.prototype.latLangDriver = function (driver) {
        console.log("eto" + driver);
        return true;
    };
    BuyerDriverInfoPage.prototype.converToString = function (toConvert) {
        console.log(toConvert);
        return toConvert.toString().replace(",", ".");
    };
    BuyerDriverInfoPage.prototype.choose = function () {
        this.viewCtrl.dismiss({ driverID: this.driverID, totalPrice: this.totalPrice });
    };
    BuyerDriverInfoPage.prototype.close = function () {
        this.viewCtrl.dismiss();
    };
    __decorate([
        ViewChild('map'),
        __metadata("design:type", ElementRef)
    ], BuyerDriverInfoPage.prototype, "mapElement", void 0);
    BuyerDriverInfoPage = __decorate([
        IonicPage(),
        Component({
            selector: 'page-buyer-driver-info',
            templateUrl: 'buyer-driver-info.html',
        }),
        __metadata("design:paramtypes", [ViewController,
            NgZone,
            AngularFireAuth,
            AngularFireDatabase,
            LoadingController,
            NavController,
            NavParams])
    ], BuyerDriverInfoPage);
    return BuyerDriverInfoPage;
}());
Пример #12
0
var BuyerCheckoutPage = /** @class */ (function () {
    function BuyerCheckoutPage(formCtrl, ngZone, navCtrl, navParams, loadingCtrl, db, fireAuth, modalCtrl) {
        var _this = this;
        this.formCtrl = formCtrl;
        this.ngZone = ngZone;
        this.navCtrl = navCtrl;
        this.navParams = navParams;
        this.loadingCtrl = loadingCtrl;
        this.db = db;
        this.fireAuth = fireAuth;
        this.modalCtrl = modalCtrl;
        this.objectfier = Object.keys;
        this.address = null;
        this.shops = [];
        this.totalPrice = 0.00;
        this.toCheckOut = [];
        this.itemsToBePayed = [];
        this.total = 0;
        this.drivers = [];
        this.totalProductPrice = 0;
        this.shippingFee = 0;
        this.productsToBePayed = {};
        this.productsToBePayedArray = [];
        this.shippingStatus = false;
        this.shopsChecker = [];
        this.productPrice = {};
        this.transactionHistory = [];
        this.currentMoney = 0;
        this.loadingStatus = true;
        this.loading = loadingCtrl.create({
            spinner: 'hide',
            content: "<img src='assets/icon/loader.gif'>",
        });
        this.loading.present();
        this.currentUser = db.object('users/' + fireAuth.auth.currentUser.uid).valueChanges();
        this.itemsToBePayed = navParams.data.items;
        this.total += this.totalProductPrice = navParams.data.totalPrice;
        // this.address = db.object('users/'+fireAuth.auth.currentUser.uid+'/addresses/-LX5BV3b3Q_q3R_M2JSi').valueChanges();
        this.cartsRef = db.list('users/' + fireAuth.auth.currentUser.uid + '/cart/', function (ref) { return ref.orderByChild('shopID'); });
        this.products = this.cartsRef.snapshotChanges().pipe(map(function (oi) {
            return oi.map(function (c) { return (__assign({ key: c.payload.key }, c.payload.val(), { productItem: _this.productDescription(c.payload.key) })); });
        }));
        this.cartsRef.snapshotChanges().pipe(map(function (oi) {
            return oi.map(function (c) { return (__assign({ key: c.payload.key }, c.payload.val(), { productItem: _this.productDescription(c.payload.key) })); });
        })).subscribe(function (x) {
            var shopName;
            _this.shops = [];
            x.forEach(function (element) {
                _this.itemsToBePayed.forEach(function (itemID) {
                    console.log(element.key + "ID");
                    shopName = _this.shopName(element.shopID);
                    if (element.key == itemID) {
                        _this.productsToBePayedArray.push(element);
                        // this.total += parseInt(element.price);
                        if (!_this.shops[element.shopID]) {
                            _this.shops[element.shopID] = true;
                            _this.shops.push(shopName);
                            _this.shopsChecker.push(element.shopID);
                        }
                    }
                });
            });
            _this.observableShops = Observable.of(_this.shops);
        });
        db.object('users/' + fireAuth.auth.currentUser.uid + '/transactions/0/').update({
            currentAmount: 0,
            key: this.fireAuth.auth.currentUser.uid,
            timeCreated: 0
        }).then(function (data) {
            _this.transactions = db.list('users/' + fireAuth.auth.currentUser.uid + "/transactions", function (ref) { return ref.orderByChild('timeCreated'); }).valueChanges();
            _this.transactions.subscribe(function (data) {
                _this.transactionHistory = [];
                console.log(data);
                data.forEach(function (transaction) {
                    _this.transactionHistory.push(transaction);
                });
                console.log(_this.transactionHistory);
                _this.currentMoney = _this.transactionHistory[_this.transactionHistory.length - 1].currentAmount;
                if (_this.loadingStatus) {
                    _this.loading.dismiss();
                    _this.loadingStatus = false;
                }
            });
        });
        console.log(this.shops);
        //
    }
    BuyerCheckoutPage.prototype.ionViewDidLoad = function () {
        console.log('ionViewDidLoad BuyerCheckoutPage');
    };
    BuyerCheckoutPage.prototype.shopName = function (shopID) {
        return this.db.object('users/' + shopID + '/').snapshotChanges().pipe(map(function (changes) {
            return (__assign({ key: changes.payload.key }, changes.payload.val()));
        }));
    };
    BuyerCheckoutPage.prototype.productDescription = function (productID) {
        var _this = this;
        var product = this.db.object('products/' + productID + '/');
        product.valueChanges().subscribe(function (data) {
            _this.productPrice[productID] = data.price;
        });
        return product.valueChanges();
    };
    BuyerCheckoutPage.prototype.goToPaymentMethod = function () {
        var _this = this;
        var loader = this.loadingCtrl.create({
            spinner: 'hide',
            content: "<img src='../assets/icon/loader.gif'>",
            duration: 1000
        });
        loader.present();
        setTimeout(function () {
            _this.navCtrl.push(BuyerPaymentMethodPage);
        }, 1000);
    };
    BuyerCheckoutPage.prototype.goToShippingAddress = function () {
        var _this = this;
        var loader = this.loadingCtrl.create({
            spinner: 'hide',
            content: "<img src='../assets/icon/loader.gif'>",
            duration: 1000
        });
        loader.present();
        setTimeout(function () {
            _this.navCtrl.push(BuyerShippingAddressPage);
        }, 1000);
    };
    BuyerCheckoutPage.prototype.goToBillingAddress = function () {
        var _this = this;
        var loader = this.loadingCtrl.create({
            spinner: 'hide',
            content: "<img src='assets/icon/loader.gif'>",
            duration: 1000
        });
        loader.present();
        setTimeout(function () {
            _this.navCtrl.push(BuyerBillingAddressPage);
        }, 1000);
    };
    BuyerCheckoutPage.prototype.chooseDriver = function (shopID, shopLat, shopLong) {
        var _this = this;
        this.driver = this.modalCtrl.create(BuyerDriverListPage, {
            long: this.address.long,
            lat: this.address.lat,
            shopLat: shopLat,
            shopLong: shopLong
        });
        console.log(shopLat, shopLong);
        this.driver.present();
        this.driver.onDidDismiss(function (driver) {
            if (driver) {
                _this.driverInfo = driver;
                console.log(driver);
                _this.ngZone.run(function () {
                    _this.total += driver.totalPrice;
                    _this.shippingFee += driver.totalPrice;
                    _this.drivers[shopID] = ({ key: driver.driverID, details: _this.db.object('/users/' + driver.driverID).valueChanges(), price: driver.totalPrice });
                });
            }
        });
        console.log(this.driverInfo);
    };
    BuyerCheckoutPage.prototype.selectAddress = function () {
        var _this = this;
        this.addressModal = this.modalCtrl.create(BuyerChooseAddressPage);
        this.addressModal.present();
        this.addressModal.onDidDismiss(function (address) {
            if (address) {
                console.log(address);
                _this.ngZone.run(function () {
                    _this.address = address;
                });
            }
        });
    };
    BuyerCheckoutPage.prototype.payOut = function () {
        var _this = this;
        if (this.total <= this.currentMoney) {
            var checker_1 = false;
            var orderKey_1 = this.db.createPushId();
            var keys_1 = {};
            var productLists = {};
            console.log(this.shops);
            this.shopsChecker.forEach(function (data) {
                console.log(data);
                console.log(_this.drivers);
                if (_this.drivers[data] != null) {
                    checker_1 = true;
                }
                keys_1[data] = { key: _this.db.createPushId() };
            });
            if (this.address != null && checker_1) {
                var products = {};
                this.productsToBePayedArray.forEach(function (item) {
                    _this.productsToBePayed["users/" + _this.drivers[item.shopID].key + "/driverStatus"] = "Taken";
                    _this.productsToBePayed['/orderReceipts/' + orderKey_1] = {
                        orederedOn: firebase.database.ServerValue.TIMESTAMP,
                        orderedBy: _this.fireAuth.auth.currentUser.uid
                    };
                    _this.productsToBePayed['/orderBundles/' + keys_1[item.shopID].key] = {
                        driver: _this.drivers[item.shopID].key,
                        driverStatus: "Pending",
                        products: _this.getProducts(item.shopID),
                        orderedBy: _this.fireAuth.auth.currentUser.uid,
                        driverPrice: _this.drivers[item.shopID].price,
                        orderReceipt: orderKey_1,
                        shopID: item.shopID,
                        readyToPickUp: 0,
                        orderedOn: firebase.database.ServerValue.TIMESTAMP,
                        status: "Pending",
                        total: _this.getTotal(item.shopID),
                        address: _this.address
                    };
                    _this.productsToBePayed['/users/' + _this.fireAuth.auth.currentUser.uid + "/cart/" + item.key] = null;
                });
                this.db.object('/').update(this.productsToBePayed).then(function (data) {
                    _this.navCtrl.push(BuyerOrdersPage, { checkOutSuccess: "Success" }).then(function (data) {
                        _this.navCtrl.remove(_this.navCtrl.length() - 2);
                    });
                    ;
                });
                // deduct money from user
                this.loading = this.loadingCtrl.create({
                    spinner: 'hide',
                    content: "<img src='assets/icon/loader.gif'>",
                });
                this.loading.present();
                this.loadingStatus = true;
                var update = {};
                var timeCreated = firebase.database.ServerValue.TIMESTAMP;
                var latestBlock = this.transactionHistory[this.transactionHistory.length - 1];
                var latestBlockHash = sha512.sha512(this.transactionHistory[this.transactionHistory.length - 1].toString());
                var description = "Deducted " + this.total + " to your account to pay your order.";
                var key = sha512.sha512(this.total + description + latestBlockHash + timeCreated);
                this.db.list('users/' + this.fireAuth.auth.currentUser.uid + '/transactions/').push({
                    currentAmount: parseInt(this.transactionHistory[this.transactionHistory.length - 1].currentAmount) - this.total,
                    description: description,
                    key: key,
                    timeCreated: timeCreated,
                    previousKey: latestBlockHash
                });
            }
            else {
                alert("Please select a delivery method!");
            }
        }
        else {
            alert("You do not have enough money, make sure you have enough balance in your E-Wallet.");
        }
    };
    BuyerCheckoutPage.prototype.getProducts = function (shopID) {
        var productReturn = {};
        this.productsToBePayedArray.forEach(function (item) {
            if (item.shopID == shopID) {
                productReturn[item.key] = {
                    productID: item.key,
                    quantity: item.quantity,
                    status: "pending",
                    shopID: item.shopID
                };
            }
        });
        return productReturn;
    };
    BuyerCheckoutPage.prototype.getTotal = function (shopID) {
        var _this = this;
        var total = 0;
        this.productsToBePayedArray.forEach(function (item) {
            console.log(item);
            if (item.shopID == shopID) {
                total += (item.quantity * _this.productPrice[item.key]);
            }
        });
        return total;
    };
    BuyerCheckoutPage.prototype.goToWallet = function () {
        this.navCtrl.push(BuyerWalletPage);
    };
    BuyerCheckoutPage = __decorate([
        IonicPage(),
        Component({
            selector: 'page-buyer-checkout',
            templateUrl: 'buyer-checkout.html',
        }),
        __metadata("design:paramtypes", [FormBuilder,
            NgZone,
            NavController,
            NavParams,
            LoadingController,
            AngularFireDatabase,
            AngularFireAuth,
            ModalController])
    ], BuyerCheckoutPage);
    return BuyerCheckoutPage;
}());
var BuyerSingleProductPage = /** @class */ (function () {
    function BuyerSingleProductPage(loadingCtrl, platform, formBuilder, fireAuth, db, navCtrl, navParams, menuCtrl, toastCtrl) {
        var _this = this;
        this.loadingCtrl = loadingCtrl;
        this.platform = platform;
        this.formBuilder = formBuilder;
        this.fireAuth = fireAuth;
        this.db = db;
        this.navCtrl = navCtrl;
        this.navParams = navParams;
        this.menuCtrl = menuCtrl;
        this.toastCtrl = toastCtrl;
        // For Segments
        this.segments = "reviewsandratings";
        this.isAndroid = false;
        // For Segments
        this.loading = loadingCtrl.create({
            spinner: 'hide',
            content: "<img src='assets/icon/loader.gif'>",
        });
        this.loading.present();
        this.isAndroid = platform.is('android');
        this.userID = fireAuth.auth.currentUser.uid;
        this.productID = this.navParams.data.pID;
        this.productRef = db.object('/products/' + this.productID);
        this.product = this.productRef.valueChanges();
        var a = this.product.subscribe(function (data) {
            _this.loading.dismiss();
            a.unsubscribe();
        });
        this.reviews = db.list('/products/' + this.productID + "/reviews/").snapshotChanges().pipe(map(function (oi) {
            return oi.map(function (c) { return (__assign({ key: c.payload.key }, c.payload.val(), { buyer: _this.buyerDescription(c.payload.val()) })); });
        }));
        this.formCtrl = this.formBuilder.group({
            quantity: ['0', Validators.required],
        });
    }
    BuyerSingleProductPage.prototype.ionViewDidLoad = function () {
        console.log('ionViewDidLoad BuyerSingleProductPage');
    };
    // For Segments
    BuyerSingleProductPage.prototype.ionViewWillEnter = function () {
        this.testing = "reviewsandratings";
    };
    BuyerSingleProductPage.prototype.buyerDescription = function (comment) {
        return this.db.object('users/' + comment.buyerID).valueChanges();
    };
    BuyerSingleProductPage.prototype.addToCart = function () {
        var _this = this;
        if (this.formCtrl.value.quantity < 200) {
            alert("You must atleast order 200 kg. and above.");
            return;
        }
        var loader = this.loadingCtrl.create({
            content: ""
        });
        loader.present();
        this.productToCart = this.db.object('products/' + this.productID).valueChanges();
        var a = this.productToCart.subscribe(function (productDetails) {
            _this.db.object('users/' + _this.userID + '/cart/' + _this.productID + '/').update({
                shopID: productDetails.owner
            }).then(function (data) {
                if (_this.addProduct()) {
                    var toast = _this.toastCtrl.create({
                        message: 'Product was successfully added.',
                        position: 'bottom',
                        dismissOnPageChange: true,
                        showCloseButton: true,
                        closeButtonText: 'Go to Cart',
                        duration: 5000
                    });
                    toast.onDidDismiss(function (data, role) {
                        console.log('Dismissed toast');
                        if (role == "close") {
                            _this.navCtrl.push(BuyerBasketPage);
                        }
                    });
                    loader.dismiss();
                    toast.present();
                    a.unsubscribe();
                }
            }).catch(function (error) {
                alert(error);
                loader.dismiss();
            });
        });
    };
    BuyerSingleProductPage.prototype.addProduct = function () {
        var _this = this;
        return this.db.object('users/' + this.userID + '/cart/' + this.productID + '/quantity/').query.ref.transaction(function (quantity) {
            if (quantity === null) {
                return quantity = parseInt(_this.formCtrl.value.quantity);
            }
            else {
                return quantity + parseInt(_this.formCtrl.value.quantity);
            }
        });
    };
    BuyerSingleProductPage.prototype.messageOwner = function (oID) {
        this.navCtrl.push(BuyerMessagesPage, { ownerID: oID });
    };
    BuyerSingleProductPage = __decorate([
        IonicPage(),
        Component({
            selector: 'page-buyer-single-product',
            templateUrl: 'buyer-single-product.html',
        }),
        __metadata("design:paramtypes", [LoadingController,
            Platform,
            FormBuilder,
            AngularFireAuth,
            AngularFireDatabase,
            NavController,
            NavParams,
            MenuController,
            ToastController])
    ], BuyerSingleProductPage);
    return BuyerSingleProductPage;
}());
Пример #14
0
var BuyerProfilePage = /** @class */ (function () {
    function BuyerProfilePage(db, formBuilder, fireAuth, ngZone, loadingCtrl, appCtrl, payPal, navCtrl, navParams) {
        this.db = db;
        this.formBuilder = formBuilder;
        this.fireAuth = fireAuth;
        this.ngZone = ngZone;
        this.loadingCtrl = loadingCtrl;
        this.appCtrl = appCtrl;
        this.payPal = payPal;
        this.navCtrl = navCtrl;
        this.navParams = navParams;
        this.static = true;
        this.user = db.object('users/' + fireAuth.auth.currentUser.uid).valueChanges();
        this.formCtrl = this.formBuilder.group({
            quantity: ['0', Validators.required],
        });
    }
    BuyerProfilePage.prototype.ionViewDidLoad = function () {
        console.log('ionViewDidLoad BuyerProfilePage');
    };
    BuyerProfilePage.prototype.addMoney = function () {
        var _this = this;
        this.payPal.init({
            PayPalEnvironmentProduction: 'YOUR_PRODUCTION_CLIENT_ID',
            PayPalEnvironmentSandbox: 'AT305vLOagTklhmxCnE_6jYJsq0-5i4zY-47q2otpDJ0ynpLKYvMoMRT8LGlo8iD4WGvs5Y_3Xf1RIwo'
        }).then(function () {
            // Environments: PayPalEnvironmentNoNetwork, PayPalEnvironmentSandbox, PayPalEnvironmentProduction
            _this.payPal.prepareToRender('PayPalEnvironmentSandbox', new PayPalConfiguration({
            // Only needed if you get an "Internal Service Error" after PayPal login!
            //payPalShippingAddressOption: 2 // PayPalShippingAddressOptionPayPal
            })).then(function () {
                var payment = new PayPalPayment('3.33', 'USD', 'Description', 'sale');
                _this.payPal.renderSinglePaymentUI(payment).then(function () {
                    // Successfully paid
                    alert('Success');
                    // Example sandbox response
                    //
                    // {
                    //   "client": {
                    //     "environment": "sandbox",
                    //     "product_name": "PayPal iOS SDK",
                    //     "paypal_sdk_version": "2.16.0",
                    //     "platform": "iOS"
                    //   },
                    //   "response_type": "payment",
                    //   "response": {
                    //     "id": "PAY-1AB23456CD789012EF34GHIJ",
                    //     "state": "approved",
                    //     "create_time": "2016-10-03T13:33:33Z",
                    //     "intent": "sale"
                    //   }
                    // }
                }, function () {
                    alert("yeah");
                    // Error or render dialog closed without being successful
                });
            }, function () {
                alert("something");
                // Error in configuration
            });
        }, function () {
            alert("Kelangan naka real mobile");
            // Error in initialization, maybe PayPal isn't supported or something else
        });
    };
    BuyerProfilePage = __decorate([
        IonicPage(),
        Component({
            selector: 'page-buyer-profile',
            templateUrl: 'buyer-profile.html',
        }),
        __metadata("design:paramtypes", [AngularFireDatabase,
            FormBuilder,
            AngularFireAuth,
            NgZone,
            LoadingController,
            App,
            PayPal,
            NavController,
            NavParams])
    ], BuyerProfilePage);
    return BuyerProfilePage;
}());