Newer
Older
smart_construction / miniprogram / pages / earth / earth.js
zhout on 27 May 2020 3 KB Initial Commit
// miniprogram/pages/earth/earth.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    show: false,
    windowWidth: 0,
    longitude: 113.324520,
    latitude: 23.099994,
    markers: [{
      id: 0,
      iconPath: "../../images/point.png",
      latitude: 23.099994,
      longitude: 113.324520,
      width: 50,
      height: 50
    }],
    controls: [{
      id: 1,
      iconPath: '../../images/copy.png',
      position: {
        left: 330,
        top: 20,
        width: 30,
        height: 30
      },
      clickable: true
    }, {
      id: 2,
      iconPath: '../../images/write.png',
      position: {
        left: 330,
        top: 60,
        width: 30,
        height: 30
      },
      clickable: true
    }, {
      id: 3,
      iconPath: '../../images/add.png',
      position: {
        left: 330,
        top: 105,
        width: 30,
        height: 30
      },
      clickable: true
    }, {
      id: 4,
      iconPath: '../../images/navigation.png',
      position: {
        left: 330,
        top: 555 - 45,
        width: 30,
        height: 30
      },
      clickable: true
    }, {
      id: 5,
      iconPath: '../../images/gps.png',
      position: {
        left: 10,
        top: 555 - 45,
        width: 30,
        height: 30
      },
      clickable: true
    }, {
      id: 6,
      iconPath: '../../images/aim.png',
      position: {
        left: 10,
        top: 555 - 90,
        width: 30,
        height: 30
      },
      clickable: true
    }]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    wx.getLocation({
      type: "gcj02",
      success: function (res) {
        that.setData({
          latitude: res.latitude,
          longitude: res.longitude,
          markers: [{
            latitude: res.latitude,
            longitude: res.longitude
          }]
        })
      }
    }),
      wx.getSystemInfo({
        success(res) {
          // console.log(res.windowWidth);
          // console.log(res.windowHeight);
          // that.setData({
          //   controls: [{
          //     position:{ 
          //       left: res.windowWidth 
          //     }
          //   }]
          // })
        }
      })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  controltap: function (e) {
    // console.log(e.controlId);
    //进入添加设备页
    if (3 == e.controlId) {
      wx.navigateTo({
        url: '../addDevice/addDevice'
      })
    }else if(2 == e.controlId){
      this.setData({ show: true });
    }
  },
  showPopup() {
    this.setData({ show: true });
  },

  onClose() {
    this.setData({ show: false });
  },
})