Component({
  data: {},
  properties: {
    // 抽屉高度
    height: {
      type: String,
      value: "",
    },
    drawerType: {
      type: String,
      value: "",
    },
    //抽屉显示隐藏
    show: {
      type: Boolean,
      value: false
    },
    titleText: {
      type: String,
      value: ''
    },
    // 是否需要显示tabbar
    hideTabbar: {
      type: Boolean,
      value: false
    },
    cancerShow: {
      type: Boolean,
      value: true
    },
    // 
    touchClose: {
      type: Boolean,
      value: true
    },
    color: {
      type: String,
      value: '#fff'
    },
  },
  methods: {
    /**
    * 阻止滑动穿透
    *
    *
    */
    modalMove () {
      console.log(this.data.color);
      return false;
    },
    // 触摸开始事件
    handletouchtart: function (event) {
      this.data.lastX = event.touches[0].pageX;
      this.data.lastY = event.touches[0].pageY;
    },
    filterTouchStart (event) {
      this.handletouchtart(event);
    },
    filterTouchMove (event) {
      let tx = this.handletouchmove(event);
      if (this.data.touchClose) {
        if (tx.ty > 100) {
          this.hideLeft();

        }
      } else {
        return false
      }
    },
    /**
    * 页面滑动事件监听
    *
    *
    */
    handletouchmove: function (event) {
      let that = this;
      var currentX = event.touches[0].pageX;
      var currentY = event.touches[0].pageY;
      var tx = currentX - this.data.lastX;
      var ty = currentY - this.data.lastY;
      var text = "";
      //左右方向滑动
      if (Math.abs(tx) > Math.abs(ty)) {
        return {
          tx,
        };
      }
      //上下方向滑动
      else {
        return {
          ty,
        };
      }
    },
    hideLeft () {
      // this.data.show = false
      // this.setData({
      //   show: false
      // })
      var eventDetail = {
        type: this.data.drawerType
      };
      this.triggerEvent("hidedrawer", eventDetail);

      if (this.data.hideTabbar) {
        console.log('this.getTabBar()',this.getTabBar());
        setTimeout(() => {
          this.getTabBar().setData({
            isShow: true,
          });
        }, 200);
      }

    },

  }
})