Commit cc0b9bff authored by wangxuelai's avatar wangxuelai

'最新代码上传'

parent 2bf6e956
......@@ -17,6 +17,6 @@
</head>
<body>
<div id="root"></div>
<script src="dist/main.js?1574643991048" charset="utf-8"></script>
<script src="dist/main.js?1574661027178" charset="utf-8"></script>
</body>
</html>
\ No newline at end of file
......@@ -91,9 +91,9 @@ class MaterialModalForm extends React.Component {
<div className={pageStyle.item}>
<Radio value={item}>
{item.type === 1 && <img className={pageStyle.img} src={imagify(item.src)} alt="" />}
{item.type === 2 && <img className={pageStyle.img} src={`${__IMGCDN__}/course/video_default.PNG`} alt="" />}
{item.type === 3 && <img className={pageStyle.img} src={`${__IMGCDN__}/course/audio_default.PNG`} alt="" />}
{item.type === 4 && <img className={pageStyle.img} src={`${__IMGCDN__}/course/ppt_default.PNG`} alt="" />}
{item.type === 2 && <img className={pageStyle.img} src={`${__IMGCDN__}course/video_default.png`} alt="" />}
{item.type === 3 && <img className={pageStyle.img} src={`${__IMGCDN__}course/audio_default.png`} alt="" />}
{item.type === 4 && <img className={pageStyle.img} src={`${__IMGCDN__}course/ppt_default.png`} alt="" />}
</Radio>
</div>
</List.Item>
......
import { connect } from 'dva';
import React from 'react';
import { Button, Row, 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 } from 'antd';
import pageStyle from './UploadCourseware.less';
import { pageIn } from '../utils/index';
import {
pageIn,
imagify,
videoPoster,
audioorigin,
pptImagify,
} from '../utils/index';
const { Option } = Select;
const { TextArea } = Input;
const { Group } = Radio;
......@@ -69,6 +75,7 @@ class UploadCourseware extends React.Component {
info,
chooseFromCourseMateria,
} = this.props;
console.log(info, '1111111');
return (
<Modal
visible={visible}
......@@ -107,17 +114,54 @@ class UploadCourseware extends React.Component {
</div>
</div>
<div className={pageStyle.uploadBox} style={{ display: info.src ? 'block' : 'none' }}>
{info.type == 1 &&
<div>图片</div>
{info.mediaType == 1 &&
<Carousel
className={pageStyle.Carousel}
ref={this.ref}
draggable
>
{info.images.map((ele, index) => {
return (
<div className={pageStyle.CarouselBox} key={ele} >
<img className={pageStyle.CarouselImg} alt="" src={imagify(ele)} />
</div>
);
})
}
</Carousel>
}
{info.type == 2 &&
<div>视频</div>
{info.mediaType == 2 &&
<div className={pageStyle.videobox}>
<img className={pageStyle.videoImg} alt="" src={videoPoster(info.src)} />
<div className={pageStyle.videoplay}>
<img className={pageStyle.videoplayicon} src={`${__IMGCDN__}smallplayicon.png`} alt="" />
</div>
</div>
}
{info.type == 3 &&
<div>录音</div>
{info.mediaType == 3 &&
<audio controls="controls" className={pageStyle.audio} src={audioorigin(info.src)} />
}
{(info.mediaType == 4 || info.mediaType == 5) && info.from == 'upload' &&
<div className={`${pageStyle.mediaBox} ${pageStyle.fileBox}`}>
<img className={pageStyle.fileIcon} src={`${__IMGCDN__}/course/ppt_icon.png`} alt="" />
<div className={pageStyle.fileName}>{info.properties.name}</div>
</div>
}
{info.type == 4 &&
<div>文件</div>
{(info.mediaType == 4 || info.mediaType == 5) && info.from != 'upload' &&
<Carousel
className={pageStyle.Carousel}
ref={this.ref}
draggable
>
{info.images.map((ele, index) => {
return (
<div className={pageStyle.CarouselBox} key={ele} >
<img className={pageStyle.CarouselImg} alt="" src={pptImagify(ele)} />
</div>
);
})
}
</Carousel>
}
</div>
<div className={pageStyle.uploadbottom}>
......
......@@ -8,9 +8,11 @@
.uploadBox {
width: 100%;
height: 254px;
overflow: hidden;
border-radius: 10px;
border:2px dashed rgba(194,194,194,1);
margin: 0 auto;
position: relative;
.uploadBoxTitle {
color: #575757;
font-size: 16px;
......@@ -106,4 +108,92 @@
font-size: 14px;
}
}
}
.Carousel {
z-index: 2;
width: 100%;
height: 100%;
position: relative;
}
.CarouselBox {
z-index: 2;
width: 100%;
// height: 100%;
height: 254px;
position: relative;
}
.CarouselImg {
position: absolute;
display: block;
max-width: 100%;
max-height: 100%;
width: 100%;
height: 254px;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.videobox {
width: 100%;
height: 254px;
position: relative;
.videoImg {
max-width: 100%;
max-height: 100%;
display: block;
margin: 0 auto;
// height: 254px;
}
.videoplay {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 55px;
height: 55px;
border-radius: 50%;
border:2px solid rgba(255,255,255,1);
background:rgba(0,0,0,0.3);
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
.videoplayicon {
width: 14px;
height: 16px;
}
}
}
.audio {
margin: 0 auto;
display: block;
line-height: 254px;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.fileBox {
background-color: #FFB879;
height: 254px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.fileIcon {
width: 57px;
height: 51px;
margin: 0 auto 18px;
display: block;
}
.fileName {
color:rgba(255,255,255,1);
text-align: center;
margin: 0 auto;
text-align: center;
max-width: 80%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
\ No newline at end of file
......@@ -1414,8 +1414,9 @@ export default {
},
});
let saveData = null;
console.log(value, 'value');
if (editSingleCourseId == 0) {
const saveData = yield call(onlineAjax.createGatherSingleCourse, {
saveData = yield call(onlineAjax.createGatherSingleCourse, {
...editSingleCourseInfo,
...value,
id,
......@@ -1504,6 +1505,9 @@ export default {
const { data, code } = transformData;
if (code == 200) {
if (editSingleCourseId == 0) {
if (info.from) {
delete info.from;
}
yield put({
type: 'updateState',
payload: {
......@@ -1511,7 +1515,7 @@ export default {
...editSingleCourseInfo,
content: {
...info,
images: info.type == 1 ? [info.src] : [],
images: transformData.data.result,
},
},
},
......@@ -1533,9 +1537,15 @@ export default {
coursewareSubmitting: true,
},
});
if (info.from) {
delete info.from;
}
const loadmessage = message.loading('保存中...', 0);
const data = yield call(courseMateriaAjax.uploadCourseware, {
content: JSON.stringify(info),
content: JSON.stringify({
...info,
images: transformData.data.result,
}),
id: editSingleCourseId,
});
yield put({
......@@ -1602,6 +1612,9 @@ export default {
});
} else {
if (editSingleCourseId == 0) {
if (info.from) {
delete info.from;
}
yield put({
type: 'updateState',
payload: {
......@@ -1631,6 +1644,9 @@ export default {
coursewareSubmitting: true,
},
});
if (info.from) {
delete info.from;
}
const loadmessage = message.loading('保存中...', 0);
const data = yield call(courseMateriaAjax.uploadCourseware, {
content: JSON.stringify(info),
......@@ -1672,6 +1688,9 @@ export default {
}
} else {
if (editSingleCourseId == 0) {
if (info.from) {
delete info.from;
}
yield put({
type: 'updateState',
payload: {
......@@ -1698,6 +1717,9 @@ export default {
coursewareSubmitting: true,
},
});
if (info.from) {
delete info.from;
}
const loadmessage = message.loading('保存中...', 0);
const data = yield call(courseMateriaAjax.uploadCourseware, {
content: JSON.stringify(info),
......
......@@ -123,7 +123,7 @@ export default {
size,
fileType,
},
images: [],
images: getFileType(fileType).filetype == 1 ? [filename] : [],
src: filename,
fileType,
type: getFileType(fileType).filetype,
......
......@@ -17,5 +17,6 @@
margin-bottom: 20px;
}
.container {
padding: 31px 21px
padding: 31px 21px;
min-height: calc(100vh - 280px);
}
......@@ -350,6 +350,8 @@ class StaticCenter extends React.Component {
}
materialSave = (values) => {
const { dispatch, materiaSaveTo, editSingleCourseInfo } = this.props;
console.log(values, 'values');
console.log(materiaSaveTo, 'materiaSaveTo');
if (materiaSaveTo == 1) {
dispatch({
type: 'coursegatherdetail/updateCover',
......@@ -374,12 +376,15 @@ class StaticCenter extends React.Component {
materialVisible: false,
},
});
const content = JSON.parse(values.checkValue.content);
const { images } = content;
delete content.images;
dispatch({
type: 'uploadcourseware/updateState',
payload: {
info: JSON.parse(JSON.stringify({
properties: JSON.parse(values.checkValue.content),
images: [],
properties: content,
images,
src: values.checkValue.src,
fileType: JSON.parse(values.checkValue.content).fileType,
type: getFileType(JSON.parse(values.checkValue.content).fileType).filetype,
......@@ -497,6 +502,7 @@ class StaticCenter extends React.Component {
uploadCourseware = (values) => {
const { dispatch } = this.props;
const { addWareType } = this.state;
console.log(addWareType, 'asdasdas');
if (addWareType == 1) {
dispatch({
type: 'coursegatherdetail/saveCourseWare',
......
......@@ -2,6 +2,7 @@
.container {
background-color: #fff;
border-radius: 6px;
min-height: calc(100vh - 110px);
}
.tabbox {
box-shadow:0px 6px 6px 0px rgba(0, 0, 0, 0.04);
......
.container {
min-height: calc(100vh - 220px - 44px);
}
.hreflink {
font-size:14px;
font-family:PingFang SC;
......
......@@ -377,7 +377,7 @@ class CourseDetailForm extends React.Component {
</FormItem>
<FormItem {...formItemModalLineLayout} label="开课时间">
{getFieldDecorator('start_time', {
initialValue: moment(addCourseObj.start_time, 'YYYY-MM-DD HH:mm'),
initialValue: addCourseObj.start_time ? moment(addCourseObj.start_time, 'YYYY-MM-DD HH:mm') : null,
rules: [
{
required: true,
......
.container {
background-color: #fff;
position: relative;
min-height: calc(100vh - 110px);
.head {
height: 70px;
width: 100%;
......
.container {
padding-bottom: 20px;
width: 100%;
min-height: calc(100vh - 110px);
.head {
//height: 100px;
//width: 100%;
......
......@@ -43,6 +43,24 @@ export function imagify(src, params) {
}
return Src;
}
function pptImagify(src, params) {
const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/g;
if (reg.test(src)) {
return src;
}
if (!src) return '';
let Src = src;
if (src.indexOf('//tmp') != -1) {
return Src;
}
if (src.indexOf('cdn.img.shangjiadao.cn') == -1) {
Src = `https://media.shangjiadao.cn/${src}`;
}
if (params) {
Src = `${Src}?x-oss-process=${params}`;
}
return Src;
}
function pathify(path) {
return typeof path === 'string' ? path.replace(/\/(sjd|activity)_\w+/, '/') : path;
}
......@@ -843,4 +861,5 @@ export {
getWeekDay,
getDateStamp,
getFileType,
pptImagify,
};
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