Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
biz.qingxiao.com
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangxuelai
biz.qingxiao.com
Commits
452c7fe9
Commit
452c7fe9
authored
Nov 27, 2019
by
wangxuelai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
''
parent
012b7c67
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
7 deletions
+75
-7
index.html
index.html
+1
-1
UploadCourseware.js
src/components/UploadCourseware.js
+26
-6
UploadCourseware.less
src/components/UploadCourseware.less
+13
-0
coursemateria.js
src/models/coursemateria.js
+16
-0
index.js
src/utils/index.js
+19
-0
No files found.
index.html
View file @
452c7fe9
...
...
@@ -17,6 +17,6 @@
</head>
<body>
<div
id=
"root"
></div>
<script
src=
"dist/main.js?15748
27384999
"
charset=
"utf-8"
></script>
<script
src=
"dist/main.js?15748
33367343
"
charset=
"utf-8"
></script>
</body>
</html>
\ No newline at end of file
src/components/UploadCourseware.js
View file @
452c7fe9
...
...
@@ -69,6 +69,19 @@ class UploadCourseware extends React.Component {
});
delCourseware
();
}
reLoadVideoPoster
=
(
src
)
=>
{
console
.
log
(
src
,
'src'
);
const
that
=
this
;
const
img
=
new
Image
();
img
.
src
=
videoPoster
(
src
);
img
.
onload
=
function
()
{
document
.
getElementById
(
'videoposter'
).
setAttribute
(
'src'
,
videoPoster
(
src
));
};
img
.
onerror
=
function
()
{
document
.
getElementById
(
'videoposter'
).
setAttribute
(
'src'
,
`
${
__IMGCDN__
}
course/video_default.png`
);
that
.
reLoadVideoPoster
(
src
);
};
}
render
()
{
const
{
visible
,
...
...
@@ -131,7 +144,7 @@ class UploadCourseware extends React.Component {
}
{
info
.
mediaType
==
2
&&
<
div
className
=
{
pageStyle
.
videobox
}
>
<
img
className
=
{
pageStyle
.
videoImg
}
alt
=
""
src
=
{
v
ideoPoster
(
info
.
src
)}
/
>
<
img
className
=
{
pageStyle
.
videoImg
}
alt
=
""
id
=
"videoposter"
src
=
{
videoPoster
(
info
.
src
)}
onError
=
{()
=>
this
.
reLoadV
ideoPoster
(
info
.
src
)}
/
>
<
div
className
=
{
pageStyle
.
videoplay
}
>
<
img
className
=
{
pageStyle
.
videoplayicon
}
src
=
{
`
${
__IMGCDN__
}
smallplayicon.png`
}
alt
=
""
/>
<
/div
>
...
...
@@ -169,20 +182,27 @@ class UploadCourseware extends React.Component {
<
div
className
=
{
pageStyle
.
uploaddesc
}
>
MOV
/
MP4
格式,大小≦
**
MB
<
/div
>
<
/div
>
<
div
className
=
{
pageStyle
.
right
}
>
<
div
className
=
{
pageStyle
.
btn
}
onClick
=
{
chooseFromCourseMateria
}
>
<
div
className
=
{
pageStyle
.
btn
}
onClick
=
{
chooseFromCourseMateria
}
style
=
{{
marginRight
:
'10px'
}}
>
<
img
src
=
{
`
${
__IMGCDN__
}
course/check.png`
}
alt
=
""
className
=
{
`
${
pageStyle
.
btnicon
}
${
pageStyle
.
leftbtnicon
}
`
}
/
>
<
span
>
素材库
<
/span
>
<
/div
>
<
div
className
=
{
pageStyle
.
btn
}
>
<
img
src
=
{
`
${
__IMGCDN__
}
course/uploadImg.png`
}
alt
=
""
className
=
{
`
${
pageStyle
.
btnicon
}
${
pageStyle
.
rightbtnicon
}
`
}
/
>
<
span
>
上传
<
/span
>
<
input
type
=
"file"
className
=
{
pageStyle
.
uploadInput
}
accept
=
".ppt, .pptx, image/*, application/vnd.ms-powerpoint, video/mp4, application/pdf, audio/*"
onChange
=
{
this
.
uploadCourseMateria
}
id
=
"uploadcourseware"
/>
<
/div
>
{
info
.
src
&&
<
div
className
=
{
pageStyle
.
delbtn
}
onClick
=
{
this
.
delCourseware
}
>
<
Icon
type
=
"delete"
className
=
{
pageStyle
.
delIcon
}
/
>
<
span
className
=
{
pageStyle
.
delText
}
>
删除
<
/span
>
<
/div
>
}
{
/* <div className={pageStyle.btn}>
<img src={`${__IMGCDN__}course/uploadImg.png`} alt="" className={`${pageStyle.btnicon} ${pageStyle.rightbtnicon}`} />
<span>上传</span>
</div> */
}
<
/div
>
<
/div
>
<
/Modal
>
...
...
src/components/UploadCourseware.less
View file @
452c7fe9
...
...
@@ -73,6 +73,16 @@
align-items: center;
justify-content: center;
cursor: pointer;
position: relative;
.uploadInput {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
z-index: 2;
opacity: 0;
}
.btnicon {
display: block;
&.leftbtnicon {
...
...
@@ -137,6 +147,9 @@
width: 100%;
height: 254px;
position: relative;
display: flex;
align-items: center;
justify-content: center;
.videoImg {
max-width: 100%;
max-height: 100%;
...
...
src/models/coursemateria.js
View file @
452c7fe9
...
...
@@ -173,11 +173,27 @@ export default {
break
;
case
2
:
// 视频
duration
=
yield
call
(
getVideoDuration
,
file
);
if
(
duration
==
0
)
{
yield
call
(
uploadMateriaLoading
);
message
.
error
(
'视频格式不支持,请上传MP4格式的文件'
,
2
);
if
(
successCallBack
&&
(
typeof
successCallBack
==
'function'
))
{
successCallBack
();
}
return
;
}
ajax
=
uploader
.
uploadVideoSignature
;
params
=
{
type
:
1
,
token
:
userInfo
.
token
,
schoolId
:
sid
};
break
;
case
3
:
// 录音
duration
=
yield
call
(
getAudioDuration
,
file
);
if
(
duration
==
0
)
{
yield
call
(
uploadMateriaLoading
);
message
.
error
(
'音频格式不支持,重新上传'
,
2
);
if
(
successCallBack
&&
(
typeof
successCallBack
==
'function'
))
{
successCallBack
();
}
return
;
}
ajax
=
uploader
.
uploadVideoSignature
;
params
=
{
type
:
2
,
token
:
userInfo
.
token
,
schoolId
:
sid
};
break
;
...
...
src/utils/index.js
View file @
452c7fe9
...
...
@@ -839,6 +839,15 @@ function getAudioDuration(file) {
duration
=
0
;
},
false
);
},
false
);
audioElement
.
addEventListener
(
'error'
,
(
event
)
=>
{
// eslint-disable-next-line prefer-destructuring
duration
=
audioElement
.
duration
;
resolve
(
0
);
// callback(duration);
audioElement
.
removeEventListener
(
'loadedmetadata'
,
(
event
)
=>
{
duration
=
0
;
},
false
);
},
false
);
});
}
function
getVideoDuration
(
file
)
{
...
...
@@ -848,6 +857,7 @@ function getVideoDuration(file) {
videoElement
.
id
=
'videoElement'
;
videoElement
.
src
=
url
;
let
duration
;
// document.body.appendChild(videoElement);
videoElement
.
addEventListener
(
'loadedmetadata'
,
(
event
)
=>
{
// eslint-disable-next-line prefer-destructuring
duration
=
videoElement
.
duration
;
...
...
@@ -857,6 +867,15 @@ function getVideoDuration(file) {
duration
=
0
;
},
false
);
},
false
);
videoElement
.
addEventListener
(
'error'
,
(
event
)
=>
{
// eslint-disable-next-line prefer-destructuring
// duration = videoElement.duration;
resolve
(
0
);
// callback(duration);
videoElement
.
removeEventListener
(
'loadedmetadata'
,
(
event
)
=>
{
duration
=
0
;
},
false
);
},
false
);
});
}
function
voiceTimeFormat
(
time
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment