|
@@ -1,149 +1,69 @@
|
|
|
<template>
|
|
|
- <view>
|
|
|
- <!-- 顶部 -->
|
|
|
- <cu-custom bgColor="bg-blue" :isBack="true">
|
|
|
- <block slot="backText">预览</block>
|
|
|
- <block slot="content"></block>
|
|
|
- <block slot="right">
|
|
|
- <view class=" flex justify-center">
|
|
|
- <button class="margin-top-ssm cu-btn round bg-blue text-blue">装饰</button>
|
|
|
- </view>
|
|
|
- </block>
|
|
|
- </cu-custom>
|
|
|
- <!-- <view class="padding content" v-for="(item,index) in fileSrc "> -->
|
|
|
- <!-- <image mode="widthFix" :src="item" ></image> -->
|
|
|
- <!-- <image mode="widthFix" :src="item" @tap="ViewImage" :data-url="fileSrc[index]"></image> -->
|
|
|
- <!-- </view> -->
|
|
|
- <view class="padding content">
|
|
|
- <web-view :src="pdf"></web-view>
|
|
|
- </view>
|
|
|
- <!-- <view class=" topc text-xssl padding" @click="download()">
|
|
|
- <image src="/static/task/download.png" class="menuImageTask"></image>
|
|
|
- </view> -->
|
|
|
- </view>
|
|
|
+ <web-view :src="pdf"/>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- export default {
|
|
|
- data() {
|
|
|
- return {
|
|
|
- fileSrc:[],
|
|
|
- pdf:'',
|
|
|
- }
|
|
|
- },
|
|
|
- onLoad(e) {
|
|
|
- //this.findImage(e.processId);
|
|
|
- if(e.previews){
|
|
|
- this.getPreviews(e.previews);
|
|
|
- }else if(e.preview){
|
|
|
- //this.toPreview(e.preview);
|
|
|
- var pdfurl=e.preview;
|
|
|
- pdfurl=decodeURIComponent(pdfurl);
|
|
|
- this.toPreview(pdfurl);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- var height = 0; //定义动态的高度变量,如高度为定值,可以直接写
|
|
|
- uni.getSystemInfo({
|
|
|
- //成功获取的回调函数,返回值为系统信息
|
|
|
- success: (sysinfo) => {
|
|
|
- height = sysinfo.windowHeight - 32; //自行修改,自己需要的高度
|
|
|
- }
|
|
|
- });
|
|
|
- var currentWebview = this.$scope.$getAppWebview(); //获取当前web-view
|
|
|
- setTimeout(function() {
|
|
|
- var wv = currentWebview.children()[0];
|
|
|
- wv.setStyle({ //设置web-view距离顶部的距离以及自己的高度,单位为px
|
|
|
- top: 35,
|
|
|
- height: height
|
|
|
- })
|
|
|
- }, 1000);
|
|
|
- },
|
|
|
- methods: {
|
|
|
- findImage(processId){
|
|
|
- var that =this;
|
|
|
- that.http.request("/app/previewExcel",{processId:processId}).then(res=>{
|
|
|
- if(res.datas!=null){
|
|
|
- that.fileSrc = res.datas;
|
|
|
- }else{
|
|
|
- that.$prompt.none("暂无数据");
|
|
|
- }
|
|
|
-
|
|
|
- })
|
|
|
- },
|
|
|
- getPreviews(previews){
|
|
|
- var that =this;
|
|
|
- that.http.request("/app/showOutViewOfSubmit",{list:previews,storeName:uni.getStorageSync("storeName")}).then(res=>{
|
|
|
- //console.log(res)
|
|
|
- if(res.data){
|
|
|
- //that.pdf = `/hybrid/html/web/viewer.html?file=${res.data}`;
|
|
|
- var encode=encodeURIComponent(res.data);
|
|
|
- that.pdf = `/hybrid/html/web/viewer.html?file=${encode}`;
|
|
|
-
|
|
|
- //that.pdf = `/hybrid/html/pdf.html?url=${res.data}`;
|
|
|
- //that.pdf = res.data;
|
|
|
- // uni.downloadFile({
|
|
|
- // // 下面一行时拼接预览PDF的地址!!!
|
|
|
- // url: res.data,
|
|
|
- // success: function(res) {
|
|
|
- // var filePath = res.tempFilePath;
|
|
|
- // if (!filePath) return
|
|
|
- // uni.openDocument({
|
|
|
- // filePath: filePath,
|
|
|
- // success: function(res) {
|
|
|
- // console.log(res);
|
|
|
- // console.log('打开文档成功');
|
|
|
- // }
|
|
|
- // });
|
|
|
- // }
|
|
|
- // });
|
|
|
- }else{
|
|
|
- that.$prompt.none("暂无数据");
|
|
|
- }
|
|
|
-
|
|
|
- })
|
|
|
- //console.log(this.fileSrc)
|
|
|
- },
|
|
|
- toPreview(url){
|
|
|
- //this.pdf = `/hybrid/html/web/viewer.html?file=${url}`;
|
|
|
- var encode=encodeURIComponent(url);
|
|
|
- this.pdf = `/hybrid/html/web/viewer.html?file=${encode}`;
|
|
|
- },
|
|
|
-/* ViewImage(e) {
|
|
|
- uni.previewImage({
|
|
|
- urls: this.fileSrc,
|
|
|
- current: e.currentTarget.dataset.url
|
|
|
- });
|
|
|
- }, */
|
|
|
- download(){
|
|
|
- uni.showLoading({
|
|
|
- title: '下载中'
|
|
|
- });
|
|
|
- uni.saveImageToPhotosAlbum({
|
|
|
- filePath: this.fileSrc,
|
|
|
- success: function() {
|
|
|
- uni.hideLoading();
|
|
|
- uni.showToast({
|
|
|
- title: '已保存到相册',
|
|
|
- icon: 'none',
|
|
|
- duration: 2200
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ fileSrc:[],
|
|
|
+ pdf:'',
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onLoad(e) {
|
|
|
+ if(e.previews){
|
|
|
+ this.getPreviews(e.previews);
|
|
|
+ } else if(e.preview){
|
|
|
+ this.toPreview(decodeURIComponent(e.preview));
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ findImage(processId){
|
|
|
+ var that =this;
|
|
|
+ that.http.request("/app/previewExcel", {
|
|
|
+ processId: processId,
|
|
|
+ }).then(res => {
|
|
|
+ if(res.datas != null){
|
|
|
+ that.fileSrc = res.datas;
|
|
|
+ } else {
|
|
|
+ that.$prompt.none("暂无数据");
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getPreviews(previews){
|
|
|
+ var that = this;
|
|
|
+ that.http.request("/app/showOutViewOfSubmit", {
|
|
|
+ list: previews,
|
|
|
+ storeName: uni.getStorageSync("storeName")
|
|
|
+ }).then(res => {
|
|
|
+ if(res.data){
|
|
|
+ var encode = encodeURIComponent(res.data);
|
|
|
+ that.pdf = `/hybrid/html/web/viewer.html?file=${encode}`;
|
|
|
+ }else{
|
|
|
+ that.$prompt.none("暂无数据");
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ toPreview(url){
|
|
|
+ var encode = encodeURIComponent(url);
|
|
|
+ this.pdf = `/hybrid/html/web/viewer.html?file=${encode}`;
|
|
|
+ },
|
|
|
+ download(){
|
|
|
+ uni.showLoading({
|
|
|
+ title: '下载中'
|
|
|
+ });
|
|
|
+ uni.saveImageToPhotosAlbum({
|
|
|
+ filePath: this.fileSrc,
|
|
|
+ success: function() {
|
|
|
+ uni.hideLoading();
|
|
|
+ uni.showToast({
|
|
|
+ title: '已保存到相册',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2200
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|
|
|
-
|
|
|
-<style>
|
|
|
- .topc {
|
|
|
- position: fixed;
|
|
|
- right: 0;
|
|
|
- top: 85%;
|
|
|
- height: 50px;
|
|
|
- line-height: 50px;
|
|
|
- }
|
|
|
- .text-xssl {
|
|
|
- font-size: 40px;
|
|
|
- }
|
|
|
-</style>
|