<template>
|
|
<view class="">
|
|
<web-view :src="h5Url" @message="message"></web-view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data(){
|
|
return{
|
|
id: '',
|
|
h5Url: '',
|
|
imageData: '',
|
|
}
|
|
},
|
|
onLoad({ id, mode}) {
|
|
this.id = id
|
|
// this.h5Url = `https://adminh5.kjetax.com/#/?id=${id}&token=${uni.getStorageSync('token')}`
|
|
this.h5Url = `https://192.168.10.100:8080/#/?id=${id}&mode=${mode}&token=${uni.getStorageSync('token')}`
|
|
|
|
console.log('url', this.h5Url)
|
|
console.log('mode', mode)
|
|
},
|
|
methods: {
|
|
message(e) {
|
|
|
|
const url = e.detail.data[0]
|
|
console.log('pdfUrl', url)
|
|
// this.downloadFile(url)
|
|
},
|
|
downloadFile(url) {
|
|
console.log('downloadFile', url)
|
|
uni.downloadFile({
|
|
url, // 文件地址
|
|
success: (downloadRes) => {
|
|
console.log('downloadRes', downloadRes)
|
|
if (downloadRes.statusCode === 200) {
|
|
uni.openDocument({
|
|
showMenu: true,
|
|
filePath: downloadRes.tempFilePath,
|
|
success: () => console.log('打开成功')
|
|
});
|
|
} else {
|
|
uni.showToast({ title: '下载失败', icon: 'none' });
|
|
}
|
|
},
|
|
fail: (err) => {
|
|
console.log('downloadFile fail', err)
|
|
uni.showToast({ title: '网络异常', icon: 'none' });
|
|
}
|
|
});
|
|
},
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
|
|
</style>
|