功能:重建指尖管理师规划系统
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* Purpose: activeLoadingCount supports loading.js by holding or executing the active loading count page or API role.
|
||||
* Usage: import, call, read, or update this let from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
let activeLoadingCount = 0
|
||||
|
||||
/**
|
||||
* Purpose: showLoading supports loading.js by holding or executing the show loading page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function showLoading(options) {
|
||||
const config = options || {}
|
||||
activeLoadingCount += 1
|
||||
|
||||
if (activeLoadingCount > 1) {
|
||||
return
|
||||
}
|
||||
|
||||
wx.showLoading({
|
||||
title: config.title || '加载中',
|
||||
mask: config.mask !== false
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: hideLoading supports loading.js by holding or executing the hide loading page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function hideLoading() {
|
||||
activeLoadingCount = Math.max(0, activeLoadingCount - 1)
|
||||
|
||||
if (activeLoadingCount > 0) {
|
||||
return
|
||||
}
|
||||
|
||||
wx.hideLoading({
|
||||
fail() {}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: resetLoading supports loading.js by holding or executing the reset loading page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function resetLoading() {
|
||||
activeLoadingCount = 0
|
||||
wx.hideLoading({
|
||||
fail() {}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: runWithLoading supports loading.js by holding or executing the run with loading page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function runWithLoading(task, options) {
|
||||
showLoading(options)
|
||||
|
||||
return Promise.resolve()
|
||||
.then(() => task())
|
||||
.finally(() => {
|
||||
hideLoading()
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
showLoading,
|
||||
hideLoading,
|
||||
resetLoading,
|
||||
runWithLoading
|
||||
}
|
||||
Reference in New Issue
Block a user