DESKTOP-SVI9JE1\muzen 2 anos atrás
pai
commit
96e37f6810
1 arquivos alterados com 41 adições e 0 exclusões
  1. 41 0
      src/utils/openApp.js

+ 41 - 0
src/utils/openApp.js

@@ -0,0 +1,41 @@
+const openApp = function (url) {
+  const res = uni.getSystemInfoSync()
+  var ua = window.navigator.userAgent.toLowerCase();
+  if (ua.match(/MicroMessenger/i) == 'micromessenger' || ua.match(/WeiBo/i) == "weibo" || ua.match(/QQ/i) == "qqbrowser ") {
+    uni.showToast({
+      icon: 'none',
+      title: '右上角在浏览器打开',
+      mask: true
+    })
+  } else {
+    if (res.platform === 'ios') {
+      // window.location.href = `airsmart://?page=${page}&channel=${channel}&audioType=${audioType}&audioId=${audioId}`
+      window.location.href = `airsmart://${url}&cmd=openPage`
+    } else {
+      // window.location.href = `airsmart://com.muzen.radioplayer:8888/main?page=${page}&channel=${channel}&audioType=${audioType}&audioId=${audioId}`
+      window.location.href = `airsmart://com.muzen.radioplayer:8888/main${url}&cmd=openPage`
+    }
+
+    var timer = setTimeout(() => {
+      if (res.platform === 'ios') {
+        window.location.href = 'itms-appss://itunes.apple.com/cn/app/apple-store/id1621419943?mt=8'
+      } else {
+        window.location.href = 'http://download.radio1964.com/readme?'
+      }
+    }, 3000)
+  }
+
+  document.addEventListener('visibilitychange', function () {
+    if (document.hidden) {
+      clearTimeout(timer)
+    }
+  })
+
+  window.onpagehide = event => {
+    if (event.persisted) {
+      clearTimeout(timer)
+    }
+  }
+}
+
+export default openApp;