const { api, mapApi, imgName, getUserInfo, wxLogin, alertTip, authAgainByUser, userLocation } = require('../../lib/util.js')
Page({
  data: {
    markers:[],
    longitude:0,
    latitude: 0,
    controls:[],
    imgLogo: imgName('logo.png'),
    imgToLoc: imgName('toloc.png'),
    title: '展示车:震动报警',
    time:'2018-05-09 18:08:44',
  },
  onLoad(){
    this.mapCtx = wx.createMapContext('myMap')
    let carLoc=wx.getStorageSync('carLocAlarm')
    console.log(carLoc)
    this.setData({
      longitude: Number(carLoc.longitude),
      latitude: Number(carLoc.latitude),
      markers:[{
        latitude: Number(carLoc.latitude),
        longitude: Number(carLoc.longitude),
        iconPath: imgName('location_sucess.png'),
        width:36,
        height:36       
      }],
      title: carLoc.content,
      time: carLoc.msgTime
    })

  },
  focusCar(e){
    this.mapCtx.moveToLocation()
  },
  findCar(){
    let that=this
    wx.openLocation({
      latitude: Number(that.data.latitude),
      longitude: Number(that.data.longitude),
      scale: 28
    })
  },
  onUnload(){
    wx.removeStorageSync('carLocAlarm')
  }
})