// component/shareModal/shareModal.js
const wxService = require('../../utils/wxService')

Component({
  /**
   * 组件的属性列表
   */
  properties: {
    show: { // 显示标识
      type: Boolean,
      value: false
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    shareHight:0
  },
  observers: {
    show() {
      const { show } = this.data
      if (show){
        wxService.nextTick(() => {
          this.getHeightFun();
        })
      }
    }
  
  },
  /**
   * 组件的方法列表
   */
  methods: {
    hidePopup(){
      this.setData({
        show: false
      })
    },
    //获取高度
    getHeightFun(){
      //获取屏幕高度
      let windowHeight = '';
      wx.getSystemInfo({
        success: function (res) {
          console.log(res.windowHeight);
          windowHeight = res.windowHeight
        },
      })
      //获取底部元素高度
      let query = wx.createSelectorQuery().in (this);
        query.select('#bottom-query').boundingClientRect(rect => {
          let height = rect.height;
          console.log(height)
          this.setData({
            shareHight: windowHeight - height + 'px'
          })
        }).exec();
    }
  }
})
