bondController.js
2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
angular.module('myApp')
.controller('bondController',['$scope' , '$rootScope', '$state' , 'dingdaService' , '$stateParams' ,
function($scope,$rootScope,$state,dingdaService,$stateParams){
$scope.goPay = function(){
$state.go('bondPay');
}
// function getUrl(name){
// var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
// var url = String(window.location);
// var arr = url.split('?');
// var str = arr[arr.length-1];
// var r = str.match(reg);
// if(r!=null)return unescape(r[2]); return null;
// }
$scope.init = function(){
var latitude = $stateParams.latitude;
var longitude = $stateParams.longitude;
dingdaService.getBond(longitude,latitude)
.success(function(data){
// alert(JSON.stringify(data))
$scope.bondInfo = data.data;
$rootScope.toPaid = data.data.toPaid;
}).error(function(data){
// alert(JSON.stringify(data))
layer.open({
content: '获取保证金失败,请刷新页面',
time:2
});
})
}
$scope.drawback = function(){
dingdaService.getUnfinishedOrder().success(function(data , status){
if(data.data.unfinishedOrder.id) {
layer.open({
content: '还有未完成的订单,无法退还保证金',
time:2
});
} else {
layer.open({
content: '您确定要退还保证金吗?',
btn: ['确认', '取消'],
shadeClose: false,
yes: function(index){
layer.close(index);
dingdaService.returnBond()
.success(function(data){
console.log(window.localStorage.getItem("IswechatPayment"));
//alert(window.localStorage.getItem("IswechatPayment"));
window.localStorage.setItem("IswechatPayment","no");
layer.open({
content: '退还成功,保证金七个工作日内退还',
time:2
});
$scope.init();
})
.error(function(data){
layer.open({
content: '退还保证金失败',
time:2
});
})
},no: function(index){
layer.close(index);
}
});
}
})
}
}])