Debug-Infos entfernt, vollstaendige Kaufabwicklung hinzugefügt

This commit is contained in:
Carsten Hilmer 2016-01-29 00:56:13 +01:00
parent 6dbbc77c30
commit 38583577f6
6 changed files with 105 additions and 45 deletions

View File

@ -82,3 +82,36 @@
.tab-item{ .tab-item{
background-color: #A50505 !important; background-color: #A50505 !important;
} }
.image-list-thumb {
padding: 2px 2px 2px 2px;
height: 100px;
}
.image-modal {
width: 100% !important;
height: 100%;
top: 0 !important;
left: 0 !important;
}
.transparent {
background: transparent !important;
}
.fullscreen-image {
max-width: 100%;
max-height: 100%;
bottom: 0;
left: 0;
margin: auto;
overflow: auto;
position: fixed;
right: 0;
top: 0;
}
.slider {
width: 100%;
height: 100%;
}

View File

@ -121,6 +121,7 @@ angular.module('starter', ['ionic', 'ngCordova', 'starter.controllers', 'starter
} }
}) })
.state('tab.buys', { .state('tab.buys', {
url: '/buys', url: '/buys',
views: { views: {

View File

@ -1,6 +1,6 @@
angular.module('starter.controllers', []) 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.preis="";
$scope.name=""; $scope.name="";
@ -9,6 +9,17 @@ angular.module('starter.controllers', [])
$scope.item=[]; $scope.item=[];
$scope.show = function() {
$ionicLoading.show({
template: '<p>Kauf wird abgeschlossen.</p><ion-spinner></ion-spinner>'
});
};
$scope.hide = function(){
$ionicLoading.hide();
};
$scope.validate = function() { $scope.validate = function() {
var link = 'http://api.raataar.de/rosen/vorschau.php'; var link = 'http://api.raataar.de/rosen/vorschau.php';
@ -22,38 +33,12 @@ 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) { function successBuyHandler (result) {
$timeout(consumesuccessHandler, 1000); $timeout(consumesuccessHandler, 1000);
} }
function successConsumeHandler (result) { function successConsumeHandler (result) {
$scope.show($ionicLoading);
var link = 'http://api.raataar.de/rosen/kauf.php'; var link = 'http://api.raataar.de/rosen/kauf.php';
$http.post(link, {name : $scope.name, freitext: $scope.freitext, rosen: $scope.preis}).then(function (res){ $http.post(link, {name : $scope.name, freitext: $scope.freitext, rosen: $scope.preis}).then(function (res){
@ -98,7 +83,8 @@ angular.module('starter.controllers', [])
// error // error
}); });
$scope.hide($ionicLoading);
$state.go('tab.buys');
}, function (error) { }, function (error) {
console.log('Error'); console.log('Error');
@ -158,8 +144,8 @@ angular.module('starter.controllers', [])
if ($rootScope.storeinit==1){ if ($rootScope.storeinit==1){
//Wegenbug ausgehebelt //Wegenbug ausgehebelt
//inappbilling.buy(successBuyHandler, errorBuyHandler, $scope.preis); inappbilling.buy(successBuyHandler, errorBuyHandler, $scope.preis);
successConsumeHandler(); //successConsumeHandler();
} }
else{ else{
var alertPopup = $ionicPopup.alert({ var alertPopup = $ionicPopup.alert({
@ -178,12 +164,21 @@ angular.module('starter.controllers', [])
}) })
.controller('BuysCtrl', function($scope, $database,$location) { .controller('BuysCtrl', function($scope, $database,$location,$ionicModal,$ionicLoading) {
$scope.items=[];
//$scope.items=$localstorage.getObject('items');
$scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) { $scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) {
if ($location.path() == "/tab/buys") {
if ($location.path() == "/tab/buys") {
$scope.show($ionicLoading);
fill_list();
$scope.hide($ionicLoading);
}
});
function fill_list(){
$scope.items=[];
$database.getAllBuys().then(function (result) { $database.getAllBuys().then(function (result) {
if(result.length>0){ if(result.length>0){
for(i=0;i<result.length;i++){ for(i=0;i<result.length;i++){
@ -192,10 +187,42 @@ angular.module('starter.controllers', [])
} else { } else {
$scope.items=[]; $scope.items=[];
} }
}); });
}
$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()
};
}) })

View File

@ -0,0 +1,3 @@
<div class="modal image-modal transparent" ng-click="closeModal()">
<img ng-src="{{imagesrc}}" class="fullscreen-image"/>
</div>

View File

@ -21,7 +21,7 @@
<div class="item tabs tabs-secondary tabs-icon-left"> <div class="item tabs tabs-secondary tabs-icon-left">
<a href="#" class="tab-item"><i class="icon ion-trash-a button-custom"></i>Löschen</a> <a href="#" class="tab-item"><i class="icon ion-trash-a button-custom"></i>Löschen</a>
<a href="#" class="tab-item"><i class="icon ion-android-image button-custom"></i>Anzeigen</a> <a href="#" class="tab-item" ng-click="showImages(i.appimgpublicpath)"><i class="icon ion-android-image button-custom"></i>Anzeigen</a>
<a href="#" class="tab-item"><i class="icon ion-share button-custom"></i>Teilen</a> <a href="#" class="tab-item"><i class="icon ion-share button-custom"></i>Teilen</a>
</div> </div>

View File

@ -33,10 +33,6 @@
<div class="col col-50"><button class="button button-full button-small icon-left ion-social-euro button-custom" ng-disabled="!$parent.preis || !$parent.freitext || !$parent.name" ng-click="buyRose()">Jetzt Kaufen</button></div> <div class="col col-50"><button class="button button-full button-small icon-left ion-social-euro button-custom" ng-disabled="!$parent.preis || !$parent.freitext || !$parent.name" ng-click="buyRose()">Jetzt Kaufen</button></div>
</div> </div>
<div class="row">
<div class="col col-50"><button class="button button-full button-small icon-left ion-image button-custom" ng-disabled="!$parent.preis || !$parent.name || !$parent.freitext" ng-click="loaddata()">Laden</button></div>
<div class="col col-50"><button class="button button-full button-small icon-left ion-social-euro button-custom" ng-disabled="!$parent.preis || !$parent.freitext || !$parent.name" ng-click="savedata()">Speichern</button></div>
</div>
</div> </div>
</div> </div>