cancel-order-dialog.js 1.02 KB
Component({
  properties: {
    showConfirm: {
      type: Boolean,
      value: true
    }
  },
  data: {
    slideLeft: 0,
    startX: 0,
    hideSlide: true,
    hideTip: false,
    containerWidth: 0
  },
  methods: {
    closeSlide: function() {
      this.setData({
        hideSlide: true
      });
    },
    touchStart: function (e) {
      this.data.startX = e.touches[0].clientX;
    },
    touchMove: function (e) {
      let currentX = e.touches[0].clientX;

      if (currentX - this.data.startX < 0 || this.data.complete) {
        return;
      }
      this.setData({
        hideTip: true,
        slideLeft: currentX - this.data.startX
      })
    },
    touchEnd: function (e) {
      if (!this.data.complete) {
        this.setData({
          slideLeft: 0,
          hideTip: false
        });
      }
    },
    confirm: function() {
      this.setData({
        showConfirm: false,
        hideSlide: false
      });
    },
    keep: function () {
      this.setData({
        showConfirm: false
      });
    }
  }
});