Commit dabbcf53 by 前端

Merge branch 'SAAS+V4.27.0' into 'master'

Saas+v4.27.0

See merge request !16
2 parents bcbc2f1a cc6e81c9
......@@ -9,7 +9,7 @@
"lint": "vue-cli-service lint"
},
"dependencies": {
"axios": "^0.18.0",
"axios": "^1.4.0",
"core-js": "^3.4.4",
"dayjs": "^1.10.7",
"el-tree-transfer": "^2.2.6",
......
......@@ -2,7 +2,7 @@
* @Author: yangming yangming@didihu.com.cn
* @Date: 2022-11-24 14:42:00
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2022-11-24 17:18:31
* @LastEditTime: 2023-08-25 18:08:43
* @FilePath: \live\src\mixins\upload.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
......@@ -11,7 +11,7 @@ export default {
return {}
},
methods: {
getImgUrl(url, multiple = 3) {
getImgUrl(url, multiple = 0.5) {
return new Promise((resolve, reject) => {
var canvas = document.createElement('canvas') // 获取 canvas 对象
const ctx = canvas.getContext('2d') // 绘制2d
......@@ -20,10 +20,10 @@ export default {
video.crossOrigin = 'anonymous' // 解决跨域问题,也就是提示污染资源无法转换视频
video.currentTime = 1 // 第一帧
video.oncanplay = async () => {
canvas.width = video.clientWidth * multiple // 获取视频宽度
canvas.height = video.clientHeight * multiple // 获取视频高度
canvas.width = video.videoWidth * multiple // 获取视频宽度
canvas.height = video.videoHeight * multiple // 获取视频高度
// 利用canvas对象方法绘图
ctx.drawImage(video, 0, 0, video.clientWidth * multiple, video.clientHeight * multiple)
ctx.drawImage(video, 0, 0, video.videoWidth * multiple, video.videoHeight * multiple)
console.log(canvas, 'canvas')
// 转换成base64形式
var oGrayImg = canvas.toDataURL('image/png') // 截取后的视频封面
......
<template>
<div class="material-view">
<div class="material-view-container">
<el-carousel :height="height + 'px'" interval="100000" @change="handleChange" v-if="fileList.length">
<el-carousel-item v-for="item in fileList" :key="item">
<div class="carousel-item">
<img :src="item.url" class="carousel-img" />
<img src="@/assets/material/videoIcon.png" class="play" v-if="item.type == 'video'" />
</div>
</el-carousel-item>
</el-carousel>
<div class="material-text" v-html="textBoxContent"></div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
height: 200,
fileList: []
}
},
watch: {
materialAddForm: {
async handler(val) {
const fileList = (val.imageUrlList || []).map(item => {
return {
type: 'img',
url: item
}
})
this.fileList = val.videoUrl ? fileList.concat({ url: val.coverUrl, type: 'video' }) : fileList
if (this.fileList.length) {
for (let val of this.fileList) {
this.$set(val, 'height', await this.getHeight(val.url))
}
this.height = this.fileList[0].height
}
},
deep: true,
immediate: true
}
},
props: {
materialAddForm: {
type: Object,
default: () => {}
},
textBoxContent: {
type: String
}
},
methods: {
getHeight(url) {
return new Promise(resolve => {
const img = new Image()
img.src = url
img.onload = res => {
resolve((img.height / img.width) * 250)
}
})
},
handleChange(e) {
this.height = this.fileList[e].height
}
}
}
</script>
<style lang="scss" scoped>
.material-view {
width: 289.47px;
height: 566px;
background: url('../../../assets/phone.png');
background-size: 100% 100%;
position: relative;
overflow: hidden;
.material-view-container {
position: absolute;
top: 56px;
left: 20px;
width: calc(100% - 40px);
height: calc(100% - 112px);
overflow-y: auto;
/deep/ .el-carousel__button {
width: 8px;
}
.carousel-item {
position: relative;
height: 100%;
width: 100%;
.carousel-img {
width: 100%;
height: 100%;
}
.play {
position: absolute;
width: 30px;
height: 30px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
}
.material-text {
word-wrap: break-word;
img {
width: 100% !important;
}
}
}
}
</style>
<style>
.material-text img {
width: 100% !important;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!