-
zhangwei
2025-03-14 6e961fafc0f921d575772a3c89f2c5cad28c270d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// 本文件由FirstUI授权予四川政采招投标咨询有限公司(会员ID: 1 63,营业执照号: 915 10   13    13  3 2 0 06 19  3K)专用,请尊重知识产权,勿私下传播,违者追究法律责任。
// #ifdef APP-VUE|| MP-WEIXIN || H5
export default {
    data() {
        return {
            isShow: false,
            isDisabled: false,
            thresholdVal: 30
        }
    },
    watch: {
        show(newVal) {
            this.isShow = this.show ? 'right' : 'none'
        },
        disabled(val) {
            this.isDisabled = this.disabled
        },
        threshold(val) {
            this.thresholdVal = Number(this.threshold)
        }
    },
    created() {
        this.group = this.getParent()
        if (this.group.children !== undefined) {
            this.group.children.push(this)
        }
    },
    mounted() {
        this.$nextTick(() => {
            setTimeout(() => {
                this.isShow = this.show ? 'right' : 'none'
                this.isDisabled = this.disabled
                this.thresholdVal = Number(this.threshold)
            }, 10)
        })
    },
    methods: {
        closeSwipe(e) {
            if (!this.autoClose) return
            this.group && this.group.closeAuto(this)
        },
        change(e) {
            const isOpen = e.open === 'right'
            this.$emit('change', {
                isOpen: isOpen,
                param: this.param
            })
            if (this.isShow !== e.open) {
                this.isShow = e.open
            }
        },
        isPC() {
            var userAgentInfo = navigator.userAgent;
            var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
            var flag = true;
            for (let v = 0; v < Agents.length - 1; v++) {
                if (userAgentInfo.indexOf(Agents[v]) > 0) {
                    flag = false;
                    break;
                }
            }
            return flag;
        },
        //解决 ios 13 点击区域错位的问题
        appTouchStart(e) {
            // #ifdef H5
            if (this.isPC()) return
            // #endif
            const {
                clientX
            } = e.changedTouches[0]
            this.clientX = clientX
            this.timestamp = new Date().getTime()
        },
        appTouchEnd(e, index, item) {
            // #ifdef H5
            if (this.isPC()) return
            // #endif
            const {
                clientX
            } = e.changedTouches[0]
            let diff = Math.abs(this.clientX - clientX)
            let time = (new Date().getTime()) - this.timestamp
            if (diff < 40 && time < 300) {
                this.$emit('click', {
                    index,
                    item,
                    param: this.param
                })
            }
        },
        handleClick(index, item) {
            // #ifdef H5
            if (!this.isPC()) return
            this.$emit('click', {
                index,
                item,
                param: this.param
            })
            // #endif
        }
    }
}
 
// #endif
// #ifndef APP-VUE|| MP-WEIXIN || H5
export default {}
// #endif