// @ts-nocheck
const systemInfo = wx.getWindowInfo();

Component({
  properties: {
    visible: {
      type: Boolean,
      value: false,
      observer(newVal:any) {
        if (newVal) {
          //先挂载再执行动画
          this.setData({ showSelf: true }, () => {
            setTimeout(() => {
              this.setData({
                popupAnimate: 'show',
                maskAnimate: 'show'
              })
            }, 20)
          })
        } else {
          //先执行动画，不见了再卸载
          this.setData({
            popupAnimate: 'hide',
            maskAnimate: 'hide'
          })
          // 等动画结束再卸载
          setTimeout(() => {
            this.setData({ showSelf: false })
          }, 500) //和transition一致
        }
      }
    }
  },
  data: {
    showSelf: false,
    safeBottom: systemInfo.safeArea.bottom - systemInfo.safeArea.height, //底部的安全距离，避免被返回键挡住了
    popupAnimate: '',
    maskAnimate: ''
  },
  methods: {
    handleClose() {
      this.triggerEvent('close');
    },
    emptyEvent() {
    }
  }
})
