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;
});
}