// 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) }) }