You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
926 B
36 lines
926 B
// utils/global.js
|
|
export function waitLibcodeReady(){
|
|
return new Promise((resolve)=>{
|
|
const app = getApp()
|
|
if(app.globalData.libcode){
|
|
return resolve(app.globalData.libcode)
|
|
}
|
|
// 轮询等待,最多3秒
|
|
let count = 0
|
|
const timer = setInterval(()=>{
|
|
count++
|
|
if(app.globalData.libcode || count>30){
|
|
clearInterval(timer)
|
|
resolve(app.globalData.libcode || '')
|
|
}
|
|
},100)
|
|
})
|
|
}
|
|
|
|
// 新增:等待馆藏名称 fondsName
|
|
export function waitFondsNameReady(){
|
|
return new Promise((resolve)=>{
|
|
const app = getApp()
|
|
if(app.globalData.fondsName){
|
|
return resolve(app.globalData.fondsName)
|
|
}
|
|
let count = 0
|
|
const timer = setInterval(()=>{
|
|
count++
|
|
if(app.globalData.fondsName || count>30){
|
|
clearInterval(timer)
|
|
resolve(app.globalData.fondsName || '')
|
|
}
|
|
},100)
|
|
})
|
|
}
|