-
Notifications
You must be signed in to change notification settings - Fork 0
/
tyxcontrollers.js
1074 lines (979 loc) · 49.3 KB
/
tyxcontrollers.js
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Created by Administrator on 2016/5/4 0004.
*/
angular.module('24EApp.tyxcontrollers',[])
.controller('RouteCtrr',function($scope){
})
//一键下单
.controller('OneKeyOderCtr',function($http,$scope,$rootScope,$ionicPopup,$document,$ionicLoading,$cordovaGeolocation,$location,$interval,$state){
var interval=$interval(function(){
$http.get("http://" + $scope.url + "/index.php/Client/Order/detection")
.success(function(res){
if(res==1){
$ionicPopup.alert({title:"系统提醒你的订单已有司机接单了"})
.then(function(){
})
$interval.cancel(interval);
}
});
},5000);
var intervalpay=$interval(function(){
$http.get("http://" + linkUrl + "/index.php/Client/Order/detectionPay")
.success(function(res){
if(res){
$interval.cancel(intervalpay);
$ionicPopup.alert({title:"您有订单待支付,请前去支付"})
.then(function(){
$state.go("OrderManagement");
})
}
});
},5000)
$ionicLoading.show({
template: "正在初始化地图,请稍等...",
noBackdrop: true,
duration: 1500
});
var Omap=$document[0].getElementById('Pmap');
var map = new BMap.Map(Omap);
createMap();//创建地图
function createMap(){
var aa= window.locationService.getCurrentPosition(function(position){
var lat = position.coords.latitude;
var long = position.coords.longitude;
$rootScope.point = new BMap.Point(long, lat);
map.centerAndZoom($rootScope.point, 12);
var marker = new BMap.Marker($rootScope.point);
map.addOverlay(marker);
});
if(aa==null){
var options = {
maximumAge: 5 * 60 * 1000,
timeout: 10 * 1000,
enableHighAccuracy: true,
};
$cordovaGeolocation.getCurrentPosition(options).then(function(position) { //h5地理定位
var lat = position.coords.latitude;
var long = position.coords.longitude;
$rootScope.point = new BMap.Point(long, lat);
map.centerAndZoom($rootScope.point, 12);
//alert(lat+"----"+long);
var geoc = new BMap.Geocoder();
var convertor = new BMap.Convertor();
var pointArr = [];
pointArr.push($rootScope.point);
//将谷歌地图的经纬度转化为百度地图的
convertor.translate(pointArr, 3, 5, function (data) {
if (data.status === 0) {
map.centerAndZoom(data.points[0], 18);
var marker = new BMap.Marker(data.points[0]);
map.addOverlay(marker);
geoc.getLocation(data.points[0], function (rs) {
var addComp = rs.addressComponents;
$ionicPopup.alert({title:addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber});
});
}
})
})
}
else{
$ionicPopup.alert({title:"获取位置失败"});
}
}
})
//正在拍单
.controller('OneKeyOderLaterCtr',function($scope,$location,$ionicPopup,$http,$rootScope,$document,$timeout,$filter,$state,$ionicLoading,$interval,$cordovaGeolocation){
//每次进入拍单页面获取位置信息
window.locationService.getCurrentPosition(function(pos){
$rootScope.lon = pos.coords.longitude;
$rootScope.lat = pos.coords.latitude;
},function(e){
var options = {
maximumAge: 5 * 60 * 1000,
timeout: 10 * 1000,
enableHighAccuracy: true,
};
$cordovaGeolocation.getCurrentPosition(options).then(function(position) { //h5地理定位
$rootScope.lat = position.coords.latitude;
$rootScope.lon = position.coords.longitude;
},function(e) {
});
});
$scope.showConfirm=function(){
$ionicPopup.show({
title:'<h2 class="pd-H2">温馨提示</h2>',
template:'<span class="pd-span1">全顺正在联络代驾司机为您服务,确定</span><p class="pd-P">现在取消订单?</p>',
scope: $scope,
cssClass :"OneKeyOderLater",
buttons:[
{text:"确定",
onTap: function() {
$scope.flag = true;
}
},
{text:"继续等待",
type:"button-positive",
onTap: function() {
$scope.flag = false;
}
}
]
}).then(function() {
var timer = $timeout(function() {
if($scope.flag) {
$http({
method: 'GET',
url: "http://"+$scope.url+"/index.php/Client/OneKeyOrder/cancelorder",
params: {
"buttonsflag": $scope.flag,
"id": $rootScope.user.id
}
}).success(function(res) {
if(res) {
$ionicLoading.show({
template:"订单已取消",
noBackdrop:true,
duration:1500
});
} else {
$ionicLoading.show({
template:"没有订单可以取消",
noBackdrop:true,
duration:1500
});
}
});
}
$timeout.cancel(timer);
}, 100);
});
};
var Omap=$document[0].getElementById('allmap');
var map = new BMap.Map(Omap);
function createMap(){
map.centerAndZoom($rootScope.point, 12);
}
function initMap(){
createMap();//创建地图
addMapControl();
}
//地图控件添加函数:
function addMapControl(){
// 添加定位控件
var geolocationControl = new BMap.GeolocationControl({
anchor:BMAP_ANCHOR_BOTTOM_RIGHT
});
geolocationControl.addEventListener("locationSuccess", function(e){
// 定位成功事件
var from = e.addressComponent.city + e.addressComponent.district +
e.addressComponent.street + e.addressComponent.streetNumber;
// $scope.from = e.addressComponent.district + e.addressComponent.street;
$scope.distinct = e.addressComponent.city;
$ionicPopup.alert({title: "当前定位地址为:" + from});
// $scope.from_location = e.point;
});
geolocationControl.addEventListener("locationError",function(e){
// 定位失败事件
//alert(e.message);
});
map.addControl(geolocationControl);
}
initMap();
$scope.order = function() {
var geoc = new BMap.Geocoder();
if($rootScope.lon !== undefined && $rootScope.lat !== undefined) {
var c = new BMap.Point($rootScope.lon, $rootScope.lat);
geoc.getLocation(c, function(res) {
$scope.from = res.address;
var d = $scope.destinationmodel;
var q, output_start_location;
geoc.getPoint(d, function(res) {
output_start_location = res;
if(c) {
if(d) {
var orderdate = new Date();
var usertime = $filter('date')(orderdate, 'HH:mm:ss');
var f, f1;
$http.get('http://'+$scope.url+'/index.php/Client/OneKeyOrder/getprice?time='+usertime)
.success(function(res) {
$scope.price = parseInt(res);
f1 = Math.floor((map.getDistance(output_start_location,
c)) / 1000);
if(f1<1) {
f = 1;
} else {
f = f1;
}
if(f <= 10) {
$scope.preestimateprice = $scope.price;
} else {
$scope.preestimateprice = $scope.price + Math.ceil((f-10)/5) * 20;
}
var tel = $rootScope.user.phone;
var orderdateformated = $filter('date')(orderdate,
'yyyy-MM-dd HH:mm:ss');
var e = $scope.preestimateprice;
if(e) {
$ionicPopup.show({
title:'<h2 class="pd-H2">订单确定</h2>',
template:'<span class="pd-span1">此次代驾预计路程为'+f+'公里,价格为'+e+'元</span><p class="pd-P">确定下单?</p>',
scope: $scope,
cssClass :"OneKeyOderLater",
buttons:[
{text:"确定",
onTap: function() {
$scope.flag_order = true;
}
},
{text:"取消",
type: "button-calm",
onTap: function() {
$scope.flag_order = false;
}
}
]
}).then(function() {
if($scope.flag_order === true) {
$http({
method: "GET",
url: "http://"+$scope.url+"/index.php/Client/OneKeyOrder/onekeyorder",
params: {
"id": $rootScope.user.id,
"tel": tel,
"date": orderdateformated,
"from": $scope.from,
"destination": d,
"distance": f,
"estimateprice": e
}
}).success(function(res) {
if(res !== false){
$ionicPopup.alert({title: "拍单成功"})
.then(function() {
var interval=$interval(function(){
$http.get("http://" + $scope.url + "/index.php/Client/Order/detection")
.success(function(res){
if(res==1){
$ionicPopup.alert({title:"系统提醒你的订单已有司机接单了"})
.then(function(){
$interval.cancel(interval);
})
}
});
},3000)
$http({
url:'http://'+$scope.url+'/index.php/Client/DuanXin/payDuan',
method:'POST',
data:{
'phone':$rootScope.user.phone
}
}).success(function(res){
console.log("短信发送成功");
$state.go('OneKeyOder');
}).error(function(res){
console.log("短信发送失败");
$state.go('OneKeyOder');
})
});
} else {
$ionicPopup.alert({title: "当前订单未完成"});
}
});
}
});
} else {
$ionicPopup.alert({title:
"拍单失败"});
}
});
map.clearOverlays();
driving = new BMap.DrivingRoute(map, {renderOptions:
{map: map, autoViewport: true}});
driving.search(c, output_start_location);
} else {
$ionicLoading.show({
template: "请先输入目的地",
noBackdrop: true,
duration: 1500
});
}
} else {
$ionicLoading.show({
template: "请先进行地位",
noBackdrop: true,
duration: 1500
});
}
}, $scope.distinct);
});
} else {
$ionicPopup.alert({title: "未知错误,请返回后重新进入拍单页面"});
}
};
$scope.getItems = function (item) {
$timeout(function () {
$scope.mapitems = item;
}, 500)
};
//获取目的地(发送到api计算距离)
function mapSelect1(id) {
var muArray = $scope.mapitems;
if (muArray != undefined) {
$scope.destinationmodel = id;
}
}
//打开目的地弹窗页面
$scope.account = function () {
$rootScope.popup = $ionicPopup.show({
cssClass: 'myPopup',
templateUrl: 'templates/Client/mudidi.html',
scope: $scope
});
$rootScope.popup.isPopup=true;
};
//关闭目的地弹窗页面
$scope.pSelect = function () {
$rootScope.popup.close();
$rootScope.popup.isPopup=false;
};
//获取目的地
$scope.MSelect = function (id) {
$scope.destinationmodel = id;
mapSelect1(id);
$rootScope.popup.close();
$rootScope.popup.isPopup=false;
};
})
//代叫
.controller('DaiJiaoCtr',function($scope,$ionicActionSheet,$http,$ionicModal,$ionicPopup,$rootScope,$filter,$timeout,$state,$document,$stateParams,$ionicLoading,$cordovaContacts, $ionicPlatform,$location,$interval) {
/*智能筛选->方法在appservices的mapSuggestion指令*/
$scope.getItems = function (item) {
$timeout(function () {
$scope.mapitems = item;
}, 500)
};
$scope.nb = '1';
$scope.items = {
firstname: '司机数量', secondname: '联系电话',
thirdname: '出发地', fourthname: '目的地',
fifthname: '预估价'
};
//联系电话
$ionicModal.fromTemplateUrl("templates/Client/daijiao-tel.html", {
scope: $scope,
animation: "slide-in-right"
}).then(function (modal) {
$scope.modal = modal;
});
$scope.openTelModal = function () {
$scope.modal.show();
};
$scope.closeTelModal = function (myForm) {
//console.log(myForm.telphone)
if (myForm.telphone.$$lastCommittedViewValue == undefined || myForm.telphone.$$lastCommittedViewValue == "") {
//alert("不能为空")
$ionicPopup.alert({
title: '<h3>抱歉</h3>',
template: '<span>电话号码不能为空</span>',
cssClass: 'telClass',
buttons: [{
text: '我知道了'
}]
})
}
else if (myForm.telphone.$invalid) {
//alert("djlk")
$ionicPopup.alert({
title: '<h3>抱歉</h3>',
template: '<span>请输入正确的手机号码</span>',
cssClass: 'telClass',
buttons: [{
text: '我知道了'
}]
})
}
if (myForm.$valid) {
//alert("ok")
$scope.modal.hide();
}
//$scope.modal.hide();
$scope.telphone = myForm.telphone.$$lastCommittedViewValue;
};
$scope.claseM = function () {
$scope.modal.hide();
};
//Cleanup the modal when we are done with it!
$scope.$on("$destroy", function () {
$scope.modal.remove();
});
// Execute action on hide modal
$scope.$on("modal.hidden", function () {
// Execute action
});
// Execute action on remove modal
$scope.$on("modal.removed", function () {
// Execute action
});
//导入电话本
//$scope.addContact = function () {
// $cordovaContacts.save($scope.contactForm).then(function (result) {
// // Contact saved
// }, function (err) {
// // Contact error
// });
//};
//
//$scope.getAllContacts = function () {
// $cordovaContacts.find().then(function (allContacts) { //omitting parameter to .find() causes all contacts to be returned
// $scope.contacts = allContacts;
// })
//};
//
//$scope.findContactsBySearchTerm = function (searchTerm) {
// var opts = { //search options
// filter: searchTerm, // 'Bob'
// multiple: true, // Yes, return any contact that matches criteria
// fields: ['displayName', 'name'], // These are the fields to search for 'bob'.
// desiredFields: [id] //return fields.
// };
// //console.log(desiredFields)
//
// if ($ionicPlatform.isAndroid()) {
// opts.hasPhoneNumber = true; //hasPhoneNumber only works for android.
// }
// ;
//
// $cordovaContacts.find(opts).then(function (contactsFound) {
// $scope.contacts = contactsFound;
// })
//}
//
//$scope.pickContactUsingNativeUI = function () {
// $cordovaContacts.pickContact().then(function (contactPicked) {
// $scope.contact = contactPicked;
// })
//}
//上拉菜单
$scope.show = function () {
$ionicActionSheet.show({
buttons: [
{text: '1'},
{text: '2'}
],
buttonClicked: function (index) {
if (index == 0) {
$scope.nb = '1';
return true;
}
if (index == 1) {
$scope.nb = '2';
return true;
}
},
cssClass: 'daijiaoAc'
})
};
//下单
var daijiaomap = $document[0].getElementById('daijiaomap');
var map = new BMap.Map(daijiaomap);
function createMap() {
var point = new BMap.Point(113.307, 23.120);
map.centerAndZoom(point, 15);
}
createMap();
$scope.myform = {};
$scope.order = function (myform) {
var tel = $scope.telphone;
var a = $scope.myform.djfrom;
var b = $scope.myform.djdestination;
var orderdate = new Date();
var orderdateformated = $filter('date')(orderdate, 'yyyy-MM-dd HH:mm:ss');
var usertime = $filter('date')(orderdate, 'HH:mm:ss');
var geoc = new BMap.Geocoder();
if (tel) {
if (a) {
if (b) {
geoc.getPoint(a, function(res) {
if(res == null) {
$ionicPopup.alert({title: "代叫失败"});
return false;
}
var output_start_location = res;
geoc.getPoint(b, function(res) {
if(res == null) {
$ionicPopup.alert({title: "代叫失败"});
return false;
}
var output_destination_location = res;
var f1 = Math.floor((map.getDistance(output_start_location,
output_destination_location)) / 1000);
var f;
if(f1<1) {
f = 1;
} else {
f = f1;
}
$http.get('http://'+$scope.url+'/index.php/Client/OneKeyOrder/getprice?time='+usertime)
.success(function(res) {
$scope.price = parseInt(res);
if (f <= 10) {
$scope.preestimateprice = $scope.price;
} else {
$scope.preestimateprice = $scope.price + Math.ceil((f - 10) / 5) * 20;
}
if ($scope.preestimateprice) {
$ionicPopup.show({
title:'<h2 class="pd-H2">订单确定</h2>',
template:'<span class="pd-span1">此次代驾预计路程为'+f+'公里,价格为'+$scope.preestimateprice+'元</span><p class="pd-P">确定下单?</p>',
scope: $scope,
cssClass :"OneKeyOderLater",
buttons:[
{text:"确定",
onTap: function() {
$scope.flag_order = true;
}
},
{text:"取消",
type: "button-calm",
onTap: function() {
$scope.flag_order = false;
}
}
]
}).then(function() {
if($scope.flag_order === true) {
$http({
method: "GET",
url: "http://" + $scope.url + "/index.php/Client/OneKeyOrder/daijiao",
params: {
'userid': $rootScope.user.id,
'tel': tel,
'from': a,
'to': b,
'price': $scope.preestimateprice,
'distance': f,
'date': orderdateformated
}
}).success(function (res) {
if (res.result = "success") {
$ionicPopup.alert({title: "代叫成功"})
.then(function () {
var interval=$interval(function(){
$http.get("http://" + $scope.url + "/index.php/Client/Order/detection")
.success(function(res){
if(res==1){
$ionicPopup.alert({title:"系统提醒你的订单已有司机接单了"})
.then(function(){
$interval.cancel(interval);
})
}
});
},3000)
//$state.go("pag", {"order_number": res.order_number});
$http({
url:'http://'+$scope.url+'/index.php/Client/DuanXin/payDuan',
method:'POST',
data:{
'phone':$rootScope.user.phone
}
}).success(function(res){
console.log("短信发送成功");
$state.go('OneKeyOder');
}).error(function(res){
console.log("短信发送失败");
$state.go('OneKeyOder');
})
});
} else {
$ionicPopup.alert({title: "代叫失败"});
}
}).error(function () {
$ionicPopup.alert({title: "代叫失败"});
});
}
});
} else {
$ionicPopup.alert({title: "代叫失败"});
}
});
}, "桂林市");
}, "桂林市");
} else {
$ionicLoading.show({
template: "请先输入目的地",
noBackdrop: true,
duration: 1500
});
}
} else {
$ionicLoading.show({
template: "请先输入出发地",
noBackdrop: true,
duration: 1500
});
}
} else {
$ionicLoading.show({
template: "请先输入电话号码",
noBackdrop: true,
duration: 1500
});
}
};
//获取出发地(发送到api计算距离)
var mapSelect = function (id) {
//console.log(2222)
var pp = $scope.mapitems;
console.log(pp);
if (pp != undefined) {
$scope.myform.djfrom = id;
}
};
//获取目的地(发送到api计算距离)
function mapSelect1(id) {
var muArray = $scope.mapitems;
console.log(muArray);
if (muArray != undefined) {
$scope.myform.djdestination = id;
}
}
//打开目的地弹窗页面
$scope.account = function () {
$rootScope.popup = $ionicPopup.show({
cssClass: 'myPopup',
templateUrl: 'templates/Client/mudidi.html',
scope: $scope
});
$rootScope.popup.isPopup=true;
};
//关闭目的地弹窗页面
$scope.pSelect = function () {
$rootScope.popup.close();
$rootScope.popup.isPopup=false;
};
//获取目的地
$scope.MSelect = function (id) {
$scope.myform.djdestination = id;
mapSelect1(id);
$rootScope.popup.close();
$rootScope.popup.isPopup=false;
};
//打开出发地弹窗页面
$scope.chufadi = function () {
$rootScope.popup = $ionicPopup.show({
cssClass: 'myPopup',
templateUrl: 'templates/Client/chufadi.html',
scope: $scope
});
$rootScope.popup.isPopup=true;
};
//关闭出发地弹窗页面
$scope.cSelect = function () {
$rootScope.popup.close();
$rootScope.popup.isPopup=false;
};
//获取出发地
$scope.CSelect = function (id) {
$scope.myform.djfrom = id;
mapSelect(id);
$rootScope.popup.close();
$rootScope.popup.isPopup=false;
}
})
//订单管理PriceListCtr
.controller('OrderManagementCtr',function($scope,$http,$state,$rootScope,$timeout,$ionicPopup,$ionicLoading,$timeout){
var run = false;
var obj = {current:0,count:8};
$scope.on_select = function(status){
$scope.hasmore=true;
obj.current=0;
obj.status=status;
obj.userid=$rootScope.user.id;
var result = chushihua(obj,1);
};
//下拉加载
$scope.loadMore = function(status){
var old = $scope.items;
obj.status=status;
if(old!=undefined){
var result = chushihua(obj,3);
}
$timeout(function(){
$scope.$broadcast('scroll.infiniteScrollComplete');
},500);
};
function chushihua(obj_data,state){
if(!run){
run = true;
$http({
method:'GET',
url:'http://'+$scope.url+'/index.php/Client/Order/get_orders',
params:obj_data,
}).success(function(data){
run = false;
if(state==3){
if (data==null||data.length==0) {
console.log("结束");
$scope.hasmore=false;
}else{
obj.current += obj.count;
$scope.items= $scope.items.concat(data);
}
}else{
$scope.items=data;
}
if(!$scope.items) {
$scope.displaystatus = true;
} else {
$scope.displaystatus = false;
}
//console.log(data);
})
}
}
/*-----------取消订单----------------*/
$scope.cancelOrder=function(orderform){
$ionicPopup.confirm({
"title":"您是否取消该订单?",
okText: "确定",
cancelText: "取消"
}).then(function(res){
if(res){
$http({
method:"POST",
url:"http://"+$scope.url+"/index.php/Client/Order/cancel_order",
data:{
orderform:orderform,
login_id:$rootScope.user.id
}
}).success(function(res){
if(res){
$ionicLoading.show({
template:res.msg,
noBackdrop:true,
duration:1500
})
}else{
$ionicLoading.show({
template:'取消有误',
noBackdrop:true,
duration:1500
})
}
})
}else{
return;
}
});
}
/*-------------订单支付----------------*/
$scope.payfor=function(orderform){
console.log(orderform);
for(var i=0;i<$scope.items.length;i++){
if(orderform==$scope.items[i].orderform){
var order=$scope.items[i];
break;
}
}
if(order.real_price==null){
real_price="暂无实际价格";
}else{
real_price="¥"+order.real_price;
}
$ionicPopup.confirm({
template: "<p class='center'>您本次订单的:</p><p>预估金额为:¥" + order.estimate_price + "</p><p>实际代驾金额为:" + real_price + "</p>",
title: "<h3>支付</h3>",
okText: '立即支付',
cancelText: '取消',
})
.then(function (res) {
if (res) {
$state.go("pag", {"order_number": orderform});
} else {
console.log('您已取消支付');
}
})
}
})
//
.controller('PriceListCtr',function($scope,$http){
$http.get("http://"+$scope.url+"/index.php/Client/Price/price").success(function(data){
$scope.price=data;console.log(data);
})
})
//代办业务
.controller('AgentServiceCtr',function($scope,$ionicPopup){
//$scope.lists=[
// {H3Class:'listHOne',h3:'年审',span:'高效、快速',p:'让你高枕无忧',ListSrc:'img/daiban1.png',Aclick:'aAlert'},
// {H3Class:'listHTwo',h3:'保险',span:'安全、保障',p:'做到最好,为你安心',ListSrc:'img/daiban2.png'},
// {H3Class:'listHThree',h3:'绿标',span:'正宗、效率',p:'让您车畅通无阻',ListSrc:'img/daiban3.png'},
// {H3Class:'listHFour',h3:'过户',span:'专业、安全',p:'让您放心、省心',ListSrc:'img/daiban4.png'},
// {H3Class:'listHFive',h3:'换证服务预订',span:'',p:'',ListSrc:'img/daiban5.png'}
//];
$scope.lists=
{h1H3:'年审',span1:'高效、快速',p1:'让你高枕无忧',ListSrc1:'img/daiban1.png',
h2H3:'保险',span2:'安全、保障',p2:'做到最好,为你安心',ListSrc2:'img/daiban2.png',
h3H3:'绿标',span3:'正宗、效率',p3:'让您车畅通无阻',ListSrc3:'img/daiban3.png',
h4H3:'过户',span4:'专业、安全',p4:'让您放心、省心',ListSrc4:'img/daiban4.png',
h5H3:'换证服务预订',span5:'',p5:'',ListSrc5:'img/daiban5.png'};
$scope.aAlert=function(){
$ionicPopup.alert({title:"<h3>温馨提示</h3>",template:'此功能暂未开通',cssClass:'AgentClass',buttons:[{text:'取消'}]});
}
})
//支付
.controller('pagCtr',function($scope,$http,$rootScope,$timeout,$ionicLoading,FloatStr,$stateParams,$state,$ionicPopup){
//获取用余额
$timeout(function(){
$http.get("http://" + $scope.url + "/index.php/Client/Order/get_account?userid="+$rootScope.user.id)
.success(function(res){
$scope.account_yue=res[0].account;
})
},10);
var order_number=$stateParams.order_number;
$http.get("http://" + linkUrl +
"/index.php/Client/OneKeyOrder/payrightnow?order_number=" +order_number)
.success(function(res) {
if(res.real_price!=null){
price=res.real_price;
}else{
price=res.estimate_price;
}
$scope.items=[
{firtname:'订单号',secondname:res.order_number},
{firtname:'出发地',secondname:res.bespoke_address},
{firtname:'目的地',secondname:res.destination},
{firtname:'路程',secondname:res.distance+'公里'},
{firtname:'车费',secondname:price+'元'}
];
//$scope.pags=[
// {firtname:'余额支付',secondname:'可用余额35元',PagSrc:'img/yuer.png'},
// {firtname:'微信支付',secondname:'',PagSrc:'img/weixin.jpg'},
// {firtname:'支付宝支付',secondname:'',PagSrc:'img/aplay.jpg'},
// {firtname:'网银支付',secondname:'',PagSrc:'img/unionPay.jpg'}
//];
});
$scope.yuerPay="余额支付";
$scope.wechatPay="微信支付";
$scope.alipay="支付宝支付";
$scope.unionPay="网银支付";
$scope.pageForm={};
$scope.immediatePay=function(pageForm){
//console.log(pageForm)
if(pageForm.pay.$untouched){
$ionicLoading.show({
template:'请选择支付方式',
noBackdrop:true,
duration:1500
});
pageForm.valid=false;
}else {
pageForm.valid=true;
}
if(pageForm.valid){
//支付方式
var pay_type;
//订单号
var out_trade_no=$scope.items[0].secondname;
//价格
var price=parseInt($scope.items[4].secondname);
//使用余额支付
if (pageForm.pay==$scope.yuerPay){
pay_type="account_yue";
//保存支付信息
$http({
url:'http://'+$scope.url+'/index.php/Client/Order/orderpay',
method:'POST',
data:{
'userid':$rootScope.user.id,
'order_number':out_trade_no,
'pay_type':pay_type,
'money':price
}
}).success(function(res){
$ionicLoading.show({
template:res.msg,
noBackdrop:true,
duration:1500
});
if(res.result=="success"){
$state.go('OneKeyOder');
}
// if(){
// //支付成功。发送短信
// $http({
// url:'http://'+$scope.url+'/index.php/Client/DuanXin/payDuan',
// method:'POST',
// data:{
// 'phone':$rootScope.user.phone
// }
// }).success(function(res){
// console.log("短信发送成功");
// $state.go('OneKeyOder');