loading.js 566 B

1234567891011121314151617181920212223242526272829
  1. function startLoading () {
  2. uni.showLoading({
  3. mask:true
  4. })
  5. }
  6. // 关闭loading事件
  7. function endLoading () {
  8. uni.hideLoading()
  9. }
  10. // 默认状态
  11. let needLoadingRequestCount = 0
  12. // 开启loading
  13. export function showFullScreenLoading() {
  14. if (needLoadingRequestCount === 0) {
  15. startLoading()
  16. }
  17. needLoadingRequestCount++
  18. }
  19. // 取消loading
  20. export function tryHideFullScreenLoading() {
  21. if (needLoadingRequestCount <= 0) return
  22. needLoadingRequestCount--
  23. if (needLoadingRequestCount === 0) {
  24. endLoading()
  25. }
  26. }