123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- var app = getApp();
- const util = require('../../utils/utils.js');
- Page({
- data: {
- windowHeight:'',
- height:'',
- order:'',
- date:[],
- markers:[],
- polyline:[],
- latitude:'',
- longitude:'',
- url:'',
- index:'',
- img:app.globalData.imgUrl
- },
- onLoad: function (options) {
- var that = this;
- console.log(options)
- wx.getSystemInfo({
- success: function (res) {
- console.log(res.windowHeight);
- that.setData({ windowHeight: res.windowHeight})
- }
- })
- this.setData({order:options.order})
- if(options.index){
- if (options.index == 0) {
- that.setData({
- url : '/order?order_no='
- })
- }
- if (options.index == 1) {
- that.setData({
- url : '/rent/order?no='
- })
- }
- this.setData({index:options.index})
- }
- if(options.index){
- if (options.index == 'true') {
- that.setData({
- url : '/order?order_no='
- })
- this.setData({index:0})
- }
- if (options.index == 'false') {
- that.setData({
- url : '/rent/order?no='
- })
- this.setData({index:1})
- }
- }
- var query = wx.createSelectorQuery();
- query.select('.box').boundingClientRect();
- query.exec(function (res) {
- console.log(res)
- console.log(res[0].height)
- that.setData({ height: res[0].height });
- })
- wx.getLocation({
- type:'gcj02',
- success: function(res) {
- var latitude = res.latitude
- var longitude = res.longitude
- that.setData({ longitude: longitude, latitude: latitude })
- },
- })
- // this.load();
- this.getTrack(); //获取行车轨迹及订单信息
- },
- // 获取行车轨迹及订单信息
- getTrack(){
- var that = this;
- wx.showLoading({
- title: '加载中...',
- })
- console.log(that.data.url)
- app.request(that.data.url + that.data.order+'&include=locations','','GET').then(res=>{
- console.log(res)
- if(res.statusCode == 200){
- wx.hideLoading()
- that.setData({ date: res.data });
- let points = res.data.locations.data;
- var center = parseInt(points.length/2)
- var obj = {};
- obj.points = points;
- obj.width = 4;
- obj.color = '#18D5B9';
- obj.borderWidth = 3;
- obj.borderColor = '#18D5B9';
- that.setData({ polyline: that.data.polyline.concat(obj) })
- 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/weapp/start1.png'
- maker[1].iconPath = 'http://resource.bike.hanyiyun.com/weapp/end1.png'
- that.setData({ markers: maker, longitude: points[center].longitude, latitude: points[center].latitude })
- } else {
- wx.getLocation({
- type: 'gcj02',
- success: function (res) {
- var latitude = res.latitude
- var longitude = res.longitude
- that.setData({ longitude: longitude, latitude: latitude })
- },
- })
- }
- }
- })
- },
- onReady: function () {
- },
- payment: util.throttle(function(){
- //点击去支付
- var url = ''
- if(this.data.index==1){
- url = '&rent=rent'
- }
- wx.navigateTo({
- url: '../payment/payment?order='+this.data.order+url,
- })
- },1000),
- onShow: function () {
- },
- onHide: function () {
- },
- onUnload: function () {
- },
- onPullDownRefresh: function () {
- },
- onReachBottom: function () {
- },
- onShareAppMessage: function () {
-
- }
- })
|