a313492b by ex

回调判断支付状态

1 parent affec4af
<div ng-controller="wxPayReturnController" ng-init="init()">
</div>
\ No newline at end of file
......@@ -67,6 +67,11 @@ var app = angular.module('myApp', [ "ui.router",'myApp.services', 'myApp.direct
url: "/rechargeList",
templateUrl: "html/rechargeList.html"
})
.state('wxPayReturn',{
url: "/wxPayReturn/:type",
templateUrl: "html/wxPayReturn.html",
controller: 'wxPayReturnController'
})
......
......@@ -5,9 +5,6 @@ angular.module('myApp')
if(!$rootScope.toPaid){
$state.go('bond');
}
if($rootScope.data.user.userName === 17097826207) {
$rootScope.toPaid = 0.01
}
// 支付保证金
var ispay = false;
$scope.goPay = function(){
......@@ -15,17 +12,16 @@ angular.module('myApp')
ispay = true;
var IswechatPayment= window.localStorage.getItem("IswechatPayment");
if (IswechatPayment== undefined || IswechatPayment == "no") {
wechatPayment.callDepositTypePay($rootScope.toPaid, $scope.payType)
.then(function (result) {
ispay = false;
//支付成功
// alert(window.localStorage.getItem("IswechatPayment"));
window.localStorage.setItem("IswechatPayment", "yes")
$state.go('bondSuccess');
// window.localStorage.setItem("IswechatPayment", "yes")
// $state.go('bondSuccess');
}, function (errMsg) {
ispay = false;
window.localStorage.setItem("IswechatPayment", "no")
// window.localStorage.setItem("IswechatPayment", "no")
//支付失败
})
}
......
angular.module('myApp')
.controller('wxPayReturnController',['$scope','$rootScope','dingdaService','$state','globalService',function($scope,$rootScope,dingdaService,$state,globalService, $stateParams){
var type = $stateParams.type
var init = function() {
switch(type){
case 'order':
dingdaService.getUnfinishedOrder().success(function(data , status){
if(data.meta.code == 200) {
if(!data.data.unfinishedOrder.id) {
layer.open({
content: '支付成功',
time: 2
});
$state.go('main')
return
}else {
$scope.unfinishOrder = data.data.unfinishedOrder;
$state.go('tripDetail' , { orderId : $scope.unfinishOrder.id});
return
}
$state.go('main')
}
}).error(function(data , status) {
console.log(JSON.stringify(data))
})
break
case 'bond':
var longitude = $rootScope.currentPoint.longitude;
var latitude = $rootScope.currentPoint.latitude;
dingdaService.getBond(longitude,latitude)
.success(function(data){
if(data.meta.code == 200){
if(data.data.isActive){
$rootScope.toPaid = data.data.toPaid;
$state.go('bondSuccess');
return
}
}
$state.go('bond')
}).error(function(data){
})
break
default:
}
}
init()
}]);
\ No newline at end of file
......@@ -62,20 +62,20 @@ angular.module('myApp.services')
// $state.go('bond');
var redirect_url= ''
if(isiOS){
redirect_url = "&redirect_url=dcxing.com://" + window.location.origin + window.location.pathname
redirect_url = "&redirect_url=dcxing.com://" + window.location.origin + window.location.pathname + '#/wxPayReturn/' + q
}
window.location.href = sign.mwebUrl + redirect_url;
}
var callUnifiedOrderApi = function(url, data){
var callOrderApi = function(url, data, type){
var q = $q.defer();
$http.post(url, data)
.success(function (data) {
if(data.meta.code == 200) {
// alert('支付签名返回:' + JSON.stringify(data));
wxh5ApiCall(data.data.wechatDto, q);
wxh5ApiCall(data.data.wechatDto, type);
}else{
layer.open({
content:'支付失败:code '+data.meta.code+","+ data.meta.message,
......@@ -130,14 +130,14 @@ angular.module('myApp.services')
// form.querySelector('#ok').click()
document.body.appendChild(form)
document.querySelector('#ok').click()
return callUnifiedOrderApiAliPay('支付')
// return callUnifiedOrderApiAliPay('支付')
case 101:
var param = Object.assign($location.search(),{
amount : amount,
body : "租车租git金",
type : 101
});
return callUnifiedOrderApi(host + "/bill/wx/h5/" + orderId, param);
return callOrderApi(host + "/bill/wx/h5/" + orderId, param, 'order');
default:
return null
......@@ -153,7 +153,7 @@ angular.module('myApp.services')
body : "保证金充值",
type : 101
});
return callUnifiedOrderApi(host + "/bail/wx", param);
return callOrderApi(host + "/bail/wx", param);
}, /**
* 保证金充值
* @param amount
......@@ -187,14 +187,14 @@ angular.module('myApp.services')
// form.querySelector('#ok').click()
document.body.appendChild(form)
document.querySelector('#ok').click()
return callUnifiedOrderApiAliPay('支付')
// return callUnifiedOrderApiAliPay('支付')
case 101:
var param = Object.assign($location.search(),{
amount : amount,
body : "保证金充值",
type : type
});
return callUnifiedOrderApi(host + "/balance/wx/h5", param);
return callOrderApi(host + "/balance/wx/h5", param, 'bond');
default:
return null
......@@ -212,7 +212,7 @@ angular.module('myApp.services')
body : "钱包充值",
type : parseInt(way)
});
return callUnifiedOrderApi(host, param);
return callOrderApi(host, param);
}
}
}]);
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!