图书馆小程序
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.

18 lines
463 B

  1. // utils/global.js
  2. export function waitLibcodeReady(){
  3. return new Promise((resolve)=>{
  4. const app = getApp()
  5. if(app.globalData.libcode){
  6. return resolve(app.globalData.libcode)
  7. }
  8. // 轮询等待,最多3秒
  9. let count = 0
  10. const timer = setInterval(()=>{
  11. count++
  12. if(app.globalData.libcode || count>30){
  13. clearInterval(timer)
  14. resolve(app.globalData.libcode || '')
  15. }
  16. },100)
  17. })
  18. }