Commit a143786c authored by baixian's avatar baixian

bug修改

parents b607a202 1c27a803
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="CssUnknownProperty" enabled="true" level="WARNING" enabled_by_default="true">
<option name="myCustomPropertiesEnabled" value="true" />
<option name="myIgnoreVendorSpecificProperties" value="false" />
<option name="myCustomPropertiesList">
<value>
<list size="1">
<item index="0" class="java.lang.String" itemvalue="textoverflow" />
</list>
</value>
</option>
</inspection_tool>
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
</profile>
</component>
\ No newline at end of file
......@@ -17,6 +17,6 @@
</head>
<body>
<div id="root"></div>
<script src="dist/main.js?1574827384999" charset="utf-8"></script>
<script src="dist/main.js?1574837184040" charset="utf-8"></script>
</body>
</html>
\ No newline at end of file
import { connect } from 'dva';
import React from 'react';
import { Button, Row, Carousel, Icon, Col, Input, Select, Pagination, Radio, DatePicker, Modal, Form, TimePicker, InputNumber, Table } from 'antd';
import { Button, Row, Carousel, Icon, Col, Input, Select, Pagination, Radio, DatePicker, Modal, Form, TimePicker, InputNumber, Table, Spin } from 'antd';
import pageStyle from './UploadCourseware.less';
import {
pageIn,
......@@ -69,11 +69,26 @@ 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,
info,
chooseFromCourseMateria,
saveStatus,
loading,
} = this.props;
return (
<Modal
......@@ -83,7 +98,7 @@ class UploadCourseware extends React.Component {
onCancel={this.hide}
onOk={this.save}
className="UploadCoursewareContent"
// confirmLoading={callStudentSubmitting}
confirmLoading={loading}
zIndex={110}
maskClosable={false}
width={600}
......@@ -113,6 +128,12 @@ class UploadCourseware extends React.Component {
</div>
</div>
<div className={pageStyle.uploadBox} style={{ display: info.src ? 'block' : 'none' }}>
{saveStatus.status != 0 &&
<div className={`${pageStyle.uploadLoading} uploadLoading`}>
<Spin size="large" wrapperClassName={pageStyle.uploadLoadingSpin} />
<div className={pageStyle.uploadLoadingText}>{saveStatus.text}</div>
</div>
}
{info.mediaType == 1 &&
<Carousel
className={pageStyle.Carousel}
......@@ -131,7 +152,7 @@ class UploadCourseware extends React.Component {
}
{info.mediaType == 2 &&
<div className={pageStyle.videobox}>
<img className={pageStyle.videoImg} alt="" src={videoPoster(info.src)} />
<img className={pageStyle.videoImg} alt="" id="videoposter" src={videoPoster(info.src)} onError={() => this.reLoadVideoPoster(info.src)} />
<div className={pageStyle.videoplay}>
<img className={pageStyle.videoplayicon} src={`${__IMGCDN__}smallplayicon.png`} alt="" />
</div>
......@@ -169,20 +190,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>
......@@ -193,10 +221,12 @@ function mapStateToProps(state) {
const {
visible,
info,
saveStatus,
} = state.uploadcourseware;
return {
visible,
info,
saveStatus,
};
}
export default connect(mapStateToProps)(UploadCourseware);
......
......@@ -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%;
......@@ -196,4 +209,31 @@
text-overflow: ellipsis;
white-space: nowrap;
}
}
:global {
.uploadLoading {
.ant-spin-dot-item {
background-color: #fff;
}
}
}
.uploadLoading {
position: absolute;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.6);
z-index: 5;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
.uploadLoadingText {
text-align: center;
color: #fff;
font-size: 18px;
position: relative;
z-index: 6;
font-weight: 700;
margin-top: 10px;
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -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;
......
......@@ -961,6 +961,21 @@ export default {
},
});
} else {
yield put({
type: 'uploadcourseware/updateState',
payload: {
saveStatus: {
status: 0, // 1 转换中 2 保存中
text: '',
},
},
});
yield put({
type: 'updateState',
payload: {
coursewareSubmitting: false,
},
});
yield put({
type: 'webapp/errorrequestresolve',
payload: {
......@@ -1009,17 +1024,41 @@ export default {
},
});
} else {
yield put({
type: 'uploadcourseware/updateState',
payload: {
saveStatus: {
status: 0, // 1 转换中 2 保存中
text: '',
},
},
});
yield put({
type: 'webapp/errorrequestresolve',
payload: {
data: transformData,
},
});
yield put({
type: 'updateState',
payload: {
coursewareSubmitting: false,
},
});
}
},
* uploadCourseware({ payload }, { call, put, select }) {
const { info } = payload;
const { addCourseObj, coursewareSubmitting } = yield select(state => state.onlineclasses);
if (coursewareSubmitting) {
return;
}
yield put({
type: 'updateState',
payload: {
coursewareSubmitting: true,
},
});
const { from } = info;
if (from == 'upload') { // 课件上传得到需要转码
if (info.type == 4) { // 其他文件需要转码
......@@ -1029,6 +1068,15 @@ export default {
info,
},
});
yield put({
type: 'uploadcourseware/updateState',
payload: {
saveStatus: {
status: 1, // 1 转换中 2 保存中
text: '文件解析中,请稍等...',
},
},
});
} else {
yield put({
type: 'saveCourseWare',
......@@ -1059,6 +1107,12 @@ export default {
},
});
} else { // 打开弹窗没操作 直接关闭弹窗
yield put({
type: 'updateState',
payload: {
coursewareSubmitting: false,
},
});
yield put({
type: 'uploadcourseware/updateState',
payload: {
......@@ -1071,19 +1125,28 @@ export default {
* saveCourseWare({ payload }, { call, put, select }) {
const { info } = payload;
const { addCourseObj, coursewareSubmitting } = yield select(state => state.onlineclasses);
if (coursewareSubmitting) {
return;
// if (coursewareSubmitting) {
// return;
// }
// yield put({
// type: 'updateState',
// payload: {
// coursewareSubmitting: true,
// },
// });
if (info.from) {
delete info.from;
}
yield put({
type: 'updateState',
type: 'uploadcourseware/updateState',
payload: {
coursewareSubmitting: true,
saveStatus: {
status: 2, // 1 转换中 2 保存中
text: '保存中...',
},
},
});
if (info.from) {
delete info.from;
}
const loadmessage = message.loading('保存中...', 0);
// const loadmessage = message.loading('保存中...', 0);
const data = yield call(courseMateriaAjax.uploadCourseware, {
content: JSON.stringify(info),
id: addCourseObj.id,
......@@ -1094,7 +1157,7 @@ export default {
coursewareSubmitting: false,
},
});
setTimeout(loadmessage);
console.log(1111111111111);
if (data.code == 200) {
yield put({
type: 'uploadcourseware/updateState',
......@@ -1103,6 +1166,15 @@ export default {
info: {},
},
});
yield put({
type: 'uploadcourseware/updateState',
payload: {
saveStatus: {
status: 0, // 1 转换中 2 保存中
text: '',
},
},
});
yield put({
type: 'updateState',
payload: {
......@@ -1125,7 +1197,17 @@ export default {
params: {},
},
});
message.success('课件保存成功...', 1);
} else {
yield put({
type: 'uploadcourseware/updateState',
payload: {
saveStatus: {
status: 0, // 1 转换中 2 保存中
text: '',
},
},
});
yield put({
type: 'webapp/errorrequestresolve',
payload: {
......
......@@ -20,6 +20,10 @@ export default {
state: {
visible: false,
info: {},
saveStatus: {
status: 0, // 1 转换中 2 保存中
text: '',
},
},
subscriptions: {
setup({ dispatch, history }) { // eslint-disable-line
......@@ -72,7 +76,7 @@ export default {
return;
}
let signature = {};
const uploaderLoading = message.loading('件上传中...');
const uploaderLoading = message.loading('件上传中...');
const uploadSignature = yield call(ajax, params);
signature = uploadSignature.data;
if (uploadSignature.code == 200) {
......
......@@ -124,13 +124,13 @@ class CourseBoxForm extends React.Component {
<List
size="large"
grid={{
gutter: 20,
gutter: 10,
xs: 1,
sm: 1,
md: 1,
lg: 2,
xl: 2,
xxl: 3,
xl: 3,
xxl: 4,
}}
dataSource={list}
footer={
......
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment