|
|
@@ -188,14 +188,48 @@
|
|
|
},
|
|
|
reviewReport(item){
|
|
|
const { isPC, isMobile, platform } = getPlatformInfo();
|
|
|
+ console.log(platform,'platform');//android
|
|
|
if (isPC) {
|
|
|
this.$showModal('请在手机端该微信小程序中查看报告')
|
|
|
} else if (isMobile||platform==='devtools') {
|
|
|
if(!item.fileUrl) return this.$showToast('报告pdf为空,请稍后再试。')
|
|
|
- uni.navigateTo({
|
|
|
- url:'/pages/webView?src='+item.fileUrl
|
|
|
- })
|
|
|
+ this.openPdf(item.fileUrl)
|
|
|
+ // uni.navigateTo({
|
|
|
+ // url:'/pages/webView?src='+item.fileUrl
|
|
|
+ // })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async openPdf(pdfUrl) {
|
|
|
+ try {
|
|
|
+ // 1. 显示加载提示
|
|
|
+ uni.showLoading({ title: '加载中...' });
|
|
|
+ // 2. 先下载PDF文件到本地(解决安卓直接预览网络文件慢的问题)
|
|
|
+ const downloadRes = await uni.downloadFile({
|
|
|
+ url: pdfUrl,
|
|
|
+ // 可选:设置超时时间,避免长时间等待
|
|
|
+ timeout: 30000
|
|
|
+ });
|
|
|
+
|
|
|
+ const dres = downloadRes[1]||null;
|
|
|
+
|
|
|
+ if (dres.statusCode !== 200) {
|
|
|
+ uni.hideLoading();
|
|
|
+ uni.showToast({ title: '文件下载失败', icon: 'none' });
|
|
|
+ return;
|
|
|
}
|
|
|
+
|
|
|
+ // 3. 用微信原生API打开本地PDF
|
|
|
+ const openRes = await uni.openDocument({
|
|
|
+ filePath: dres.tempFilePath,
|
|
|
+ fileType: 'pdf',
|
|
|
+ showMenu: true // 允许用户转发/保存等
|
|
|
+ });
|
|
|
+
|
|
|
+ uni.hideLoading();
|
|
|
+ } catch (error) {
|
|
|
+ uni.hideLoading();
|
|
|
+ uni.showToast({ title: '加载失败,请重试', icon: 'none' });
|
|
|
+ }
|
|
|
},
|
|
|
askReport(item){
|
|
|
uni.navigateTo({
|