a313492b by ex

回调判断支付状态

1 parent affec4af
1 <div ng-controller="wxPayReturnController" ng-init="init()">
2
3 </div>
...\ No newline at end of file ...\ No newline at end of file
...@@ -67,6 +67,11 @@ var app = angular.module('myApp', [ "ui.router",'myApp.services', 'myApp.direct ...@@ -67,6 +67,11 @@ var app = angular.module('myApp', [ "ui.router",'myApp.services', 'myApp.direct
67 url: "/rechargeList", 67 url: "/rechargeList",
68 templateUrl: "html/rechargeList.html" 68 templateUrl: "html/rechargeList.html"
69 }) 69 })
70 .state('wxPayReturn',{
71 url: "/wxPayReturn/:type",
72 templateUrl: "html/wxPayReturn.html",
73 controller: 'wxPayReturnController'
74 })
70 75
71 76
72 77
......
...@@ -5,9 +5,6 @@ angular.module('myApp') ...@@ -5,9 +5,6 @@ angular.module('myApp')
5 if(!$rootScope.toPaid){ 5 if(!$rootScope.toPaid){
6 $state.go('bond'); 6 $state.go('bond');
7 } 7 }
8 if($rootScope.data.user.userName === 17097826207) {
9 $rootScope.toPaid = 0.01
10 }
11 // 支付保证金 8 // 支付保证金
12 var ispay = false; 9 var ispay = false;
13 $scope.goPay = function(){ 10 $scope.goPay = function(){
...@@ -15,17 +12,16 @@ angular.module('myApp') ...@@ -15,17 +12,16 @@ angular.module('myApp')
15 ispay = true; 12 ispay = true;
16 var IswechatPayment= window.localStorage.getItem("IswechatPayment"); 13 var IswechatPayment= window.localStorage.getItem("IswechatPayment");
17 if (IswechatPayment== undefined || IswechatPayment == "no") { 14 if (IswechatPayment== undefined || IswechatPayment == "no") {
18
19 wechatPayment.callDepositTypePay($rootScope.toPaid, $scope.payType) 15 wechatPayment.callDepositTypePay($rootScope.toPaid, $scope.payType)
20 .then(function (result) { 16 .then(function (result) {
21 ispay = false; 17 ispay = false;
22 //支付成功 18 //支付成功
23 // alert(window.localStorage.getItem("IswechatPayment")); 19 // alert(window.localStorage.getItem("IswechatPayment"));
24 window.localStorage.setItem("IswechatPayment", "yes") 20 // window.localStorage.setItem("IswechatPayment", "yes")
25 $state.go('bondSuccess'); 21 // $state.go('bondSuccess');
26 }, function (errMsg) { 22 }, function (errMsg) {
27 ispay = false; 23 ispay = false;
28 window.localStorage.setItem("IswechatPayment", "no") 24 // window.localStorage.setItem("IswechatPayment", "no")
29 //支付失败 25 //支付失败
30 }) 26 })
31 } 27 }
......
1 angular.module('myApp')
2 .controller('wxPayReturnController',['$scope','$rootScope','dingdaService','$state','globalService',function($scope,$rootScope,dingdaService,$state,globalService, $stateParams){
3
4 var type = $stateParams.type
5
6 var init = function() {
7 switch(type){
8 case 'order':
9 dingdaService.getUnfinishedOrder().success(function(data , status){
10 if(data.meta.code == 200) {
11 if(!data.data.unfinishedOrder.id) {
12 layer.open({
13 content: '支付成功',
14 time: 2
15 });
16 $state.go('main')
17 return
18 }else {
19 $scope.unfinishOrder = data.data.unfinishedOrder;
20 $state.go('tripDetail' , { orderId : $scope.unfinishOrder.id});
21 return
22 }
23 $state.go('main')
24 }
25
26
27 }).error(function(data , status) {
28 console.log(JSON.stringify(data))
29 })
30 break
31 case 'bond':
32 var longitude = $rootScope.currentPoint.longitude;
33 var latitude = $rootScope.currentPoint.latitude;
34 dingdaService.getBond(longitude,latitude)
35 .success(function(data){
36 if(data.meta.code == 200){
37 if(data.data.isActive){
38 $rootScope.toPaid = data.data.toPaid;
39 $state.go('bondSuccess');
40 return
41 }
42 }
43 $state.go('bond')
44 }).error(function(data){
45
46 })
47 break
48 default:
49 }
50
51 }
52 init()
53
54 }]);
...\ No newline at end of file ...\ No newline at end of file
...@@ -62,20 +62,20 @@ angular.module('myApp.services') ...@@ -62,20 +62,20 @@ angular.module('myApp.services')
62 // $state.go('bond'); 62 // $state.go('bond');
63 var redirect_url= '' 63 var redirect_url= ''
64 if(isiOS){ 64 if(isiOS){
65 redirect_url = "&redirect_url=dcxing.com://" + window.location.origin + window.location.pathname 65 redirect_url = "&redirect_url=dcxing.com://" + window.location.origin + window.location.pathname + '#/wxPayReturn/' + q
66 } 66 }
67 window.location.href = sign.mwebUrl + redirect_url; 67 window.location.href = sign.mwebUrl + redirect_url;
68 68
69 } 69 }
70 70
71 71
72 var callUnifiedOrderApi = function(url, data){ 72 var callOrderApi = function(url, data, type){
73 var q = $q.defer(); 73 var q = $q.defer();
74 $http.post(url, data) 74 $http.post(url, data)
75 .success(function (data) { 75 .success(function (data) {
76 if(data.meta.code == 200) { 76 if(data.meta.code == 200) {
77 // alert('支付签名返回:' + JSON.stringify(data)); 77 // alert('支付签名返回:' + JSON.stringify(data));
78 wxh5ApiCall(data.data.wechatDto, q); 78 wxh5ApiCall(data.data.wechatDto, type);
79 }else{ 79 }else{
80 layer.open({ 80 layer.open({
81 content:'支付失败:code '+data.meta.code+","+ data.meta.message, 81 content:'支付失败:code '+data.meta.code+","+ data.meta.message,
...@@ -130,14 +130,14 @@ angular.module('myApp.services') ...@@ -130,14 +130,14 @@ angular.module('myApp.services')
130 // form.querySelector('#ok').click() 130 // form.querySelector('#ok').click()
131 document.body.appendChild(form) 131 document.body.appendChild(form)
132 document.querySelector('#ok').click() 132 document.querySelector('#ok').click()
133 return callUnifiedOrderApiAliPay('支付') 133 // return callUnifiedOrderApiAliPay('支付')
134 case 101: 134 case 101:
135 var param = Object.assign($location.search(),{ 135 var param = Object.assign($location.search(),{
136 amount : amount, 136 amount : amount,
137 body : "租车租git金", 137 body : "租车租git金",
138 type : 101 138 type : 101
139 }); 139 });
140 return callUnifiedOrderApi(host + "/bill/wx/h5/" + orderId, param); 140 return callOrderApi(host + "/bill/wx/h5/" + orderId, param, 'order');
141 141
142 default: 142 default:
143 return null 143 return null
...@@ -153,7 +153,7 @@ angular.module('myApp.services') ...@@ -153,7 +153,7 @@ angular.module('myApp.services')
153 body : "保证金充值", 153 body : "保证金充值",
154 type : 101 154 type : 101
155 }); 155 });
156 return callUnifiedOrderApi(host + "/bail/wx", param); 156 return callOrderApi(host + "/bail/wx", param);
157 }, /** 157 }, /**
158 * 保证金充值 158 * 保证金充值
159 * @param amount 159 * @param amount
...@@ -187,14 +187,14 @@ angular.module('myApp.services') ...@@ -187,14 +187,14 @@ angular.module('myApp.services')
187 // form.querySelector('#ok').click() 187 // form.querySelector('#ok').click()
188 document.body.appendChild(form) 188 document.body.appendChild(form)
189 document.querySelector('#ok').click() 189 document.querySelector('#ok').click()
190 return callUnifiedOrderApiAliPay('支付') 190 // return callUnifiedOrderApiAliPay('支付')
191 case 101: 191 case 101:
192 var param = Object.assign($location.search(),{ 192 var param = Object.assign($location.search(),{
193 amount : amount, 193 amount : amount,
194 body : "保证金充值", 194 body : "保证金充值",
195 type : type 195 type : type
196 }); 196 });
197 return callUnifiedOrderApi(host + "/balance/wx/h5", param); 197 return callOrderApi(host + "/balance/wx/h5", param, 'bond');
198 198
199 default: 199 default:
200 return null 200 return null
...@@ -212,7 +212,7 @@ angular.module('myApp.services') ...@@ -212,7 +212,7 @@ angular.module('myApp.services')
212 body : "钱包充值", 212 body : "钱包充值",
213 type : parseInt(way) 213 type : parseInt(way)
214 }); 214 });
215 return callUnifiedOrderApi(host, param); 215 return callOrderApi(host, param);
216 } 216 }
217 } 217 }
218 }]); 218 }]);
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!