| xqd
@@ -1,6 +1,6 @@
|
|
|
(function (app) {
|
|
|
- app.controller('homeCtrl', ["$scope", "$ionicTabsDelegate","storage", "$http", 'config', "$state", "$ionicSlideBoxDelegate", "msg", "$ionicPopover", "homeService", "$ionicPopup", "$timeout", "$ionicSideMenuDelegate", "$rootScope"
|
|
|
- , function ($scope, $ionicTabsDelegate,storage, $http, config, $state, $ionicSlideBoxDelegate, msg, $ionicPopover, homeService, $ionicPopup, $timeout, $ionicSideMenuDelegate, $rootScope) {
|
|
|
+ app.controller('homeCtrl', ["$scope", "$ionicTabsDelegate","storage", "$http", 'config', 'myService', "$state", "$ionicSlideBoxDelegate", "msg", "$ionicPopover", "homeService", "$ionicPopup", "$timeout", "$ionicSideMenuDelegate", "$rootScope"
|
|
|
+ , function ($scope, $ionicTabsDelegate,storage, $http, config, myService, $state, $ionicSlideBoxDelegate, msg, $ionicPopover, homeService, $ionicPopup, $timeout, $ionicSideMenuDelegate, $rootScope) {
|
|
|
$scope.$on('$ionicView.enter', function () {
|
|
|
$ionicTabsDelegate.showBar(true);
|
|
|
$scope.load(false);
|
| xqd
@@ -643,22 +643,41 @@
|
|
|
//充值
|
|
|
$scope.charge = function(number){
|
|
|
if($scope.ios.isIOS){
|
|
|
- if ($scope.ios.productid.length<2){
|
|
|
- msg.text('请选择充值金额');
|
|
|
- return;
|
|
|
- }
|
|
|
- inAppPurchase
|
|
|
- .buy($scope.ios.productid)
|
|
|
- .then(function (data) {
|
|
|
- return inAppPurchase.consume(data.productType, data.receipt, data.signature);
|
|
|
- })
|
|
|
- .then(function () {
|
|
|
- msg.success('购买成功');
|
|
|
- })
|
|
|
- .catch(function (err) {
|
|
|
- alert('购买失败:'+err);
|
|
|
+ if (number<2){
|
|
|
+ msg.text('请选择充值金额');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ console.log('购买productid:'+number);
|
|
|
+ msg.loading();
|
|
|
+ inAppPurchase
|
|
|
+ .buy(number)
|
|
|
+ .then(function (data) {
|
|
|
+ msg.hide();
|
|
|
+ console.log('购买then:'+JSON.stringify(data));
|
|
|
+ return inAppPurchase.consume(data.productType, data.receipt, data.signature);
|
|
|
+ })
|
|
|
+ .then(function (data) {
|
|
|
+ msg.hide();
|
|
|
+ myService.orderIos(number).then(function (result) {
|
|
|
+ console.log('服务器端购买成功:'+number);
|
|
|
+ }, function (erro) {
|
|
|
});
|
|
|
- }else{
|
|
|
+ console.log('购买成功:'+number);
|
|
|
+ msg.success('购买成功');
|
|
|
+ $timeout(function () {
|
|
|
+ $scope.closeRechargeModal();
|
|
|
+ }, 1000);
|
|
|
+
|
|
|
+ })
|
|
|
+ .catch(function (err) {
|
|
|
+ msg.hide();
|
|
|
+ console.log('购买失败:'+JSON.stringify(err));
|
|
|
+ $timeout(function () {
|
|
|
+ $scope.closeRechargeModal();
|
|
|
+ }, 1000);
|
|
|
+ // alert('购买失败:'+JSON.stringify(err));
|
|
|
+ });
|
|
|
+ }else{
|
|
|
if (!number) {
|
|
|
msg.text('请输入充值金额');
|
|
|
return;
|
| xqd
@@ -842,6 +861,21 @@
|
|
|
|
|
|
$scope.rechagemodal.show();
|
|
|
$scope.vm.money = '';
|
|
|
+ if($scope.ios.isIOS){
|
|
|
+ var productIds = ['apple10000','apple10002','apple10003','apple10004']; // <- Add your product Ids here
|
|
|
+ msg.loading();
|
|
|
+ inAppPurchase
|
|
|
+ .getProducts(productIds)
|
|
|
+ .then(function (products) {
|
|
|
+ msg.hide();
|
|
|
+ $scope.products = products;
|
|
|
+ console.log('products:'+JSON.stringify(products));
|
|
|
+ })
|
|
|
+ .catch(function (err) {
|
|
|
+ msg.hide();
|
|
|
+ console.log(err);
|
|
|
+ });
|
|
|
+ }
|
|
|
};
|
|
|
$scope.closeRechargeModal = function() {
|
|
|
$scope.rechagemodal.hide();
|