<template>
<div>
<el-button @click="previewPdf(scope.row)"
type="text"
size="small"
v-if="">
預覽
</el-button>
<el-dialog :visible="showDoc == true || showPdf == true || showVideo == true"
:show-close="true"
:width="'80%'"
class="dialog-div-pre-style"
:before-close="closePreviewClick"
center>
<div v-if="showDoc == true"
class="dialog-body-content-base-style">
<iframe frameborder="0"
:src="'https://view.officeapps.live.com/op/view.aspx?src='https://bbs.csdn.net/topics/ + this.fileUrl"
width='100%'>
</iframe>
</div>
<div v-else-if="showPdf == true"
class="dialog-body-content-base-style"
style="justify-content: center; align-items: center">
<embed :src="https://bbs.csdn.net/topics/pdfUrl"
style="width: 100%; height: 100%" />
</div>
<div v-else-if="showVideo == true"
class="dialog-body-content-base-style"
style="justify-content: center; align-items: center">
<video-player class="video-player vjs-custom-skin"
ref="positiveVideoPlayer"
:playsinline="true"
:options="positivePlayerOptions"></video-player>
</div>
</el-dialog>
</div>
</template>
// <script>
// import {getFileList} from '@/api/uploadOrders'
import { videoPlayer } from 'vue-video-player'
export default {
components: {
videoPlayer
},
data () {
return {
showDoc: false,
showPdf: false,
showVideo: false,
fileUrl: "",
images: [],
currentPage: 0, // pdf檔案頁碼
pageCount: 0, // pdf檔案總頁數
pdfUrl: "",
scale: 1.0,
scope:'',
/**
*播放器配置
*/
positivePlayerOptions: {
playbackRates: [0.5, 1.0, 1.5, 2.0], //播放速度
autoplay: false, //如果true,瀏覽器準備好時開始回放。
muted: false, // 默認情況下將會消除任何音頻。
loop: false, // 導致視頻一結束就重新開始。
preload: 'auto', // 建議瀏覽器在<video>加載元素后是否應該開始下載視頻資料。auto瀏覽器選擇最佳行為,立即開始加載視頻(如果瀏覽器支持)
language: 'zh-CN',
aspectRatio: '16:9', // 將播放器置于流暢模式,并在計算播放器的動態大小時使用該值。值應該代表一個比例 - 用冒號分隔的兩個數字(例如"16:9"或"4:3")
fluid: true, // 當true時,Video.js player將擁有流體大小。換句話說,它將按比例縮放以適應其容器。
sources: [{
type: "",
src: "" //視頻url地址
}],
poster: "", //你的封面地址
// width: document.documentElement.clientWidth,
notSupportedMessage: '此視頻暫無法播放,請稍后再試', //允許覆寫Video.js無法播放媒體源時顯示的默認資訊。
controlBar: {
timeDivider: true,
durationDisplay: true,
remainingTimeDisplay: false,
fullscreenToggle: true //全屏按鈕
},
common: "positivePlayer",
},
}
},
methods: {
/* pdf預覽*/
previewPdf (row) {
let type = this.iconByType(row);
this.fileUrl = row.url
if (type.indexOf("doc") != -1 || type.indexOf("docx") != -1 || type.indexOf("xsl") != -1 || type.indexOf("xslx") != -1) {
this.showDoc = true
} else if (type.indexOf("pdf") != -1) {
this.pdfUrl = "http://47.105.218.26:8888/group1/M00/00/00/rB-LJlzT042AbKdCAAiu_35Yccs182.pdf"
this.showPdf = true
} else if (type.indexOf("avi") != -1 || type.indexOf("mp4") != -1 || type.indexOf("webm") != -1 || type.indexOf("m4v") != -1 || type.indexOf("rmvb") != -1 || type.indexOf("mpg") != -1 || type.indexOf("3gp") != -1 || type.indexOf("swf") != -1 || type.indexOf("mkv") != -1) {
this.positivePlayerOptions.sources[0].src = "//nos.netease.com/vod163/demo.mp4"
this.positivePlayerOptions.sources[0].type = "video/mp4"
this.showVideo = true
} else {
this.$message("當前檔案暫不支持預覽")
}
// this.showPdf = true
},
/*** 通過檔案后綴回傳檔案的圖示*/
iconByType (row) {
return row.fileName.substring(row.fileName.lastIndexOf(".") + 1, srow.fileName.length)
},
closePreviewClick () {
if (this.showDoc == true) {
this.showDoc = false
} else if (this.showPdf == true) {
this.showPdf = false
} else if (this.showVideo == true) {
this.showVideo = false
}
},
}
}
</script>


轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/243069.html
標籤:其他
上一篇:Vue+element-ui檔案上傳阿里云oss+預覽word 、excel、ppt、pdf、png、jpg檔案
下一篇:求助:bootstrap-table.min.js:7 Uncaught TypeError: Cannot assign to read only prope
