rentDetailController.js
2.28 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
angular.module('myApp')
.controller('rentDetailController',['$scope','$rootScope','$state','dingdaService' ,function($scope,$rootScope,$state,dingdaService){
$scope.detail = {};
$scope.costTime = "";
var oldTime;
$scope.backHome = function(){
$state.go('main');
}
var init = function() {
dingdaService.getUnfinishedOrder().success(function(data , status){
// alert(JSON.stringify(data))
if(data.meta.code == 200) {
if(!data.data.unfinishedOrder.id) {
$state.go('main');
}
}
if(data.data.unfinishedOrder.status == 200) {
$state.go('tripDetail' , { orderId : data.data.unfinishedOrder.id});
}
dingdaService.getOrderRealTimeInfo(data.data.unfinishedOrder.id)
.success(function(data , status){
// alert(JSON.stringify(data))
$scope.datail = data.data.orderDetail;
setInterval(function(){
$scope.$apply(function(){
var h = Math.floor($scope.datail.rentTime / 3600);
var m = Math.floor($scope.datail.rentTime % 3600 / 60);
var s = $scope.datail.rentTime % 60;
if(h < 10) {
h = "0" + h;
}
if(m < 10) {
m = "0" + m;
}
if(s < 10) {
s = "0" + s;
}
$scope.costTime = h + ":" + m + ":" + s;
// console.log($scope.costTime)
if($scope.datail.freeTime <= $scope.datail.rentTime) {
$scope.detail.freeCountdown = "00:00";
} else {
var minute = Math.floor(( $scope.datail.freeTime - $scope.datail.rentTime ) / 60);
if(minute < 10) {
minute = "0" + minute;
}
var second = ( $scope.datail.freeTime - $scope.datail.rentTime ) % 60;
if(second < 10) {
second = "0" + second;
}
$scope.detail.freeCountdown = minute + ":" + second;
}
$scope.datail.rentTime++;
})
} , 1000);
}).error(function(data , status){
})
}).error(function(data , status) {
console.log(JSON.stringify(data))
})
}
init();
// ������ж�ʱ��
setTimeout(function() {
var href = new String(location.href);
if(href.indexOf("rentDetail") > 0) location.reload();
} , 30000)
$scope.alreadyBack = function(){
$state.go('unusual' , { id : $scope.datail.id});
}
}])