Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas
/
scrm-micro-marketing
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 6a874cf1
authored
Aug 28, 2023
by
杨明
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
素材
1 parent
8b9cd3b8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
9 deletions
src/mixins/upload.js
src/views/material/components/MaterialView.vue
src/mixins/upload.js
View file @
6a874cf
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* @Author: yangming yangming@didihu.com.cn
* @Author: yangming yangming@didihu.com.cn
* @Date: 2022-11-24 14:42:00
* @Date: 2022-11-24 14:42:00
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 202
2-11-24 17:18:31
* @LastEditTime: 202
3-08-28 11:12:22
* @FilePath: \live\src\mixins\upload.js
* @FilePath: \live\src\mixins\upload.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
*/
...
@@ -11,7 +11,7 @@ export default {
...
@@ -11,7 +11,7 @@ export default {
return
{}
return
{}
},
},
methods
:
{
methods
:
{
getImgUrl
(
url
,
multiple
=
3
)
{
getImgUrl
(
url
,
multiple
=
0.5
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
var
canvas
=
document
.
createElement
(
'canvas'
)
// 获取 canvas 对象
var
canvas
=
document
.
createElement
(
'canvas'
)
// 获取 canvas 对象
const
ctx
=
canvas
.
getContext
(
'2d'
)
// 绘制2d
const
ctx
=
canvas
.
getContext
(
'2d'
)
// 绘制2d
...
@@ -20,10 +20,10 @@ export default {
...
@@ -20,10 +20,10 @@ export default {
video
.
crossOrigin
=
'anonymous'
// 解决跨域问题,也就是提示污染资源无法转换视频
video
.
crossOrigin
=
'anonymous'
// 解决跨域问题,也就是提示污染资源无法转换视频
video
.
currentTime
=
1
// 第一帧
video
.
currentTime
=
1
// 第一帧
video
.
oncanplay
=
async
()
=>
{
video
.
oncanplay
=
async
()
=>
{
canvas
.
width
=
video
.
client
Width
*
multiple
// 获取视频宽度
canvas
.
width
=
video
.
video
Width
*
multiple
// 获取视频宽度
canvas
.
height
=
video
.
client
Height
*
multiple
// 获取视频高度
canvas
.
height
=
video
.
video
Height
*
multiple
// 获取视频高度
// 利用canvas对象方法绘图
// 利用canvas对象方法绘图
ctx
.
drawImage
(
video
,
0
,
0
,
video
.
clientWidth
*
multiple
,
video
.
client
Height
*
multiple
)
ctx
.
drawImage
(
video
,
0
,
0
,
video
.
videoWidth
*
multiple
,
video
.
video
Height
*
multiple
)
console
.
log
(
canvas
,
'canvas'
)
console
.
log
(
canvas
,
'canvas'
)
// 转换成base64形式
// 转换成base64形式
var
oGrayImg
=
canvas
.
toDataURL
(
'image/png'
)
// 截取后的视频封面
var
oGrayImg
=
canvas
.
toDataURL
(
'image/png'
)
// 截取后的视频封面
...
...
src/views/material/components/MaterialView.vue
View file @
6a874cf
...
@@ -33,8 +33,8 @@ export default {
...
@@ -33,8 +33,8 @@ export default {
})
})
this
.
fileList
=
val
.
videoUrl
?
fileList
.
concat
({
url
:
val
.
coverUrl
,
type
:
'video'
})
:
fileList
this
.
fileList
=
val
.
videoUrl
?
fileList
.
concat
({
url
:
val
.
coverUrl
,
type
:
'video'
})
:
fileList
if
(
this
.
fileList
.
length
)
{
if
(
this
.
fileList
.
length
)
{
for
(
let
i
in
this
.
fileList
)
{
for
(
let
val
of
this
.
fileList
)
{
this
.
$set
(
this
.
fileList
[
i
],
'height'
,
await
this
.
getHeight
(
this
.
fileList
[
i
]
.
url
))
this
.
$set
(
val
,
'height'
,
await
this
.
getHeight
(
val
.
url
))
}
}
this
.
height
=
this
.
fileList
[
0
].
height
this
.
height
=
this
.
fileList
[
0
].
height
}
}
...
@@ -53,13 +53,13 @@ export default {
...
@@ -53,13 +53,13 @@ export default {
}
}
},
},
methods
:
{
methods
:
{
//获取图片高度
getHeight
(
url
)
{
getHeight
(
url
)
{
return
new
Promise
(
resolve
=>
{
return
new
Promise
(
resolve
=>
{
const
img
=
new
Image
()
const
img
=
new
Image
()
img
.
src
=
url
img
.
src
=
url
img
.
onload
=
res
=>
{
img
.
onload
=
res
=>
{
console
.
log
(
img
.
width
,
img
.
height
)
resolve
((
img
.
height
/
img
.
width
)
*
250
)
resolve
((
img
.
width
/
img
.
height
)
*
250
)
}
}
})
})
},
},
...
...
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