function throttle(fn, interval) {
var enterTime = 0;
var gapTime = interval || 2000;
return function () {
var context = this;
var backTime = new Date();
if (backTime - enterTime > gapTime) {
fn.call(context, arguments);
enterTime = backTime;
}
};
}
function debounce(fn, interval) {
var timer;
var gapTime = interval || 2000;
return function () {
clearTimeout(timer);
var context = this;
var args = arguments;
timer = setTimeout(function () {
fn.call(context, args);
}, gapTime);
};
}
module.exports = {
throttle,
debounce
}
const { throttle } = require("../../utils/util");
submit: throttle(async function () {
let { data } = await api.addOrder(form);
wx.showToast({ icon: "none", title: "预订成功" });
}),