Mike 7 年之前
父節點
當前提交
6f01474389

+ 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'));

+ 15 - 12
miaomiao/www/js/config/router.js

xqd xqd
@@ -361,15 +361,15 @@
                 }
             }
         })
-            .state('app.recharge', {
-                url: '/home/recharge',
-                views: {
-                    'app-home': {
-                        templateUrl: 'templates/my/my-recharge.html',
-                        controller: 'payCtrl'
-                    }
+        .state('app.recharge', {
+            url: '/home/recharge',
+            views: {
+                'app-home': {
+                    templateUrl: 'templates/my/my-recharge.html',
+                    controller: 'rechargeCtrl'
                 }
-            })
+            }
+        })
         .state('app.my_setting', {
             url: '/my/setting',
             views: {
@@ -396,12 +396,15 @@
                         controller: 'payExplainCtrl'
                     }
                 }
-            }) .state('app.payDetail', {
-                url: '/my/payDetail',
+            }) .state('app.paySuccess', {
+                url: '/my/paySuccess',
+                params:{
+                  item:null
+                },
                 views: {
                     'app-my': {
-                        templateUrl: 'templates/my/payDetail.html',
-                        controller: 'payDetailCtrl'
+                        templateUrl: 'templates/my/paySuccess.html',
+                        controller: 'paySuccessCtrl'
                     }
                 }
             })

+ 13 - 11
miaomiao/www/js/controllers/home.js

xqd
@@ -632,17 +632,19 @@
                         };
                         // console.log("result: " + JSON.stringify(params));
                         Wechat.sendPaymentRequest(params, function (r) {
-                            $scope.clicksub = false;
-                            courseService.orderStatus(orderID, $scope.paytype).then(function (result) {
-                                $timeout(function () {
-                                    $scope.closeRechargeModal();
-                                }, 500);
-                                homeService.myInfo().then(function (result) {
-                                    $scope.user = result.data.data;
-                                });
-                            }, function (erro) {
-                                // msg.alert("支付反馈失败:" + JSON.stringify(erro));
-                            });
+                            // $scope.clicksub = false;
+                            $timeout(function () {
+                                $scope.closeRechargeModal();
+                            }, 500);
+                            $scope.load(id,dream_user_id,interaction_id);
+                            // courseService.orderStatus(orderID, $scope.paytype).then(function (result) {
+                                
+                            //     homeService.myInfo().then(function (result) {
+                            //         $scope.user = result.data.data;
+                            //     });
+                            // }, function (erro) {
+                            //     // msg.alert("支付反馈失败:" + JSON.stringify(erro));
+                            // });
                         }, function (reason) {
                             $scope.clicksub = false;
                             // msg.alert("支付失败:" + JSON.stringify(reason));

+ 39 - 98
miaomiao/www/js/controllers/my.js

xqd xqd xqd xqd xqd xqd
@@ -223,16 +223,18 @@
                 })
             };
         }]);
-    app.controller('explainCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
-        , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
-
-        }]);
-    app.controller('payDetailCtrl', ["$scope","$ionicTabsDelegate","$ionicHistory", "$state", "myService", "msg","storage"
-        , function ($scope,$ionicTabsDelegate,$ionicHistory, $state,myService, msg, storage) {
+    app.controller('paySuccessCtrl', ["$scope","$stateParams","$ionicTabsDelegate","$ionicHistory", "$state", "myService", "msg","storage"
+        , function ($scope,$stateParams,$ionicTabsDelegate,$ionicHistory, $state,myService, msg, storage) {
+            var item = $stateParams.item;
+            alert(item.out_trade_no);
             $scope.goBack = function(){
                 $ionicHistory.goBack();
             }
         }]);
+    app.controller('explainCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
+        , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
+
+        }]);
     app.controller('contactCtrl', ["$scope","$ionicTabsDelegate", "$timeout","$state", "myService", "msg","storage"
         , function ($scope,$ionicTabsDelegate, $timeout,$state,myService, msg, storage) {
             $scope.vm={
@@ -397,10 +399,11 @@
                 });
             });
         }]);
