openApp.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. const openApp = function (url) {
  2. const res = uni.getSystemInfoSync()
  3. var ua = window.navigator.userAgent.toLowerCase();
  4. if (ua.match(/MicroMessenger/i) == 'micromessenger' || ua.match(/WeiBo/i) == "weibo" || ua.match(/QQ/i) == "qqbrowser ") {
  5. uni.showToast({
  6. icon: 'none',
  7. title: '右上角在浏览器打开',
  8. mask: true
  9. })
  10. } else {
  11. if (res.platform === 'ios') {
  12. window.location.href = `airsmart://${url}&cmd=openPage`
  13. } else {
  14. window.location.href = `airsmart://muzen${url}&cmd=openPage`
  15. }
  16. var timer = setTimeout(() => {
  17. if (res.platform === 'ios') {
  18. window.location.href = 'itms-appss://itunes.apple.com/cn/app/apple-store/id1621419943?mt=8'
  19. } else {
  20. window.location.href = 'http://download.radio1964.com/readme?'
  21. }
  22. }, 3000)
  23. }
  24. document.addEventListener('visibilitychange', function () {
  25. if (document.hidden) {
  26. clearTimeout(timer)
  27. }
  28. })
  29. window.onpagehide = event => {
  30. if (event.persisted) {
  31. clearTimeout(timer)
  32. }
  33. }
  34. }
  35. export default openApp;