| 1234567891011121314151617181920212223242526272829303132 |
- import Config from '@/config/index'
- const { Host80 } = Config
- import getWebBase from '@/utils/webBase'
- const webBase = getWebBase()
- // 打开 PDF 文件(修复 URL 编码问题)
- export function openLocalPdf(fileName, title, type = 'pdf') {
- // 最终要跳转的 url
- let targetUrl = ''
- // 拼接地址
- if (type === 'pdf') {
- targetUrl = `${Host80}/${fileName}`
- } else if (type === 'pdf1') {
- targetUrl = fileName
- }
- // 传递给 webview(只编码一次,正确格式)
- const webviewUrl = `/pages/common/webview?url=${encodeURIComponent(targetUrl)}&title=${encodeURIComponent(title)}`
- // #ifdef H5
- if (type === 'pdf') {
- window.open(targetUrl)
- } else if (type === 'pdf1') {
- window.open(targetUrl)
- }
- // #endif
- // #ifdef APP-PLUS
- uni.navigateTo({ url: webviewUrl })
- // #endif
- }
|