var app = getApp() Page({ data: { detail: [], //订单详情 polyline: [], //折线 longitude: 113.3245211, latitude: 23.10229, markers: [] //标记点 }, onLoad: function(options) { let self = this; // var url = ''; // if(options.index==1){ // url = 'order/detail' // } // if(options.index==2){ // url = 'orderRent/detail' // } // app.request(url+'?order_id=' + options.id, '', 'GET').then(res => { app.request('order/detail?order_id=' + options.id, '', 'GET').then(res => { console.log(res, '订单详情'); self.setData({ detail: res.data }) if ( res.data.orderLocations.length == 0 && res.data.start_location.length == 0 && res.data.end_location.length == 0 ) { wx.showToast({ title: '暂无骑行轨迹~', icon: 'none' }) } else { let points = res.data.wx_orderLocations; let center = parseInt(points.length / 2); let obj = {}; obj.points = points; obj.width = 4; obj.color = '#18D5B9'; obj.borderWidth = 3; obj.borderColor = '#18D5B9'; self.setData({ polyline: self.data.polyline.concat(obj), }); console.log(self.data.polyline, '折线') //添加开始结束点 if (points.length > 0) { var maker = []; maker = maker.concat(points[0]); maker = maker.concat(points[points.length - 1]) for (var i = 0; i < maker.length; i++) { maker[i].width = 32; maker[i].height = 32; maker[i].zIndex = 1111; } //在地图上显示两个坐标 maker[0].iconPath = 'http://resource.weilaibike.com/common/start-location-mark.png' maker[1].iconPath = 'http://resource.weilaibike.com/common/end-location-mark.png' self.setData({ markers: maker, longitude: points[center].longitude, latitude: points[center].latitude }) } } }) }, //点击手机号拨打用户电话 phoneCall(e) { console.log(33333) console.log(e.currentTarget.dataset.phone) wx.makePhoneCall({ phoneNumber: e.currentTarget.dataset.phone }) }, onReady: function() { }, onShow: function() { }, onHide: function() { }, onUnload: function() { }, onPullDownRefresh: function() { }, onReachBottom: function() { }, onShareAppMessage: function() { } })