移动端长按,点击,滑动问题解决

var ismoved = false;
        function longTouch() {
            $(".equipment").on("touchmove", function (event) {
                // event.preventDefault()
                ismoved = true;
            });
            $(".equipment").on("touchstart", function (event) {
                if (ismoved === false) {
                    lastTime = new Date().getTime();
                    // event.preventDefault();//阻止触摸时浏览器的缩放、滚动条滚动
                    clearTimeout(timeout);
                    state = 0;
                    timeout = setTimeout(function () {
                        state = 1;
                    }, 1000);
                    // event.returnValue = true;
                }
            });

            $(".equipment").on("touchend", function (event) {
                if (ismoved === false) {
                    // event.preventDefault();//阻止触摸时浏览器的缩放、滚动条滚动
                    clearTimeout(timeout);
                    var delId = $(this).attr('deviceid');
                    nowTime = new Date().getTime();
                    var timeLength = nowTime - lastTime;

                    if (timeLength > 1000) {
                        layer.msg('<span style="height:60px;">是否删除该设备?<span>', {
                            area: ['60%', '80px'],
                            time: 22220000,
                            shade: 0.3,
                            btn: ['是', '否'],
                            yes: function () {
                                $.ajax({
                                    url: common.baseUrl + 'product/industry/canceldevicejoin',
                                    type: 'post',
                                    contentType: 'application/json',
                                    dataType: 'json',
                                    data: JSON.stringify(
                                        common.getSign({
                                            pageIndex: 0,
                                            pageSize: 10,
                                            token: localStorage.getItem('token'),
                                            timestamp: +new Date(),
                                            deviceId: delId
                                        })
                                    ),
                                    success: function (res) {
                                        if (res && res.code === "00000") {
                                            // layer.msg('<span style="fontSize:16px;">删除设备成功!</span>', {
                                            //     area: ['60%', '80px'],
                                            //     time: 30000000000000
                                            // })
                                            setTimeout(function () {
                                                location.reload();
                                            }, 1000)

                                        } else {
                                            layer.msg(res.msg);
                                        }
                                    },
                                    error: function () {
                                        layer.msg('删除设备失败');
                                    }
                                });
                            }
                        })
                    }
                    if (timeLength <= 1000) {
                        var deviceId = $(this).attr('deviceId')
                        var deviceModel = $(this).attr('deviceModel')
                        var deviceName = $(this).attr('deviceName')
                        var categoryId = categoryIdObj[deviceModel]
                        if ($(this).attr('deviceModel') === "screen") {
                            if ($(this).attr('status') === "0") {
                                window.location.href = './intelligent-display.html' + '?screenid=' + deviceId;
                            }
                            else {
                                window.location.href = './select-sence.html' + '?screenid=' + deviceId;
                            }
                        }
                        if ($(this).attr('deviceModel') === "waterenv") {
                            window.location.href = './water-equipment.html' + '?deviceId=' + deviceId + '&deviceName=' + deviceName + '&deviceModel=' + deviceModel;
                        }
                        if ($(this).attr('deviceModel') === "ecotope") {
                            window.location.href = './meteorological-equipment.html' + '?deviceId=' + deviceId + '&deviceName=' + deviceName + '&deviceModel=' + deviceModel;
                        }
                        if ($(this).attr('deviceModel') === "roomenv") {
                            window.location.href = './water-equipment.html' + '?deviceId=' + deviceId + '&deviceName=' + deviceName + '&deviceModel=' + deviceModel;
                        }
                        if ($(this).attr('deviceModel') === "gateway") {
                            window.location.href = './water-equipment.html' + '?deviceId=' + deviceId + '&deviceName=' + deviceName + '&deviceModel=' + deviceModel;
                        }
                    }
                    state = 0;
                    // event.returnValue = true;
                }
                ismoved = false;
            });
        }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

风里有诗句哈

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值