2 Коміти 22fbf97e78 ... 23467e495d

Автор SHA1 Опис Дата
  liangan 23467e495d Merge remote-tracking branch 'origin/development' 1 тиждень тому
  liangan aca9a10607 fix: h5第三方地址跳转兼容http新标签打开 1 тиждень тому
1 змінених файлів з 21 додано та 0 видалено
  1. 21 0
      src/pages/webLink/webLink.vue

+ 21 - 0
src/pages/webLink/webLink.vue

@@ -13,9 +13,30 @@ import { t } from '@/locale'
 
 const params = ref({})
 
+function openInNewTabAndClose(url) {
+  try {
+    if (typeof window !== 'undefined') {
+      const win = window.open(url, '_blank')
+      if (!win)
+        window.location.href = url
+    }
+  }
+  finally {
+    uni.navigateBack()
+  }
+}
+
 onLoad((options) => {
   params.value = options
   params.value.link = decodeURIComponent(params.value.link)
+
+  // #ifdef H5
+  if (typeof params.value.link === 'string' && params.value.link.startsWith('http://')) {
+    openInNewTabAndClose(params.value.link)
+    return
+  }
+  // #endif
+
   uni.setNavigationBarTitle({
     title: decodeURIComponent(params.value.title) || t('webLink.title'),
   })