var location = require("../../../../mybehaviors/location/location");
Component({
  behaviors: [location],
  properties: {
    params: {
      type: null
    },
    data: {
      type: null
    },
    is_url: {
      type: null
    }
  },
  data: {
    address: "",
    point: {
      lat: '',
      lng: ''
    },
    city: ""
  }, // 私有数据，可用于模板渲染

  lifetimes: {
    // 生命周期函数，可以为函数，或一个在methods段中定义的方法名
    attached() {

    },
    moved() {},
    detached() {},
  },

  // 生命周期函数，可以为函数，或一个在methods段中定义的方法名
  attached() {

  }, // 此处attached的声明会被lifetimes字段中的声明覆盖
  ready() {
    this._getLocation();
  },

  pageLifetimes: {
    // 组件所在页面的生命周期函数
    show() {},
    hide() {},
    resize() {},
  },

  methods: {
    tolocation() {
      if (this.data.data[0].home){
        wx.navigateTo({
          url: '/packageC/o2o/o2oLocation/o2oLocation?tag=home'
        });
      }else if(this.properties.is_url){
        wx.navigateTo({
          url: '/packageC/o2o/o2oLocation/o2oLocation?tag=diy'
        });
      }else{
        wx.navigateTo({
          url: '/packageC/o2o/o2oLocation/o2oLocation'
        });
      }

    },
    tosearch() {
      if (!this.data.city) {
        wx.showToast({
          icon: 'none',
          title: '请先选择城市',
          duration: 1000
        });
        return;
      }
      wx.navigateTo({
        url: '/packageC/o2o/o2oSearch/o2oSearch?city=' + this.data.city + '&point=' + JSON.stringify(this.data.point)
      });
    },
  }
});
