qa-regulatory-gwj-app/pages/key-project-management/positioning_management/videoView.vue

91 lines
1.9 KiB
Vue

<template>
<view class="content">
<video id="coursewareVideo" :src="src"
controls autoplay="autoplay" style="width: 100%;"></video>
</view>
</template>
<script>
import {getPlatVideoPlay, loginVideoPlat} from "@/api";
export default {
data() {
return {
info: {},
src:''
}
},
onLoad(options) {
this.info = options
this.fnInit()
},
methods: {
fnInit(){
this.fnInitVideoPlat()
},
async fnInitVideoPlat(){
const params = this.getUrlParams(this.info.old)
if(!params || !params.serial){
uni.showToast({
title: '网络错误请重试',
icon: 'none',
duration: 2000
});
return
}
const serial = params.serial
const resData = await loginVideoPlat({
username:"admin",
password:"234f3424be5a75ad898a1b55f6e34d9e",
url_token_only:true
});
const token = resData.URLToken
const playData = await getPlatVideoPlay({
serial,
token
});
console.log(playData)
this.src = playData.HLS
console.log(src)
},
fnBack() {
uni.$u.route({
type: 'navigateBack'
})
},
getUrlParams(url) {
const params = {};
const paramStr = url.split('?')[1]; // 获取问号后面的参数部分
if (paramStr) {
const paramArr = paramStr.split('&'); // 将参数字符串分割成键值对数组
paramArr.forEach((param) => {
const [key, value] = param.split('='); // 将键值对字符串分割成键和值
params[key] = value; // 将键值对添加到params对象中
});
}
return params;
}
},
}
</script>
<style lang="scss" scoped>
.content {
background-color: #fff;
padding: 0 20upx;
}
.button {
text-align: center;
margin-top: 40upx;
margin-bottom: 40upx;
button {
width: 70%;
}
}
</style>