Config.xml angepasst, Kaufabwicklung funktioniert jetzt reibungslos

This commit is contained in:
2016-02-02 16:11:18 +01:00
parent 89e8dde72c
commit 5e25c4ca61
1219 changed files with 92546 additions and 2746 deletions

View File

@@ -59,28 +59,46 @@ angular.module('starter', ['ionic', 'ngCordova', 'starter.controllers', 'starter
}
function successHandler (result) {
/*
/*
* Google-Stroe Initialisieren START
*/
function StoreInitsuccessHandler (result) {
$rootScope.storeinit=1;
inappbilling.getPurchases(purchasessuccess, purchasesfail)
}
function StoreIniterrorHandler (error) {
$rootScope.storeinit=0;
}
if((window.device && device.platform == "Android") && typeof inappbilling !== "undefined") {
inappbilling.init(StoreInitsuccessHandler, StoreIniterrorHandler, {showLog:true});
}
function purchasessuccess (result) {
var strResult = "";
if(typeof result === 'object') {
strResult = JSON.stringify(result);
} else {
strResult = result;
}
alert("SUCCESS: \r\n"+strResult );
*/
$rootScope.storeinit=1;
}
function errorHandler (error) {
//alert("ERROR: \r\n"+error );
$rootScope.storeinit=0;
function purchasesfail (error) {
alert("ERROR: \r\n"+error );
}
/*
* Google-Stroe Initialisieren ENDE
*/
if((window.device && device.platform == "Android") && typeof inappbilling !== "undefined") {
inappbilling.init(successHandler, errorHandler, {showLog:true});
}
// Initialize database through $database service
db = $database.initDB();
@@ -121,6 +139,7 @@ angular.module('starter', ['ionic', 'ngCordova', 'starter.controllers', 'starter
}
})
.state('tab.buys', {
url: '/buys',
views: {

View File

@@ -1,6 +1,6 @@
angular.module('starter.controllers', [])
.controller('DashCtrl', function($scope,$ionicPopup,$http, $database, $timeout,$rootScope, $cordovaFileTransfer,$cordovaFile) {
.controller('DashCtrl', function($scope,$ionicPopup,$http, $database, $timeout,$rootScope, $cordovaFileTransfer,$cordovaFile,$ionicLoading,$state) {
$scope.preis="";
$scope.name="";
@@ -8,6 +8,47 @@ angular.module('starter.controllers', [])
$scope.items=[];
$scope.item=[];
$scope.producitems=[];
$scope.rosen1titel="";
$scope.rosen1preis="";
$scope.rosen1beschreibung="";
$scope.rosen1preiscurrency="";
$scope.rosen1preistag="";
$scope.rosen3titel="";
$scope.rosen3preis="";
$scope.rosen3beschreibung="";
$scope.rosen3preiscurrency="";
$scope.rosen3preistag="";
$scope.rosen9titel="";
$scope.rosen9preis="";
$scope.rosen9beschreibung="";
$scope.rosen9preiscurrency="";
$scope.rosen9preistag="";
$scope.flateraterosentitel="";
$scope.flateraterosenpreis="";
$scope.flateraterosenbeschreibung="";
$scope.flateraterosenpreiscurrency="";
$scope.flateraterosenpreistag="";
$scope.showrosen = false;
$scope.showflatrate = true;
$scope.show = function() {
$ionicLoading.show({
template: '<p>Kauf wird abgeschlossen.</p><ion-spinner></ion-spinner>'
});
};
$scope.hide = function(){
$ionicLoading.hide();
};
$scope.validate = function() {
@@ -22,38 +63,155 @@ angular.module('starter.controllers', [])
};
$scope.loaddata = function() {
$scope.items=[];
$database.getAllBuys().then(function (result) {
if(result.length>0){
alert("daten da");
for(i=0;i<result.length;i++){
$scope.items.push(result[i]);
alert(i);
}
} else {
$scope.items=[];
}
});
};
$scope.savedata = function() {
$scope.item={name: $scope.name, bild: "test"};
$scope.items.push($scope.item);
$database.setBuys($scope.name,"test");
};
function successBuyHandler (result) {
$timeout(consumesuccessHandler, 1000);
/*
* Produkt-Details abrufen START
*/
function getProducts(){
inappbilling.getProductDetails(successProducts, errorProducts,["rosenflatrate","9xrose","3xrose","1xrose"]);
}
function successConsumeHandler (result) {
function successProducts (result) {
//alert(JSON.stringify(result));
$scope.producitems = [
angular.fromJson(result[0]),
angular.fromJson(result[1]),
angular.fromJson(result[2]),
angular.fromJson(result[3])
];
$scope.producitems[0].title=$scope.producitems[0].title.replace("(Wolle Rosen kaufen)", "");
$scope.producitems[1].title=$scope.producitems[1].title.replace("(Wolle Rosen kaufen)", "");
$scope.producitems[2].title=$scope.producitems[2].title.replace("(Wolle Rosen kaufen)", "");
$scope.producitems[3].title=$scope.producitems[3].title.replace("(Wolle Rosen kaufen)", "");
$scope.rosen1titel=$scope.producitems[2].title;
$scope.rosen1preis=$scope.producitems[2].price;
$scope.rosen1beschreibung=$scope.producitems[2].description;
$scope.rosen1preiscurrency=$scope.producitems[2].price_currency_code;
$scope.rosen1preistag="Preis: " + $scope.rosen1preis + " " + $scope.rosen1preiscurrency + " (inkl. MwSt.)";
$scope.rosen3titel=$scope.producitems[1].title;
$scope.rosen3preis=$scope.producitems[1].price;
$scope.rosen3beschreibung=$scope.producitems[1].description;
$scope.rosen3preiscurrency=$scope.producitems[2].price_currency_code;
$scope.rosen3preistag="Preis: " + $scope.rosen3preis + " " + $scope.rosen3preiscurrency + " (inkl. MwSt.)";
$scope.rosen9titel=$scope.producitems[0].title;
$scope.rosen9preis=$scope.producitems[0].price;
$scope.rosen9beschreibung=$scope.producitems[0].description;
$scope.rosen9preiscurrency=$scope.producitems[2].price_currency_code;
$scope.rosen9preistag="Preis: " + $scope.rosen9preis + " " + $scope.rosen9preiscurrency + " (inkl. MwSt.)";
$scope.flateraterosentitel=$scope.producitems[3].title;
$scope.flateraterosenpreis=$scope.producitems[3].price;
$scope.flateraterosenbeschreibung=$scope.producitems[3].description;
$scope.flateraterosenpreiscurrency=$scope.producitems[2].price_currency_code;
$scope.flateraterosenpreistag="Preis: " + $scope.flateraterosenpreis + " " + $scope.flateraterosenpreiscurrency + " (inkl. MwSt.)";
$scope.showrosen = true;
$timeout(function(){
$scope.showrosen = true;
}, 500);
}
function errorProducts (result) {
var strResult = "";
if(typeof result === 'object') {
strResult = JSON.stringify(result);
} else {
strResult = result;
}
alert(strResult);
}
$timeout(getProducts, 1000);
/*
* Produkt-Details abrufen ENDE
*/
/*
* Rosen kaufen START
*/
$scope.buyRose = function() {
if((window.device && device.platform == "Android") && typeof inappbilling !== "undefined") {
if ($rootScope.storeinit==1){
inappbilling.buy(successBuyHandler, errorBuyHandler, $scope.preis);
}
else{
var alertPopup = $ionicPopup.alert({
title: 'Achtung',
template: 'Der Google-Store konnte nicht initialisiert werden.'
});
alertPopup.then(function(res) {
console.log('Store steht nicht zur Verfuegung');
});
}
}
}
function errorBuyHandler (error) {
var strResult = "";
var returnBool=false;
if(typeof error === 'object') {
strResult = JSON.stringify(error);
} else {
strResult = error;
}
/*
* Prüfen ob Kuf schonmal durchgeführt wurde, aber noch nicht konsumiert
*/
returnBool=strResult.indexOf("Item Already Owned") != -1;
if (returnBool==true){
//Rose wurde schon gekauft, jetzt konsumieren
$timeout(consumesuccessHandler, 500);
}
else{
//Ein anderer Fehler ist auf getreten Kauf wird abgebrochen
var alertPopup = $ionicPopup.alert({
title: 'Oh Nein',
template: 'Der Kauf konnte nicht durchgeführt werden.'
});
alertPopup.then(function(res) {
console.log('Der Kauf konnte nicht durchgeführt werden');
});
}
}
function successBuyHandler (result) {
$timeout(consumesuccessHandler, 500);
}
/*
* Rosen kaufen ENDE
*/
/*
* Rosen konsuieren START
*/
function successConsumeHandler (result) {
$scope.show($ionicLoading);
var link = 'http://api.raataar.de/rosen/kauf.php';
$http.post(link, {name : $scope.name, freitext: $scope.freitext, rosen: $scope.preis}).then(function (res){
@@ -98,41 +256,17 @@ angular.module('starter.controllers', [])
// error
});
$scope.hide($ionicLoading);
$state.go('tab.buys');
}, function (error) {
console.log('Error');
}, function (progress) {
// PROGRESS HANDLING GOES HERE
});
return false;
});
}
function errorBuyHandler (error) {
/*
var strResult = "";
if(typeof error === 'object') {
strResult = JSON.stringify(error);
} else {
strResult = error;
}
alert("Feher: \r\n"+strResult );
*/
var alertPopup = $ionicPopup.alert({
title: 'Oh Nein',
template: 'Der Kauf konnte nicht durchgeführt werden.'
});
alertPopup.then(function(res) {
console.log('Der Kauf konnte nicht durchgeführt werden');
});
}
function errorConsumeHandler (error) {
@@ -150,40 +284,35 @@ angular.module('starter.controllers', [])
function consumesuccessHandler (result) {
inappbilling.consumePurchase(successConsumeHandler, errorConsumeHandler, $scope.preis);
}
/*
* Rosen konsuieren ENDE
*/
$scope.buyRose = function() {
if((window.device && device.platform == "Android") && typeof inappbilling !== "undefined") {
if ($rootScope.storeinit==1){
//Wegenbug ausgehebelt
//inappbilling.buy(successBuyHandler, errorBuyHandler, $scope.preis);
successConsumeHandler();
}
else{
var alertPopup = $ionicPopup.alert({
title: 'Achtung',
template: 'Der Google-Store konnte nicht initialisiert werden.'
});
alertPopup.then(function(res) {
console.log('Store steht nicht zur Verfuegung');
});
}
}
}
})
.controller('BuysCtrl', function($scope, $database,$location) {
$scope.items=[];
//$scope.items=$localstorage.getObject('items');
.controller('BuysCtrl', function($scope, $database,$location,$ionicModal,$ionicLoading,$timeout) {
/*
$scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) {
if ($location.path() == "/tab/buys") {
if ($location.path() == "/tab/buys") {
$scope.show($ionicLoading);
$timeout(fill_list, 1000);
}
});
*/
$scope.$on( "$ionicView.enter", function( scopes, states ) {
$scope.show($ionicLoading);
$timeout(fill_list, 1000);
});
function fill_list(){
$scope.items=[];
$database.getAllBuys().then(function (result) {
if(result.length>0){
for(i=0;i<result.length;i++){
@@ -192,10 +321,43 @@ angular.module('starter.controllers', [])
} else {
$scope.items=[];
}
});
}
});
$scope.hide($ionicLoading);
}
$scope.show = function() {
$ionicLoading.show({
template: '<p>Lade...</p><ion-spinner></ion-spinner>'
});
};
$scope.hide = function(){
$ionicLoading.hide();
};
$scope.showImages = function(imagesrc) {
$scope.imagesrc=imagesrc;
$scope.showModal('templates/image-popover.html');
}
$scope.showModal = function(templateUrl) {
$ionicModal.fromTemplateUrl(templateUrl, {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.modal = modal;
$scope.modal.show();
});
}
// Close the modal
$scope.closeModal = function() {
$scope.modal.hide();
$scope.modal.remove()
};
});
})