// pages/details/details.js

import http from '../../base/httputil'

Page({


  onLoad(e) {
    this.data.busEnterpriseId = e.busEnterpriseId
    this.getEnterpriseDetails()
  },

  data: {
    busEnterpriseId: null,
    enterpriseDetails: null,

    //店铺经纬度
    latitude: 43.8691319,
    longitude: 125.3504459,
    //标记点
    markers: [{
      id: 0,
      name: "编程小石头",
      address: "长春首佳科技有限公司",
      latitude: 43.8691319,
      longitude: 125.3504459,
      width: 35,
      height: 50
    }]

  },


  getEnterpriseDetails() {
    let obj = new Object();
    obj.busEnterpriseId = this.data.busEnterpriseId
    http.post("/system/AppEnterpriseController/getEnterpriseDetails", obj, this.getEnterpriseDetailsSuccess)
  },
  getEnterpriseDetailsSuccess(res) {
    console.log(res)
    this.setData({
      enterpriseDetails: res.enterpriseDetails,
      latitude: res.enterpriseDetails.latitude,
      longitude: res.enterpriseDetails.longitude,
      markers: [{
        id: res.enterpriseDetails.busEnterpriseId,
        name: res.enterpriseDetails.businessName,
        address: res.enterpriseDetails.businessAddress,
        latitude: res.enterpriseDetails.latitude,
        longitude: res.enterpriseDetails.longitude,
        width: 35,
        height: 50
      }]
    })
  },







  //拨打电话
  Call() {
    wx.makePhoneCall({
      phoneNumber: '17649876533'
    })
  },
  //导航
  navRoad(event) {
    console.log(event)
    wx.getLocation({ //获取当前经纬度
      type: 'wgs84', //返回可以用于wx.openLocation的经纬度，
      success: function (res) {
        wx.openLocation({ //​使用微信内置地图查看位置。
          latitude: event.currentTarget.dataset.marker.latitude, //要去的纬度-地址
          longitude: event.currentTarget.dataset.marker.longitude, //要去的经度-地址
          name: event.currentTarget.dataset.marker.name,
          address: event.currentTarget.dataset.marker.address
        })
      }
    })
  },



  //-------跳转
  //巡检跳转
  bindViewXunJian() {
    wx.navigateTo({
      url: '../xunjian/xunjian?busEnterpriseId='+this.data.busEnterpriseId,
    })
  },
  //巡检跳转
  bindViewXunChaJiLu() {
    wx.navigateTo({
      url: '../xunchajilu/xunchajilu?busEnterpriseId='
      +this.data.enterpriseDetails.busEnterpriseId
      +"&businessName="+this.data.enterpriseDetails.businessName,
    })
  },
  //企业详情
  bindViewQiYeXiangQingTable() {
    wx.navigateTo({
      url: '../qiyexqtable/qiyexqtable?busEnterpriseId='+this.data.busEnterpriseId,
    })
  },













})