Commit a143786c authored by baixian's avatar baixian

bug修改

parents b607a202 1c27a803
<component name="InspectionProjectProfileManager"> <component name="InspectionProjectProfileManager">
<profile version="1.0"> <profile version="1.0">
<option name="myName" value="Project Default" /> <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" /> <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
</profile> </profile>
</component> </component>
\ No newline at end of file
...@@ -17,6 +17,6 @@ ...@@ -17,6 +17,6 @@
</head> </head>
<body> <body>
<div id="root"></div> <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> </body>
</html> </html>
\ No newline at end of file
import { connect } from 'dva'; import { connect } from 'dva';
import React from 'react'; 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 pageStyle from './UploadCourseware.less';
import { import {
pageIn, pageIn,
...@@ -69,11 +69,26 @@ class UploadCourseware extends React.Component { ...@@ -69,11 +69,26 @@ class UploadCourseware extends React.Component {
}); });
delCourseware(); 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() { render() {
const { const {
visible, visible,
info, info,
chooseFromCourseMateria, chooseFromCourseMateria,
saveStatus,
loading,
} = this.props; } = this.props;
return ( return (
<Modal <Modal
...@@ -83,7 +98,7 @@ class UploadCourseware extends React.Component { ...@@ -83,7 +98,7 @@ class UploadCourseware extends React.Component {
onCancel={this.hide} onCancel={this.hide}
onOk={this.save} onOk={this.save}
className="UploadCoursewareContent" className="UploadCoursewareContent"
// confirmLoading={callStudentSubmitting} confirmLoading={loading}
zIndex={110} zIndex={110}
maskClosable={false} maskClosable={false}
width={600} width={600}
...@@ -113,6 +128,12 @@ class UploadCourseware extends React.Component { ...@@ -113,6 +128,12 @@ class UploadCourseware extends React.Component {
</div> </div>
</div> </div>
<div className={pageStyle.uploadBox} style={{ display: info.src ? 'block' : 'none' }}> <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 && {info.mediaType == 1 &&
<Carousel <Carousel
className={pageStyle.Carousel} className={pageStyle.Carousel}
...@@ -131,7 +152,7 @@ class UploadCourseware extends React.Component { ...@@ -131,7 +152,7 @@ class UploadCourseware extends React.Component {
} }
{info.mediaType == 2 && {info.mediaType == 2 &&
<div className={pageStyle.videobox}> <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}> <div className={pageStyle.videoplay}>
<img className={pageStyle.videoplayicon} src={`${__IMGCDN__}smallplayicon.png`} alt="" /> <img className={pageStyle.videoplayicon} src={`${__IMGCDN__}smallplayicon.png`} alt="" />
</div> </div>
...@@ -169,20 +190,27 @@ class UploadCourseware extends React.Component { ...@@ -169,20 +190,27 @@ class UploadCourseware extends React.Component {
<div className={pageStyle.uploaddesc}>MOV/MP4格式,大小≦**MB</div> <div className={pageStyle.uploaddesc}>MOV/MP4格式,大小≦**MB</div>
</div> </div>
<div className={pageStyle.right}> <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}`} /> <img src={`${__IMGCDN__}course/check.png`} alt="" className={`${pageStyle.btnicon} ${pageStyle.leftbtnicon}`} />
<span>素材库</span> <span>素材库</span>
</div> </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 && {info.src &&
<div className={pageStyle.delbtn} onClick={this.delCourseware}> <div className={pageStyle.delbtn} onClick={this.delCourseware}>
<Icon type="delete" className={pageStyle.delIcon} /> <Icon type="delete" className={pageStyle.delIcon} />
<span className={pageStyle.delText}>删除</span> <span className={pageStyle.delText}>删除</span>
</div> </div>
} }
{/* <div className={pageStyle.btn}>
<img src={`${__IMGCDN__}course/uploadImg.png`} alt="" className={`${pageStyle.btnicon} ${pageStyle.rightbtnicon}`} />
<span>上传</span>
</div> */}
</div> </div>
</div> </div>
</Modal> </Modal>
...@@ -193,10 +221,12 @@ function mapStateToProps(state) { ...@@ -193,10 +221,12 @@ function mapStateToProps(state) {
const { const {
visible, visible,
info, info,
saveStatus,
} = state.uploadcourseware; } = state.uploadcourseware;
return { return {
visible, visible,
info, info,
saveStatus,
}; };
} }
export default connect(mapStateToProps)(UploadCourseware); export default connect(mapStateToProps)(UploadCourseware);
......
...@@ -73,6 +73,16 @@ ...@@ -73,6 +73,16 @@
align-items: center; align-items: center;
justify-content: center; justify-content: center;
cursor: pointer; cursor: pointer;
position: relative;
.uploadInput {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
z-index: 2;
opacity: 0;
}
.btnicon { .btnicon {
display: block; display: block;
&.leftbtnicon { &.leftbtnicon {
...@@ -137,6 +147,9 @@ ...@@ -137,6 +147,9 @@
width: 100%; width: 100%;
height: 254px; height: 254px;
position: relative; position: relative;
display: flex;
align-items: center;
justify-content: center;
.videoImg { .videoImg {
max-width: 100%; max-width: 100%;
max-height: 100%; max-height: 100%;
...@@ -196,4 +209,31 @@ ...@@ -196,4 +209,31 @@
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; 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 { ...@@ -173,11 +173,27 @@ export default {
break; break;
case 2: // 视频 case 2: // 视频
duration = yield call(getVideoDuration, file); 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; ajax = uploader.uploadVideoSignature;
params = { type: 1, token: userInfo.token, schoolId: sid }; params = { type: 1, token: userInfo.token, schoolId: sid };
break; break;
case 3: // 录音 case 3: // 录音
duration = yield call(getAudioDuration, file); duration = yield call(getAudioDuration, file);
if (duration == 0) {
yield call(uploadMateriaLoading);
message.error('音频格式不支持,重新上传', 2);
if (successCallBack && (typeof successCallBack == 'function')) {
successCallBack();
}
return;
}
ajax = uploader.uploadVideoSignature; ajax = uploader.uploadVideoSignature;
params = { type: 2, token: userInfo.token, schoolId: sid }; params = { type: 2, token: userInfo.token, schoolId: sid };
break; break;
......
...@@ -961,6 +961,21 @@ export default { ...@@ -961,6 +961,21 @@ export default {
}, },
}); });
} else { } else {
yield put({
type: 'uploadcourseware/updateState',
payload: {
saveStatus: {
status: 0, // 1 转换中 2 保存中
text: '',
},
},
});
yield put({
type: 'updateState',
payload: {
coursewareSubmitting: false,
},
});
yield put({ yield put({
type: 'webapp/errorrequestresolve', type: 'webapp/errorrequestresolve',
payload: { payload: {
...@@ -1009,17 +1024,41 @@ export default { ...@@ -1009,17 +1024,41 @@ export default {
}, },
}); });
} else { } else {
yield put({
type: 'uploadcourseware/updateState',
payload: {
saveStatus: {
status: 0, // 1 转换中 2 保存中
text: '',
},
},
});
yield put({ yield put({
type: 'webapp/errorrequestresolve', type: 'webapp/errorrequestresolve',
payload: { payload: {
data: transformData, data: transformData,
}, },
}); });
yield put({
type: 'updateState',
payload: {
coursewareSubmitting: false,
},
});
} }
}, },
* uploadCourseware({ payload }, { call, put, select }) { * uploadCourseware({ payload }, { call, put, select }) {
const { info } = payload; const { info } = payload;
const { addCourseObj, coursewareSubmitting } = yield select(state => state.onlineclasses); const { addCourseObj, coursewareSubmitting } = yield select(state => state.onlineclasses);
if (coursewareSubmitting) {
return;
}
yield put({
type: 'updateState',
payload: {
coursewareSubmitting: true,
},
});
const { from } = info; const { from } = info;
if (from == 'upload') { // 课件上传得到需要转码 if (from == 'upload') { // 课件上传得到需要转码
if (info.type == 4) { // 其他文件需要转码 if (info.type == 4) { // 其他文件需要转码
...@@ -1029,6 +1068,15 @@ export default { ...@@ -1029,6 +1068,15 @@ export default {
info, info,
}, },
}); });
yield put({
type: 'uploadcourseware/updateState',
payload: {
saveStatus: {
status: 1, // 1 转换中 2 保存中
text: '文件解析中,请稍等...',
},
},
});
} else { } else {
yield put({ yield put({
type: 'saveCourseWare', type: 'saveCourseWare',
...@@ -1059,6 +1107,12 @@ export default { ...@@ -1059,6 +1107,12 @@ export default {
}, },
}); });
} else { // 打开弹窗没操作 直接关闭弹窗 } else { // 打开弹窗没操作 直接关闭弹窗
yield put({
type: 'updateState',
payload: {
coursewareSubmitting: false,
},
});
yield put({ yield put({
type: 'uploadcourseware/updateState', type: 'uploadcourseware/updateState',
payload: { payload: {
...@@ -1071,19 +1125,28 @@ export default { ...@@ -1071,19 +1125,28 @@ export default {
* saveCourseWare({ payload }, { call, put, select }) { * saveCourseWare({ payload }, { call, put, select }) {
const { info } = payload; const { info } = payload;
const { addCourseObj, coursewareSubmitting } = yield select(state => state.onlineclasses); const { addCourseObj, coursewareSubmitting } = yield select(state => state.onlineclasses);
if (coursewareSubmitting) { // if (coursewareSubmitting) {
return; // return;
// }
// yield put({
// type: 'updateState',
// payload: {
// coursewareSubmitting: true,
// },
// });
if (info.from) {
delete info.from;
} }
yield put({ yield put({
type: 'updateState', type: 'uploadcourseware/updateState',
payload: { payload: {
coursewareSubmitting: true, saveStatus: {
status: 2, // 1 转换中 2 保存中
text: '保存中...',
},
}, },
}); });
if (info.from) { // const loadmessage = message.loading('保存中...', 0);
delete info.from;
}
const loadmessage = message.loading('保存中...', 0);
const data = yield call(courseMateriaAjax.uploadCourseware, { const data = yield call(courseMateriaAjax.uploadCourseware, {
content: JSON.stringify(info), content: JSON.stringify(info),
id: addCourseObj.id, id: addCourseObj.id,
...@@ -1094,7 +1157,7 @@ export default { ...@@ -1094,7 +1157,7 @@ export default {
coursewareSubmitting: false, coursewareSubmitting: false,
}, },
}); });
setTimeout(loadmessage); console.log(1111111111111);
if (data.code == 200) { if (data.code == 200) {
yield put({ yield put({
type: 'uploadcourseware/updateState', type: 'uploadcourseware/updateState',
...@@ -1103,6 +1166,15 @@ export default { ...@@ -1103,6 +1166,15 @@ export default {
info: {}, info: {},
}, },
}); });
yield put({
type: 'uploadcourseware/updateState',
payload: {
saveStatus: {
status: 0, // 1 转换中 2 保存中
text: '',
},
},
});
yield put({ yield put({
type: 'updateState', type: 'updateState',
payload: { payload: {
...@@ -1125,7 +1197,17 @@ export default { ...@@ -1125,7 +1197,17 @@ export default {
params: {}, params: {},
}, },
}); });
message.success('课件保存成功...', 1);
} else { } else {
yield put({
type: 'uploadcourseware/updateState',
payload: {
saveStatus: {
status: 0, // 1 转换中 2 保存中
text: '',
},
},
});
yield put({ yield put({
type: 'webapp/errorrequestresolve', type: 'webapp/errorrequestresolve',
payload: { payload: {
......
...@@ -20,6 +20,10 @@ export default { ...@@ -20,6 +20,10 @@ export default {
state: { state: {
visible: false, visible: false,
info: {}, info: {},
saveStatus: {
status: 0, // 1 转换中 2 保存中
text: '',
},
}, },
subscriptions: { subscriptions: {
setup({ dispatch, history }) { // eslint-disable-line setup({ dispatch, history }) { // eslint-disable-line
...@@ -72,7 +76,7 @@ export default { ...@@ -72,7 +76,7 @@ export default {
return; return;
} }
let signature = {}; let signature = {};
const uploaderLoading = message.loading('件上传中...'); const uploaderLoading = message.loading('件上传中...');
const uploadSignature = yield call(ajax, params); const uploadSignature = yield call(ajax, params);
signature = uploadSignature.data; signature = uploadSignature.data;
if (uploadSignature.code == 200) { if (uploadSignature.code == 200) {
......
...@@ -124,13 +124,13 @@ class CourseBoxForm extends React.Component { ...@@ -124,13 +124,13 @@ class CourseBoxForm extends React.Component {
<List <List
size="large" size="large"
grid={{ grid={{
gutter: 20, gutter: 10,
xs: 1, xs: 1,
sm: 1, sm: 1,
md: 1, md: 1,
lg: 2, lg: 2,
xl: 2, xl: 3,
xxl: 3, xxl: 4,
}} }}
dataSource={list} dataSource={list}
footer={ footer={
......
...@@ -839,6 +839,15 @@ function getAudioDuration(file) { ...@@ -839,6 +839,15 @@ function getAudioDuration(file) {
duration = 0; duration = 0;
}, false); }, false);
}, 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) { function getVideoDuration(file) {
...@@ -848,6 +857,7 @@ function getVideoDuration(file) { ...@@ -848,6 +857,7 @@ function getVideoDuration(file) {
videoElement.id = 'videoElement'; videoElement.id = 'videoElement';
videoElement.src = url; videoElement.src = url;
let duration; let duration;
// document.body.appendChild(videoElement);
videoElement.addEventListener('loadedmetadata', (event) => { videoElement.addEventListener('loadedmetadata', (event) => {
// eslint-disable-next-line prefer-destructuring // eslint-disable-next-line prefer-destructuring
duration = videoElement.duration; duration = videoElement.duration;
...@@ -857,6 +867,15 @@ function getVideoDuration(file) { ...@@ -857,6 +867,15 @@ function getVideoDuration(file) {
duration = 0; duration = 0;
}, false); }, false);
}, 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) { 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