小程序长按事件

手指长按触发事件;
/**
* 手指触摸事件
*/
touchStart: function (e) {
var that = this;
that.setData({
touchStart: e.timeStamp
})
},
touchEnd: function (e) {
var that = this;
that.setData({
touchEnd: e.timeStamp
})
},
pressTap: function () {
var that = this;
var touchTime = that.data.touchEnd - that.data.touchStart;
if (touchTime > 3000) { //自定义长按时长,单位为ms
if (that.data.isManager == true) {
if (that.data.status == 1){
wx.showModal({
title: '提示',
content: '你将切换到预览模式!',
success: function (res) {
if (res.confirm) {
that.setData({ status: 0 })
that.getHouseList( 0);
}
}
})
} else{
wx.showModal({
title: '提示',
content: '你将切换到正常模式!',
success: function (res) {
if (res.confirm) {
that.setData({ status: 1 })
that.getHouseList( 1);
}
}
})
}
}
}
},

猜你喜欢

转载自blog.csdn.net/wwj791859814/article/details/80193320