123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- var app = getApp()
- Page({
- data: {
- detail: [], //订单详情
- polyline: [], //折线
- longitude: 113.3245211,
- latitude: 23.10229,
- markers: [] //标记点
- },
- onLoad: function(options) {
- wx.showLoading({
- title: '加载中...',
- })
- 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 => { //普通订单和日租订单
- wx.hideLoading();
- 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.bike.hanyiyun.com/common/start-location-mark.png'
- maker[1].iconPath = 'http://resource.bike.hanyiyun.com/common/end-location-mark.png'
- self.setData({
- markers: maker,
- longitude: points[center].longitude,
- latitude: points[center].latitude
- })
- }
- }
- })
- },
- //点击手机号拨打用户电话
- phoneCall(e) {
- wx.makePhoneCall({
- phoneNumber: e.currentTarget.dataset.phone
- })
- },
- })
|