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 8bdf9b18
authored
Nov 24, 2022
by
前端
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
视频第一帧
1 parent
c58578cc
Show 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 @
8bdf9b1
...
@@ -341,6 +341,7 @@ import wTextarea from './tag-textarea'
...
@@ -341,6 +341,7 @@ import wTextarea from './tag-textarea'
// import vuedraggable from 'vuedraggable'
// import vuedraggable from 'vuedraggable'
import
{
utils
}
from
'glsx-common'
import
{
utils
}
from
'glsx-common'
import
{
set
}
from
'vue'
import
{
set
}
from
'vue'
import
{
commonApi
}
from
'../../api/commonApi'
export
default
{
export
default
{
name
:
'GLEditor'
,
name
:
'GLEditor'
,
components
:
{
components
:
{
...
@@ -603,6 +604,60 @@ export default {
...
@@ -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
)
{
async
handleVideoChange
(
e
)
{
// 判断是否有链接
// 判断是否有链接
...
@@ -633,6 +688,14 @@ export default {
...
@@ -633,6 +688,14 @@ export default {
materialType
:
that
.
ATT_TYPE
.
VEDIO
,
materialType
:
that
.
ATT_TYPE
.
VEDIO
,
materialContent
:
res
,
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
({
this
.
$notify
({
...
...
src/views/task/addTask/index.vue
View file @
8bdf9b1
...
@@ -189,6 +189,7 @@
...
@@ -189,6 +189,7 @@
:linkStatus=
"itm.linkStatus"
:linkStatus=
"itm.linkStatus"
@
getEditor=
"getEditor(item, index, itm, index1)"
@
getEditor=
"getEditor(item, index, itm, index1)"
@
shareMatrial=
"shareMatrial"
@
shareMatrial=
"shareMatrial"
@
getVideoImg=
"getVideoImg"
></GLEditor>
></GLEditor>
</el-form-item>
</el-form-item>
<el-form-item
<el-form-item
...
@@ -411,6 +412,7 @@ export default {
...
@@ -411,6 +412,7 @@ export default {
repeatChecked
:
false
,
repeatChecked
:
false
,
// 子组件传来的分享素材
// 子组件传来的分享素材
shareEditor
:
''
,
shareEditor
:
''
,
videoImg
:
''
,
// 是否是编辑
// 是否是编辑
isEditor
:
false
,
isEditor
:
false
,
// 是否是克隆
// 是否是克隆
...
@@ -751,6 +753,9 @@ export default {
...
@@ -751,6 +753,9 @@ export default {
},
},
// 添加任务
// 添加任务
addTaskType
(
item
,
index
)
{
addTaskType
(
item
,
index
)
{
if
(
this
.
videoImg
)
{
this
.
videoImg
=
''
}
this
.
taskList
[
index
].
missionList
.
unshift
({
this
.
taskList
[
index
].
missionList
.
unshift
({
...
this
.
basicObj
,
...
this
.
basicObj
,
})
})
...
@@ -832,10 +837,29 @@ export default {
...
@@ -832,10 +837,29 @@ export default {
'missionMaterialList'
,
'missionMaterialList'
,
this
.
shareEditor
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
)
{
shareMatrial
(
val
)
{
this
.
shareEditor
=
val
this
.
shareEditor
=
val
},
},
getVideoImg
(
val
)
{
this
.
videoImg
=
val
},
// 删除任务
// 删除任务
delTask
(
dateTask
,
dateTaskIndex
,
task
,
taskIndex
)
{
delTask
(
dateTask
,
dateTaskIndex
,
task
,
taskIndex
)
{
// dateTask -- 具体哪一天的任务对象
// dateTask -- 具体哪一天的任务对象
...
@@ -1058,6 +1082,7 @@ export default {
...
@@ -1058,6 +1082,7 @@ export default {
}
}
params
.
missionDateList
=
this
.
taskList
params
.
missionDateList
=
this
.
taskList
params
.
id
=
this
.
taskId
params
.
id
=
this
.
taskId
console
.
log
(
params
,
'params'
)
// 创建
// 创建
if
(
!
this
.
isEditor
)
{
if
(
!
this
.
isEditor
)
{
taskApi
.
creatMission
(
params
).
then
(
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