Merge branch 'develop' of http://25.13.9.101:9000/K17_AITS/tra-app into develop
This commit is contained in:
+3
-1
@@ -41,7 +41,9 @@ export const uploadFile = (file, data) => {
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const getPreviewFileUrl = (id) => {
|
||||
return get_base_url() + `/traoss/tras3/show/${id}`
|
||||
}
|
||||
// 对象存储下载 /traoss/tras3/show/{文件ID}
|
||||
export function downloadFile(id) {
|
||||
const token = getToken();
|
||||
|
||||
@@ -10,10 +10,11 @@
|
||||
<uv-overlay :show="showModel" opacity=".6" @click.stop="showModel = false">
|
||||
<view class="overlay-box" @click.stop="showModel = false">
|
||||
<video class="video-cont-center"
|
||||
ref="playerRef"
|
||||
v-if="showModel && fileUrlShow"
|
||||
:id="`video`+ fileId"
|
||||
ref="playerRef"
|
||||
v-if="showModel && fileUrlShow"
|
||||
:src="fileUrlShow"
|
||||
controls
|
||||
:controls="true"
|
||||
@error="playError"
|
||||
@ended="playEnded"
|
||||
object-fit="contain"></video>
|
||||
@@ -23,8 +24,9 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { downloadFile } from'@/api/common.js'
|
||||
import { downloadFile,getPreviewFileUrl } from'@/api/common.js'
|
||||
import { useStorageStore } from "@/store/storage.js"
|
||||
|
||||
export default {
|
||||
name:"video-preview",
|
||||
props:{
|
||||
@@ -37,7 +39,8 @@
|
||||
return {
|
||||
showModel: false,
|
||||
fileUrlShow:'',
|
||||
watching:false
|
||||
watching:false,
|
||||
videoContext: null
|
||||
};
|
||||
},
|
||||
computed:{
|
||||
@@ -51,11 +54,12 @@
|
||||
handler(newval, oldval) {
|
||||
if(newval.indexOf('http') === 0){
|
||||
this.fileUrlShow = newval
|
||||
return
|
||||
}
|
||||
if (newval && this.watching) {
|
||||
this.getPreviewUrlBlob(newval);
|
||||
}else{
|
||||
if (newval && this.watching) {
|
||||
this.getPreviewUrlBlob(newval);
|
||||
}
|
||||
}
|
||||
this.videoContext = uni.createVideoContext(`video`+ this.fileId)
|
||||
},
|
||||
immediate: true,
|
||||
deep: true,
|
||||
@@ -64,10 +68,14 @@
|
||||
methods: {
|
||||
playError(info){
|
||||
console.log('err:',info)
|
||||
this.$refs.playerRef.stop();
|
||||
console.log(this.$refs.playerRef)
|
||||
console.log(this.videoContext)
|
||||
// this.$refs.playerRef.stop();
|
||||
},
|
||||
playEnded(){
|
||||
this.$refs.playerRef.stop();
|
||||
// let _newDate = new Date().getTime()
|
||||
// this.fileUrlShow = getPreviewFileUrl(this.fileId)+'?t=' + _newDate
|
||||
this.showModel = false
|
||||
},
|
||||
getPreviewUrlBlob(id) {
|
||||
if (!id) {
|
||||
@@ -79,20 +87,33 @@
|
||||
this.fileUrlShow = _cache;
|
||||
return
|
||||
}
|
||||
downloadFile(id).then(res=>{
|
||||
this.fileUrlShow = res.tempFilePath
|
||||
this.storageStore.setStorage('video', id, this.fileUrlShow)
|
||||
})
|
||||
let _newDate = new Date().getTime()
|
||||
this.fileUrlShow = getPreviewFileUrl(this.fileId)+'?t=' + _newDate
|
||||
// downloadFile(id).then(res=>{
|
||||
// this.fileUrlShow = res.tempFilePath
|
||||
// this.storageStore.setStorage('video', id, this.fileUrlShow)
|
||||
// })
|
||||
},
|
||||
getPreviewFileUrlNow(id){
|
||||
let _newDate = new Date().getTime()
|
||||
if(id.indexOf('http') === 0){
|
||||
this.fileUrlShow = id + '?t=' + _newDate
|
||||
return
|
||||
}
|
||||
if (id && this.watching) {
|
||||
this.getPreviewUrlBlob(id);
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
console.log(this.fileId)
|
||||
if (this.fileId) {
|
||||
let _newDate = new Date().getTime()
|
||||
if(this.fileId.indexOf('http') === 0){
|
||||
this.fileUrlShow = this.fileId
|
||||
this.fileUrlShow = this.fileId + '?t=' + _newDate
|
||||
}else{
|
||||
this.getPreviewUrlBlob(this.fileId);
|
||||
}
|
||||
this.videoContext = uni.createVideoContext(`video`+ this.fileId)
|
||||
}
|
||||
this.watching = true
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user