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

3 weeks ago
  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. }
  19. // 新增:等待馆藏名称 fondsName
  20. export function waitFondsNameReady(){
  21. return new Promise((resolve)=>{
  22. const app = getApp()
  23. if(app.globalData.fondsName){
  24. return resolve(app.globalData.fondsName)
  25. }
  26. let count = 0
  27. const timer = setInterval(()=>{
  28. count++
  29. if(app.globalData.fondsName || count>30){
  30. clearInterval(timer)
  31. resolve(app.globalData.fondsName || '')
  32. }
  33. },100)
  34. })
  35. }