Mike 7 лет назад
Родитель
Сommit
900769fe5f

+ 4 - 4
miaomiao/www/js/config/config.js

xqd
@@ -1,11 +1,11 @@
 (function (app) {
     //全局配置 
     app.constant("config", {
-        server: 'http://q8.9026.com/',
-        imgServer: 'http://q8.9026.com/attachment/'
+    //     server: 'http://q8.9026.com/',
+    //     imgServer: 'http://q8.9026.com/attachment/'
         //server: 'http://localhost:8092/',
         //imgServer: 'http://localhost:8092/attachment/',
-        // server: 'http://miao.beiyuesi.com/',
-        // imgServer: 'http://miao.beiyuesi.com/attachment/'
+        server: 'http://miao.beiyuesi.com/',
+        imgServer: 'http://miao.beiyuesi.com/attachment/'
     });
 })(angular.module('app'));

+ 51 - 17
miaomiao/www/js/controllers/home.js

xqd xqd 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);
@@ -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;
@@ -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();

+ 1 - 1
miaomiao/www/js/controllers/my.js

xqd
@@ -413,7 +413,7 @@
                 $scope.vm.payType = 2;
             });
             if($scope.ios.isIOS){
-                var productIds = ['apple100000','apple100001','apple100002','apple100003','apple100004']; // <- Add your product Ids here
+                var productIds = ['apple10000','apple10002','apple10003','apple10004']; // <- Add your product Ids here
                 msg.loading();
                 inAppPurchase
                   .getProducts(productIds)

+ 3 - 15
miaomiao/www/templates/home/dream-detail.html

xqd
@@ -386,23 +386,11 @@
                             </div>
                             <div ng-if="ios.isIOS">
                                 <div class="item" style="color: #969696; padding-top: 40px">
-                                     充值金额
+                                     请选择充值金额
                              </div>
                             <ion-list>
-                                <ion-radio ng-model="ios.productid"  ng-value="'apple100000'">
-                                    <span>充值1元</span>
-                                </ion-radio>
-                                <ion-radio ng-model="ios.productid" ng-value="'apple100001'">
-                                    <span>充值6元</span>
-                                </ion-radio>
-                                <ion-radio ng-model="ios.productid" ng-value="'apple100002'">
-                                    <span>充值50元</span>
-                                </ion-radio>
-                                <ion-radio ng-model="ios.productid" ng-value="'apple100003'">
-                                  <span>充值188元</span>
-                                </ion-radio>
-                                <ion-radio ng-model="ios.productid" ng-value="apple100004">
-                                    <span>充值898元</span>
+                                <ion-radio ng-repeat="product in products" ng-model="vm.number"  ng-value="product.productId">
+                                  <span>{{product.title}}</span>
                                 </ion-radio>
                             
                             </ion-list>