| 12345678910111213141516171819202122232425262728293031323334353637 |
- import { openPayWebview } from '@/hooks/usePayWebview'
- /**
- * 打开外部链接
- * @param {string} url
- * @param {string} [type] 'pay' 支付页:App 内 webview 页,H5 弹窗 iframe
- * @param {{ title?: string }} [options]
- */
- export function openExternalUrl(url, type, options = {}) {
- if (!url) return
- const title = options.title || 'Shop.Order.OrderDetails'
- if (type === 'pay') {
- // #ifdef APP-PLUS
- const webviewUrl = `/pages/common/webview?url=${encodeURIComponent(url)}&title=${encodeURIComponent(title)}`
- uni.navigateTo({ url: webviewUrl })
- // #endif
- // #ifdef H5
- openPayWebview(url, title)
- // #endif
- return
- }
- // #ifdef APP-PLUS
- plus.runtime.openURL(url, (error) => {
- if (error) {
- uni.showToast({ title: '打开失败', icon: 'none' })
- }
- })
- // #endif
- // #ifdef H5
- window.open(url, '_blank')
- // #endif
- }
|