Common.js 684 B

1234567891011121314151617181920212223242526272829
  1. // 处理多次点击
  2. function noMultipleClicks(methods) {
  3. //复制this对象指向当时的this,防止找不到原来的对象
  4. let that = this;
  5. if (that.noClick) {
  6. that.noClick = false;
  7. //点击方法
  8. methods();
  9. setTimeout(function() {
  10. that.noClick = true;
  11. }, 2000)
  12. } else {
  13. uni.$showMsg('正在加载中', 500)
  14. }
  15. }
  16. //获取胶囊位置信息
  17. function getCapsuleSite() {
  18. let res = uni.getMenuButtonBoundingClientRect()
  19. this.capsuleBottom = res.bottom + 5
  20. this.capsuleMiddle = res.left
  21. this.capsuleWidth = res.width
  22. }
  23. //导出并在Main.js中全局注册
  24. export default {
  25. noMultipleClicks, //禁止多次点击
  26. getCapsuleSite, //获取胶囊位置信息
  27. }