trip_detail.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. // pages/trip/trip.js
  2. var app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. windowHeight:'',
  9. height:'',
  10. order:'',
  11. date:[],
  12. markers:[],
  13. polyline:[],
  14. latitude:'',
  15. longitude:'',
  16. url:'',
  17. index:'',
  18. img:app.globalData.imgUrl
  19. },
  20. onLoad: function (options) {
  21. var that = this;
  22. console.log(options,'传值')
  23. let order_no=options.order_no
  24. // my.getSystemInfo({
  25. // success: function (res) {
  26. // console.log(res.windowHeight);
  27. // that.setData({ windowHeight: res.windowHeight})
  28. // }
  29. // })
  30. // this.setData({order:options.order})
  31. // if(options.index){
  32. // if (options.index == 0) {
  33. // that.setData({
  34. // url : '/order?order_no='
  35. // })
  36. // }
  37. // if (options.index == 1) {
  38. // that.setData({
  39. // url : '/rent/order?no='
  40. // })
  41. // }
  42. // this.setData({index:options.index})
  43. // }
  44. // if(options.index){
  45. // if (options.index == 'true') {
  46. // that.setData({
  47. // url : '/order?order_no='
  48. // })
  49. // this.setData({index:0})
  50. // }
  51. // if (options.index == 'false') {
  52. // that.setData({
  53. // url : '/rent/order?no='
  54. // })
  55. // this.setData({index:1})
  56. // }
  57. // }
  58. // var query = my.createSelectorQuery();
  59. // query.select('.box').boundingClientRect();
  60. // query.exec(function (res) {
  61. // console.log(res)
  62. // console.log(res[0].height)
  63. // that.setData({ height: res[0].height });
  64. // })
  65. // my.getLocation({
  66. // type:'gcj02',
  67. // success: function(res) {
  68. // var latitude = res.latitude
  69. // var longitude = res.longitude
  70. // that.setData({ longitude: longitude, latitude: latitude })
  71. // },
  72. // })
  73. // this.load();
  74. this.getTrack(order_no); //获取行车轨迹及订单信息
  75. },
  76. // 获取行车轨迹及订单信息
  77. getTrack(order_no){
  78. var that = this;
  79. my.showLoading({
  80. content: '加载中...',
  81. })
  82. console.log(that.data.url)
  83. app.request('/order?order_no=' + order_no+'&include=locations','','GET').then(res=>{
  84. console.log(res)
  85. if(res.status == 200){
  86. my.hideLoading()
  87. that.setData({ date: res.data });
  88. let points = res.data.locations.data;
  89. var center = parseInt(points.length/2)
  90. var obj = {};
  91. obj.points = points;
  92. obj.width = 2;
  93. obj.color = '#f8c700';
  94. obj.borderWidth = 1;
  95. obj.borderColor = '#f8c700';
  96. that.setData({ polyline: that.data.polyline.concat(obj) })
  97. if (points.length>0){
  98. var maker = [];
  99. maker = maker.concat(points[0]);
  100. maker = maker.concat(points[points.length - 1])
  101. for (var i = 0; i < maker.length; i++) {
  102. maker[i].width =32;
  103. maker[i].height = 32;
  104. maker[i].zIndex = 1111;
  105. }
  106. //在地图上显示两个坐标
  107. maker[0].iconPath = 'http://resource.bike.hanyiyun.com/weapp/start1.png'
  108. maker[1].iconPath = 'http://resource.bike.hanyiyun.com/weapp/end1.png'
  109. that.setData({ markers: maker, longitude: points[center].longitude, latitude: points[center].latitude })
  110. } else {
  111. my.getLocation({
  112. type: 'gcj02',
  113. success: function (res) {
  114. var latitude = res.latitude
  115. var longitude = res.longitude
  116. that.setData({ longitude: longitude, latitude: latitude })
  117. },
  118. })
  119. }
  120. }
  121. })
  122. },
  123. //计费规则
  124. chargeRule:function(){
  125. my.navigateTo({
  126. url:'/pages/charge_rule/charge_rule',
  127. })
  128. },
  129. //不认可收费
  130. noAgree:function(){
  131. my.makePhoneCall({
  132. number:my.getStorageSync({'key':'home'}).data.customer_service_phone,
  133. })
  134. },
  135. onReady: function () {
  136. },
  137. onShow: function () {
  138. },
  139. onHide: function () {
  140. },
  141. onUnload: function () {
  142. },
  143. onPullDownRefresh: function () {
  144. },
  145. onReachBottom: function () {
  146. },
  147. onShareAppMessage: function () {
  148. },
  149. })