default.js 784 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // 日期时间
  2. import {
  3. formatDateTime,
  4. formatDate,
  5. parseTime
  6. } from "@/unit/datetime.js"
  7. import {
  8. add,
  9. ride
  10. } from "@/unit/Math.js"
  11. /*
  12. 防抖
  13. fn : 回调函数 传进来的是正真的业务逻辑
  14. delay : 延时时间
  15. */
  16. const antiShake = function(fn, delay) {
  17. let time = null; //time用来控制事件的触发
  18. return function() {
  19. if (time !== null) {
  20. clearTimeout(time);
  21. }
  22. time = setTimeout(() => {
  23. fn.call(this);
  24. //利用call(),让this的指针从指向window 转成指向input
  25. }, delay)
  26. }
  27. }
  28. const hideBoard = function() {
  29. var interval = setInterval(function() {
  30. uni.hideKeyboard();
  31. }, 100);
  32. setTimeout(() => {
  33. clearInterval(interval);
  34. }, 2000);
  35. };
  36. export {
  37. antiShake,
  38. hideBoard,
  39. formatDateTime,
  40. formatDate,
  41. parseTime,
  42. add,
  43. ride
  44. }