orderDetail.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. wx.showLoading({
  12. title: '加载中...',
  13. })
  14. let self = this;
  15. var url = '';
  16. if(options.index==1){
  17. url = 'order/detail'
  18. }
  19. if(options.index==2){
  20. url = 'orderRent/detail'
  21. }
  22. app.request(url+'?order_id=' + options.id, '', 'GET').then(res => { //普通订单和日租订单
  23. wx.hideLoading();
  24. console.log(res, '订单详情');
  25. self.setData({
  26. detail: res.data
  27. })
  28. if (
  29. res.data.orderLocations.length == 0 &&
  30. res.data.start_location.length == 0 &&
  31. res.data.end_location.length == 0
  32. ) {
  33. wx.showToast({
  34. title: '暂无骑行轨迹~',
  35. icon: 'none'
  36. })
  37. } else {
  38. let points = res.data.wx_orderLocations;
  39. let center = parseInt(points.length / 2);
  40. let obj = {};
  41. obj.points = points;
  42. obj.width = 4;
  43. obj.color = '#18D5B9';
  44. obj.borderWidth = 3;
  45. obj.borderColor = '#18D5B9';
  46. self.setData({
  47. polyline: self.data.polyline.concat(obj),
  48. });
  49. console.log(self.data.polyline, '折线')
  50. //添加开始结束点
  51. if (points.length > 0) {
  52. var maker = [];
  53. maker = maker.concat(points[0]);
  54. maker = maker.concat(points[points.length - 1])
  55. for (var i = 0; i < maker.length; i++) {
  56. maker[i].width = 32;
  57. maker[i].height = 32;
  58. maker[i].zIndex = 1111;
  59. }
  60. //在地图上显示两个坐标
  61. maker[0].iconPath = 'http://resource.bike.hanyiyun.com/common/start-location-mark.png'
  62. maker[1].iconPath = 'http://resource.bike.hanyiyun.com/common/end-location-mark.png'
  63. self.setData({
  64. markers: maker,
  65. longitude: points[center].longitude,
  66. latitude: points[center].latitude
  67. })
  68. }
  69. }
  70. })
  71. },
  72. //点击手机号拨打用户电话
  73. phoneCall(e) {
  74. wx.makePhoneCall({
  75. phoneNumber: e.currentTarget.dataset.phone
  76. })
  77. },
  78. })