App({
onLaunch: function () {
this.globalData = {
lastClickTime: 0,
};
},
handleClick(time, result) {
const currentTime = new Date().getTime();
const minInterval = time;
var lastClickTime = this.globalData.lastClickTime;
if (currentTime - lastClickTime > minInterval) {
this.globalData.lastClickTime = currentTime;
console.log('执行点击操作');
result(true);
} else {
console.log('请勿重复点击');
result(false);
}
},
})
var app = getApp()
Page({
data: {
},
onLoad(options) {
},
fun(){
app.handleClick(1000, function (status) {
if (status) {
} else {
wx.showToast({
title: '操作太快了',
icon: 'none'
})
}
})
},
})