49 lines
1.1 KiB
Vue
49 lines
1.1 KiB
Vue
<template>
|
|
<web-view :src="url"></web-view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
url: '', //PDF路径
|
|
};
|
|
},
|
|
onLoad(options) {
|
|
console.log(options)
|
|
if (options.tape == 1) {
|
|
this.url = options.url;
|
|
} else {
|
|
uni.request({
|
|
url: uni.conf.baseUrl + 'szzpy/downloadurl',
|
|
data: {
|
|
//参数
|
|
id: options.id
|
|
},
|
|
method: 'POST', //请求方式,必须为大写
|
|
success: res => {
|
|
let fileUrl = options.url
|
|
// this.url = 'https://www.pfile.com.cn/api/profile/onlinePreview?url=' +
|
|
// encodeURIComponent(res.data.data);
|
|
|
|
// this.url = 'https://view.officeapps.live.com/op/view.aspx?src=' + res.data.data
|
|
// console.log(this.url)
|
|
var user = navigator.userAgent;
|
|
//android端
|
|
var isAndroid = user.indexOf("Android") > -1 || user.indexOf("Adr") > -1;
|
|
//ios端
|
|
var isiOS = !!user.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
|
|
if(isAndroid) {
|
|
window.open(res.data.data)
|
|
}else if(isiOS) {
|
|
window.location.href = res.data.data;
|
|
}
|
|
// window.open(res.data.data)
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
};
|
|
</script> |