orderDetail.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. var app = getApp()
  2. Page({
  3. data: {
  4. detail: [], //订单详情
  5. polyline: [], //折线
  6. longitude: 113.3245211,
  7. latitude: 23.10229,
  8. markers: [] //标记点
  9. },
  10. onLoad: function(options) {
  11. let self = this;
  12. // var url = '';
  13. // if(options.index==1){
  14. // url = 'order/detail'
  15. // }
  16. // if(options.index==2){
  17. // url = 'orderRent/detail'
  18. // }
  19. // app.request(url+'?order_id=' + options.id, '', 'GET').then(res => {
  20. app.request('order/detail?order_id=' + options.id, '', 'GET').then(res => {
  21. console.log(res, '订单详情');
  22. self.setData({
  23. detail: res.data
  24. })
  25. if (
  26. res.data.orderLocations.length == 0 &&
  27. res.data.start_location.length == 0 &&
  28. res.data.end_location.length == 0
  29. ) {
  30. wx.showToast({
  31. title: '暂无骑行轨迹~',
  32. icon: 'none'
  33. })
  34. } else {
  35. let points = res.data.wx_orderLocations;
  36. let center = parseInt(points.length / 2);
  37. let obj = {};
  38. obj.points = points;
  39. obj.width = 4;
  40. obj.color = '#18D5B9';
  41. obj.borderWidth = 3;
  42. obj.borderColor = '#18D5B9';
  43. self.setData({
  44. polyline: self.data.polyline.concat(obj),
  45. });
  46. console.log(self.data.polyline, '折线')
  47. //添加开始结束点
  48. if (points.length > 0) {
  49. var maker = [];
  50. maker = maker.concat(points[0]);
  51. maker = maker.concat(points[points.length - 1])
  52. for (var i = 0; i < maker.length; i++) {
  53. maker[i].width = 32;
  54. maker[i].height = 32;
  55. maker[i].zIndex = 1111;
  56. }
  57. //在地图上显示两个坐标
  58. maker[0].iconPath = 'http://resource.weilaibike.com/common/start-location-mark.png'
  59. maker[1].iconPath = 'http://resource.weilaibike.com/common/end-location-mark.png'
  60. self.setData({
  61. markers: maker,
  62. longitude: points[center].longitude,
  63. latitude: points[center].latitude
  64. })
  65. }
  66. }
  67. })
  68. },
  69. //点击手机号拨打用户电话
  70. phoneCall(e) {
  71. console.log(33333)
  72. console.log(e.currentTarget.dataset.phone)
  73. wx.makePhoneCall({
  74. phoneNumber: e.currentTarget.dataset.phone
  75. })
  76. },
  77. onReady: function() {
  78. },
  79. onShow: function() {
  80. },
  81. onHide: function() {
  82. },
  83. onUnload: function() {
  84. },
  85. onPullDownRefresh: function() {
  86. },
  87. onReachBottom: function() {
  88. },
  89. onShareAppMessage: function() {
  90. }
  91. })