gaoluyang
3 天以前 92230c9a97dc9ce9df3313d11d26999c04bb6b26
src/uni_modules/uni-swipe-action/components/uni-swipe-action-item/mpwxs.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,83 @@
let mpMixins = {}
let is_pc = null
// #ifdef H5
import {
   isPC
} from "./isPC"
is_pc = isPC()
// #endif
// #ifdef APP-VUE|| MP-WEIXIN || H5
mpMixins = {
   data() {
      return {
         is_show: 'none'
      }
   },
   watch: {
      show(newVal) {
         this.is_show = this.show
      }
   },
   created() {
      this.swipeaction = this.getSwipeAction()
      if (this.swipeaction.children !== undefined) {
         this.swipeaction.children.push(this)
      }
   },
   mounted() {
      this.is_show = this.show
   },
   methods: {
      // wxs ä¸­è°ƒç”¨
      closeSwipe(e) {
         if (!this.autoClose) return
         this.swipeaction.closeOther(this)
      },
      change(e) {
         this.$emit('change', e.open)
         if (this.is_show !== e.open) {
            this.is_show = e.open
         }
      },
      appTouchStart(e) {
         if (is_pc) return
         const {
            clientX
         } = e.changedTouches[0]
         this.clientX = clientX
         this.timestamp = new Date().getTime()
      },
      appTouchEnd(e, index, item, position) {
         if (is_pc) return
         const {
            clientX
         } = e.changedTouches[0]
         // fixed by xxxx æ¨¡æ‹Ÿç‚¹å‡»äº‹ä»¶ï¼Œè§£å†³ ios 13 ç‚¹å‡»åŒºåŸŸé”™ä½çš„问题
         let diff = Math.abs(this.clientX - clientX)
         let time = (new Date().getTime()) - this.timestamp
         if (diff < 40 && time < 300) {
            this.$emit('click', {
               content: item,
               index,
               position
            })
         }
      },
      onClickForPC(index, item, position) {
         if (!is_pc) return
         // #ifdef H5
         this.$emit('click', {
            content: item,
            index,
            position
         })
         // #endif
      }
   }
}
// #endif
export default mpMixins