-    app.controller('rechargeCtrl', ["$scope","$timeout","$ionicHistory","$ionicTabsDelegate", "$state", "myService", "msg"
-  , function ($scope,$timeout, $ionicHistory,$ionicTabsDelegate,$state, myService, msg) {
+    app.controller('rechargeCtrl', ["$scope","$ionicModal","$timeout","$ionicHistory","$ionicTabsDelegate", "$state", "myService", "msg"
+  , function ($scope,$ionicModal,$timeout, $ionicHistory,$ionicTabsDelegate,$state, myService, msg) {
         $scope.$on('$ionicView.beforeEnter', function () {
             $ionicTabsDelegate.showBar(false);
+            $scope.vm = {}
             myService.myInfo().then(function(result){
                 $scope.vm = result.data.data;
                 $scope.vm.number = '';
@@ -427,6 +430,23 @@
             // },500)
         });
       };
+      $ionicModal.fromTemplateUrl('paysuccess-modal.html', {
+        scope: $scope,
+        animation: 'slide-in-up'
+      }).then(function(modal) {
+        $scope.modal = modal;
+      });
+      $scope.openModal = function() {
+        $scope.modal.show();
+      };
+      $scope.closeModal = function() {
+        $scope.modal.hide();
+      };
+      //当我们用到模型时,清除它!
+      $scope.$on('$destroy', function() {
+        $scope.modal.remove();
+      });
+
       //充值
       $scope.charge = function(number){
           if (!number) {
@@ -437,6 +457,9 @@
               //todo:result需要返回支付宝或者微信的签名信息
               console.log("result: " + JSON.stringify(result));
               var payInfo = result.data.data;
+              var orderID = payInfo.transaction_id
+              $scope.vm.transaction_id = payInfo.transaction_id;
+              $scope.vm.price = payInfo.price;
               if ($scope.vm.payType == 1) { //支付宝
                   cordova.plugins.AliPay.pay(payInfo, function success(e) {
                       //e.resultStatus  状态代码  e.result  本次操作返回的结果数据 e.memo 提示信息
@@ -472,10 +495,16 @@
               // console.log("result: " + JSON.stringify(params));
                   Wechat.sendPaymentRequest(params, function (r) {
                       $scope.clicksub = false;
-                      courseService.orderStatus(orderID, $scope.paytype).then(function (result) {
+                      // $state.go("app.paySuccess")
+                      // $state.go('app.paySuccess',{item:payInfo})
+                      $scope.openModal();
+                      // alert(orderID);
+                      myService.orderStatus(orderID).then(function (result) {
                           //  alert(result);
                           //支付成功
                         //  $state.go('app.my');
+                        
+
                       }, function (erro) {
                           // msg.alert("支付反馈失败:" + JSON.stringify(erro));
                       });
@@ -491,95 +520,7 @@
       }
 
   }]);
-    app.controller('payCtrl', ["$scope","$timeout","$ionicHistory","$ionicTabsDelegate", "$timeout","$ionicHistory","$state", "myService", "msg"
-        , function ($scope,$timeout,$ionicHistory,$ionicTabsDelegate, $timeout,$ionicHistory,$state, myService, msg) {
-            $scope.$on('$ionicView.beforeEnter', function () {
-                myService.myInfo().then(function(result){
-                    $scope.vm = result.data.data;
-                    $scope.vm.money = '';
-                    $scope.vm.payType = 2;
-                })
-            });
-            $scope.payExplain = function(){
-                $state.go("app.explain")
-            };
-            $scope.withdraw = function(){
-                $state.go("app.payout")
-            };
-            //充值
-            $scope.testcharge = function(number){
-                if (!number) {
-                    msg.text('请输入充值金额');
-                    return;
-                }
-                myService.testcharge(number,2).then(function (result) {
-                    msg.text("充值成功");
-                    $scope.vm.coin = parseInt($scope.vm.coin) + parseInt(number);
-                    $timeout(function(){
-                        $ionicHistory.goBack();
-                    },500)
-                });
-            }
-            //充值
-            $scope.charge = function(number){
-                if (!number) {
-                    msg.text('请输入充值金额');
-                    return;
-                }
-                myService.charge(number,2).then(function (result) {
-                    //todo:result需要返回支付宝或者微信的签名信息
-                    console.log("result: " + JSON.stringify(result));
-                    var payInfo = result.data;
-                    if ($scope.vm.payType == 1) { //支付宝
-                        cordova.plugins.AliPay.pay(payInfo, function success(e) {
-                            //e.resultStatus  状态代码  e.result  本次操作返回的结果数据 e.memo 提示信息
-                            //e.resultStatus  9000  订单支付成功 ;8000 正在处理中  调用function success
-                            //e.resultStatus  4000  订单支付失败 ;6001  用户中途取消 ;6002 网络连接出错  调用function error
-                            //当e.resultStatus为9000时,请去服务端验证支付结果
-                            $scope.clicksub = false;
-                            if (e.resultStatus == '9000') {
-                                alert(orderID);
-                                //支付成功
-                                // $state.go('app.my');
-                            } else {
-                                msg.error("支付失败");
-                                // msg.error("支付失败:" + JSON.stringify(e));
-                            }
-                        }, function error(e) {
-                            $scope.clicksub = false;
-                            // msg.error("支付失败:" + JSON.stringify(e));
-                            msg.error("支付失败");
-                        });
-                    }
-                    if ($scope.vm.payType == 2) { //微信
-                        var obj = JSON.parse(payInfo);
-                        var params = {
-                            partnerid: obj.partnerid, // merchant id
-                            prepayid: obj.prepayid, // prepay id
-                            noncestr: obj.noncestr, // nonce
-                            timestamp: obj.timestamp, // timestamp
-                            sign: obj.sign, // signed string
-                        };
-                        Wechat.sendPaymentRequest(params, function (r) {
-                            $scope.clicksub = false;
-                            courseService.orderStatus(orderID, $scope.paytype).then(function (result) {
-                                //  alert(result);
-                                //支付成功
-                                //  $state.go('app.my');
-                            }, function (erro) {
-                                msg.alert("支付反馈失败:" + JSON.stringify(erro));
-                            });
-                        }, function (reason) {
-                            $scope.clicksub = false;
-                            msg.alert("支付失败:" + JSON.stringify(reason));
-                        });
-                    }
-                    // msg.text("充值成功");
-                    //   $state.go('app.my');
-                });
-            }
-
-        }]);
+ 
     app.controller('accountCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg"
         , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
             $scope.$on('$ionicView.beforeEnter', function () {

+ 7 - 0
miaomiao/www/js/services/myservice.js

xqd
@@ -27,6 +27,13 @@
                     data: { number:number,goods:1,type:type}
                 })
             },
+            orderStatus:function(number,type){
+                return $http({
+                    url:config.server + "api/pay/order_status",
+                    method:"post",
+                    data: { number:number,goods:1,type:type}
+                })
+            },
             setting:function(){
                 return $http({
                     url:config.server + "api/my/setting",

+ 23 - 0
miaomiao/www/templates/my/my-recharge.html

xqd
@@ -44,4 +44,27 @@
             </button>
         </div>
     </ion-content>
+
+    <script id="paysuccess-modal.html" type="text/ng-template">
+        <div class="modal">
+            <ion-header-bar class="bar-calm bar bar-header has-tabs-top">
+                <h1 class="title">支付成功</h1>
+                <button class="button button-clear" ng-click="closeModal()">关闭</button>
+            </ion-header-bar>
+            <ion-content style="text-align: center; color: #0A0A0A;">
+                <p style=" margin: 80px auto; ">
+                    <i class="icon ion-checkmark-circled" style="color: #148F2C; font-size: 50px;"></i>
+                </p>
+                <p style="font-size: 22px">
+                    已成功充值{{vm.price}}元!
+                </p>
+                <p style="font-size: 20px;margin-top: 60px">
+                    交易号:{{vm.transaction_id}}
+                </p>
+            </ion-content>
+            <div style="width: 100%; position: fixed; bottom: 0; padding: 60px">
+                <button ng-click="closeModal()" class="button button-block button-calm">确认</button>
+            </div>
+        </div>
+    </script>
 </ion-view>

+ 1 - 1
miaomiao/www/templates/my/payExplain.html

xqd
@@ -1,7 +1,7 @@
 <ion-view view-title="交易记录">
     <ion-content>
         <div class="list">
-            <a ui-sref="app.payDetail" class="item reply-item" >
+            <a class="item reply-item" >
                 <div class="item" style="height:90px; border-bottom: 2px solid #EFEFEF">
                     <div style="float:left;">
                         <img style="width: 45px; height: 45px;border-radius: 100%; border: 1px solid #D8D8D8" ng-src="{{ user.avatar | avator }}" />

+ 0 - 0
miaomiao/www/templates/my/payDetail.html → miaomiao/www/templates/my/paySuccess.html