Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx-web
/
glsx-oss-task
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit b5c7d017
authored
Nov 24, 2022
by
匡雅琴
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'kuangyq_dev_v3.1.0' into 'v3.1.0'
视频第一帧 See merge request
!63
2 parents
6c5b1c5c
8bdf9b18
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
88 additions
and
0 deletions
src/components/GLEditor/index.vue
src/views/task/addTask/index.vue
src/components/GLEditor/index.vue
View file @
b5c7d01
...
...
@@ -341,6 +341,7 @@ import wTextarea from './tag-textarea'
// import vuedraggable from 'vuedraggable'
import
{
utils
}
from
'glsx-common'
import
{
set
}
from
'vue'
import
{
commonApi
}
from
'../../api/commonApi'
export
default
{
name
:
'GLEditor'
,
components
:
{
...
...
@@ -603,6 +604,60 @@ export default {
}
}
},
getImgUrl
(
url
,
multiple
=
3
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
var
canvas
=
document
.
createElement
(
'canvas'
)
// 获取 canvas 对象
const
ctx
=
canvas
.
getContext
(
'2d'
)
// 绘制2d
let
video
=
document
.
getElementById
(
'video'
)
video
.
src
=
url
video
.
crossOrigin
=
'anonymous'
// 解决跨域问题,也就是提示污染资源无法转换视频
video
.
currentTime
=
1
// 第一帧
video
.
oncanplay
=
async
()
=>
{
canvas
.
width
=
video
.
clientWidth
*
multiple
// 获取视频宽度
canvas
.
height
=
video
.
clientHeight
*
multiple
// 获取视频高度
// 利用canvas对象方法绘图
ctx
.
drawImage
(
video
,
0
,
0
,
video
.
clientWidth
*
multiple
,
video
.
clientHeight
*
multiple
)
console
.
log
(
canvas
,
'canvas'
)
// 转换成base64形式
var
oGrayImg
=
canvas
.
toDataURL
(
'image/png'
)
// 截取后的视频封面
const
file
=
this
.
dataURLtoFile
(
oGrayImg
)
const
imgUrl
=
await
this
.
uploadImg
(
file
)
resolve
(
imgUrl
)
}
})
},
//将base64转换为文件
dataURLtoFile
(
dataurl
,
filename
=
'1.png'
)
{
var
arr
=
dataurl
.
split
(
','
),
mime
=
arr
[
0
].
match
(
/:
(
.*
?)
;/
)[
1
],
bstr
=
atob
(
arr
[
1
]),
n
=
bstr
.
length
,
u8arr
=
new
Uint8Array
(
n
)
while
(
n
--
)
{
u8arr
[
n
]
=
bstr
.
charCodeAt
(
n
)
}
return
new
File
([
u8arr
],
filename
,
{
type
:
mime
})
},
uploadImg
(
fileInfo
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
var
reader
=
new
FileReader
()
reader
.
readAsDataURL
(
fileInfo
)
reader
.
onload
=
(
e
)
=>
{
const
imgFile
=
e
.
target
.
result
const
base64
=
fileInfo
.
name
.
split
(
'.'
)[
1
]
+
'@'
+
imgFile
.
split
(
','
)[
1
]
commonApi
.
uploadImgApi
({
file
:
base64
}).
then
((
res
)
=>
{
resolve
(
res
)
})
}
})
},
// 上传视频
async
handleVideoChange
(
e
)
{
// 判断是否有链接
...
...
@@ -633,6 +688,14 @@ export default {
materialType
:
that
.
ATT_TYPE
.
VEDIO
,
materialContent
:
res
,
})
that
.
$nextTick
(()
=>
{
const
videoUrl
=
res
that
.
getImgUrl
(
videoUrl
).
then
((
res
)
=>
{
console
.
log
(
res
,
'videoimg'
)
that
.
$emit
(
'getVideoImg'
,
res
.
data
.
data
)
that
.
$emit
(
'getEditor'
)
})
})
},
})
this
.
$notify
({
...
...
src/views/task/addTask/index.vue
View file @
b5c7d01
...
...
@@ -189,6 +189,7 @@
:linkStatus=
"itm.linkStatus"
@
getEditor=
"getEditor(item, index, itm, index1)"
@
shareMatrial=
"shareMatrial"
@
getVideoImg=
"getVideoImg"
></GLEditor>
</el-form-item>
<el-form-item
...
...
@@ -411,6 +412,7 @@ export default {
repeatChecked
:
false
,
// 子组件传来的分享素材
shareEditor
:
''
,
videoImg
:
''
,
// 是否是编辑
isEditor
:
false
,
// 是否是克隆
...
...
@@ -751,6 +753,9 @@ export default {
},
// 添加任务
addTaskType
(
item
,
index
)
{
if
(
this
.
videoImg
)
{
this
.
videoImg
=
''
}
this
.
taskList
[
index
].
missionList
.
unshift
({
...
this
.
basicObj
,
})
...
...
@@ -832,10 +837,29 @@ export default {
'missionMaterialList'
,
this
.
shareEditor
)
console
.
log
(
this
.
videoImg
)
if
(
this
.
videoImg
)
{
// 找到视频下标
const
videoFlag
=
this
.
taskList
[
dateTaskIndex
].
missionList
[
taskIndex
].
missionMaterialList
.
findIndex
((
item
)
=>
{
return
item
.
materialType
==
3
})
this
.
$set
(
this
.
taskList
[
dateTaskIndex
].
missionList
[
taskIndex
]
.
missionMaterialList
[
videoFlag
],
'firstFrameUrl'
,
this
.
videoImg
)
}
console
.
log
(
this
.
taskList
[
dateTaskIndex
].
missionList
[
taskIndex
])
},
shareMatrial
(
val
)
{
this
.
shareEditor
=
val
},
getVideoImg
(
val
)
{
this
.
videoImg
=
val
},
// 删除任务
delTask
(
dateTask
,
dateTaskIndex
,
task
,
taskIndex
)
{
// dateTask -- 具体哪一天的任务对象
...
...
@@ -1058,6 +1082,7 @@ export default {
}
params
.
missionDateList
=
this
.
taskList
params
.
id
=
this
.
taskId
console
.
log
(
params
,
'params'
)
// 创建
if
(
!
this
.
isEditor
)
{
taskApi
.
creatMission
(
params
).
then
(
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment