Commit 4f481ca9 authored by wangxuelai's avatar wangxuelai

''

parents e7ada6d0 e0b0bbb0
...@@ -186,6 +186,7 @@ export default { ...@@ -186,6 +186,7 @@ export default {
importCourse: `${dakaapi}member/online_courses_import_sub_course`, importCourse: `${dakaapi}member/online_courses_import_sub_course`,
staticTotal: `${dakaapi}member/online_courses_total`, staticTotal: `${dakaapi}member/online_courses_total`,
staticChart: `${dakaapi}member/online_courses_chart`, staticChart: `${dakaapi}member/online_courses_chart`,
comments: `${dakaapi}common/website/comments`,
}, },
courseMateria: { courseMateria: {
index: `${dakaapi}member/materials`, index: `${dakaapi}member/materials`,
......
...@@ -6,7 +6,7 @@ import moment from 'moment'; ...@@ -6,7 +6,7 @@ import moment from 'moment';
import { import {
LocalStorage, LocalStorage,
SessionStorage, SessionStorage,
isExpired, getRandomFilename, isExpired, getRandomFilename, imagify,
} from '../utils/index'; } from '../utils/index';
import errorcode from '../common/errorcode'; import errorcode from '../common/errorcode';
import * as onlineAjax from '../services/onlineclasses'; import * as onlineAjax from '../services/onlineclasses';
...@@ -50,6 +50,12 @@ export default { ...@@ -50,6 +50,12 @@ export default {
}, },
materiaList: [], materiaList: [],
materiaListTotal: 0, materiaListTotal: 0,
commentList: [],
commentParams: {
page: 1,
perPage: 10,
},
commentListTotal: 0,
}, },
subscriptions: { subscriptions: {
setup({ dispatch, history }) { // eslint-disable-line setup({ dispatch, history }) { // eslint-disable-line
...@@ -168,6 +174,47 @@ export default { ...@@ -168,6 +174,47 @@ export default {
}); });
} }
}, },
* selectComment({ payload }, { call, put, select }) {
const { params } = payload;
const { commentParams } = yield select(state => state.onlineclasses);
const newParams = Object.assign(commentParams, params, {
source_type: 4,
});
const data = yield call(onlineAjax.selectComment, newParams);
if (data.code == 200) {
yield put({
type: 'updateState',
payload: {
commentList: data.data && data.data.list,
commentListTotal: data.data && data.data.total,
},
});
} else {
yield put({
type: 'webapp/errorrequestresolve',
payload: {
data,
},
});
}
},
* commentStick({ payload }, { call, put, select }) {
const { id, place_top } = payload;
const data = yield call(onlineAjax.commentStick, {
id,
place_top,
});
if (data.code == 200) {
message.success('修改成功', 0.5);
} else {
yield put({
type: 'webapp/errorrequestresolve',
payload: {
data,
},
});
}
},
* findCourse({ payload }, { call, put, select }) { * findCourse({ payload }, { call, put, select }) {
const { sid } = yield select(state => state.webapp); const { sid } = yield select(state => state.webapp);
const { id } = payload; const { id } = payload;
...@@ -213,6 +260,14 @@ export default { ...@@ -213,6 +260,14 @@ export default {
id: data.data.id, id: data.data.id,
}, },
}); });
yield put({
type: 'selectComment',
payload: {
params: {
source_id: data.data.id,
},
},
});
} else { } else {
yield put({ yield put({
type: 'webapp/errorrequestresolve', type: 'webapp/errorrequestresolve',
...@@ -476,7 +531,9 @@ export default { ...@@ -476,7 +531,9 @@ export default {
* queryvideosignature({ payload }, { call, put, select }) { * queryvideosignature({ payload }, { call, put, select }) {
const { avatorUploader } = yield select(state => state.uploader); const { avatorUploader } = yield select(state => state.uploader);
const { userInfo, sid } = yield select(state => state.webapp); const { userInfo, sid } = yield select(state => state.webapp);
const { files, uploadtype, orgIndex } = payload; const {
files, uploadtype, orgIndex, time,
} = payload;
const file = files.files ? files.files[0] : null; const file = files.files ? files.files[0] : null;
const REGEXP_VIDEO = /^video\/\w+/; const REGEXP_VIDEO = /^video\/\w+/;
const params = { type: 1, token: userInfo.token, schoolId: sid }; const params = { type: 1, token: userInfo.token, schoolId: sid };
...@@ -492,6 +549,7 @@ export default { ...@@ -492,6 +549,7 @@ export default {
files, files,
uploadtype, uploadtype,
orgIndex, orgIndex,
time,
}, },
}); });
} }
...@@ -499,6 +557,7 @@ export default { ...@@ -499,6 +557,7 @@ export default {
* uploadvideo({ payload }, { call, put, select }) { * uploadvideo({ payload }, { call, put, select }) {
const { const {
signature, files, uploadtype, orgIndex, signature, files, uploadtype, orgIndex,
time,
} = payload; } = payload;
const file = files.files ? files.files[0] : null; const file = files.files ? files.files[0] : null;
const uploaderLoading = message.loading('正在上传视频', 0); const uploaderLoading = message.loading('正在上传视频', 0);
...@@ -518,6 +577,8 @@ export default { ...@@ -518,6 +577,8 @@ export default {
addCourseObj.intro.push({ addCourseObj.intro.push({
type: 'video', type: 'video',
value: videoUrl, value: videoUrl,
// eslint-disable-next-line radix
duration: parseInt(time),
}); });
yield put({ yield put({
type: 'updateState', type: 'updateState',
...@@ -530,7 +591,7 @@ export default { ...@@ -530,7 +591,7 @@ export default {
}, },
* queryvoiceignature({ payload }, { call, put, select }) { * queryvoiceignature({ payload }, { call, put, select }) {
const { userInfo, sid } = yield select(state => state.webapp); const { userInfo, sid } = yield select(state => state.webapp);
const { files, uploadtype } = payload; const { files, uploadtype, time } = payload;
const file = files.files ? files.files[0] : null; const file = files.files ? files.files[0] : null;
const REGEXP_VIDEO = /^audio\/\w+/; const REGEXP_VIDEO = /^audio\/\w+/;
const params = { type: 2, token: userInfo.token, schoolId: sid }; const params = { type: 2, token: userInfo.token, schoolId: sid };
...@@ -547,6 +608,7 @@ export default { ...@@ -547,6 +608,7 @@ export default {
files, files,
uploaderLoading, uploaderLoading,
uploadtype, uploadtype,
time,
}, },
}); });
} else { } else {
...@@ -563,6 +625,7 @@ export default { ...@@ -563,6 +625,7 @@ export default {
* uploadaudio({ payload }, { call, put, select }) { * uploadaudio({ payload }, { call, put, select }) {
const { const {
signature, files, uploaderLoading, uploadtype, signature, files, uploaderLoading, uploadtype,
time,
} = payload; } = payload;
const file = files.files ? files.files[0] : null; const file = files.files ? files.files[0] : null;
const { addCourseObj } = yield select(state => state.onlineclasses); const { addCourseObj } = yield select(state => state.onlineclasses);
...@@ -589,6 +652,8 @@ export default { ...@@ -589,6 +652,8 @@ export default {
addCourseObj.intro.push({ addCourseObj.intro.push({
type: 'audio', type: 'audio',
value: audioUrl, value: audioUrl,
// eslint-disable-next-line radix
duration: parseInt(time),
}); });
yield put({ yield put({
type: 'updateState', type: 'updateState',
...@@ -718,6 +783,12 @@ export default { ...@@ -718,6 +783,12 @@ export default {
editLoading: false, editLoading: false,
materialVisible: false, materialVisible: false,
courseChartData: {}, courseChartData: {},
commentList: [],
commentParams: {
page: 1,
perPage: 10,
},
commentListTotal: 0,
}, },
}); });
}, },
......
...@@ -32,8 +32,51 @@ class ThemeEditor extends React.Component { ...@@ -32,8 +32,51 @@ class ThemeEditor extends React.Component {
previewVisible: false, previewVisible: false,
}); });
} }
editorUploadVideo = (e) => {
const { editorUploadVideo } = this.props;
const filesTarget = e.target;
// 获取视频时长
const obj_file = document.getElementById('uploadVideo');
const content = obj_file.files[0];
const url = URL.createObjectURL(content);
const videoElement = new Audio(url);
let duration;
videoElement.addEventListener('loadedmetadata', (event) => {
// eslint-disable-next-line prefer-destructuring
duration = videoElement.duration;
editorUploadVideo({
files: filesTarget,
uploadtype: 'uploadVideo',
time: duration,
});
videoElement.removeEventListener('loadedmetadata', (event) => {
duration = 0;
}, false);
}, false);
}
editorUploadAudio = (e) => {
const { editorUploadAudio } = this.props;
const filesTarget = e.target;
const obj_file = document.getElementById('uploadAudio');
const content = obj_file.files[0];
const url = URL.createObjectURL(content);
const audioElement = new Audio(url);
let duration;
audioElement.addEventListener('loadedmetadata', (event) => {
// eslint-disable-next-line prefer-destructuring
duration = audioElement.duration;
editorUploadAudio({
files: filesTarget,
uploadtype: 'uploadDescAudio',
time: duration,
});
audioElement.removeEventListener('loadedmetadata', (event) => {
duration = 0;
}, false);
}, false);
}
render() { render() {
const { previewVisible, previewImage } = this.state; const { previewVisible, previewImage, time } = this.state;
const { const {
editorUploadImg, editorUploadImg,
commentParams, commentParams,
...@@ -44,7 +87,6 @@ class ThemeEditor extends React.Component { ...@@ -44,7 +87,6 @@ class ThemeEditor extends React.Component {
moveContent, moveContent,
editorUploadVideo, editorUploadVideo,
} = this.props; } = this.props;
console.log(commentParams, 'commentParams1111111111111');
return ( return (
<div className={pageStyle.container}> <div className={pageStyle.container}>
<div className={pageStyle.editorwrap}> <div className={pageStyle.editorwrap}>
...@@ -118,8 +160,8 @@ class ThemeEditor extends React.Component { ...@@ -118,8 +160,8 @@ class ThemeEditor extends React.Component {
<div className={pageStyle.uploadflex}> <div className={pageStyle.uploadflex}>
<div className={pageStyle.uploadimg} onClick={editorAddText}><Icon style={{ marginRight: 10 }} type="font-size" />添加文字</div> <div className={pageStyle.uploadimg} onClick={editorAddText}><Icon style={{ marginRight: 10 }} type="font-size" />添加文字</div>
<div className={pageStyle.uploadimg}><input type="file" id="uploadImg" className={pageStyle.fileuploadinput} onChange={editorUploadImg} accept="image/*" /><Icon style={{ marginRight: 10 }} type="picture" />添加图片</div> <div className={pageStyle.uploadimg}><input type="file" id="uploadImg" className={pageStyle.fileuploadinput} onChange={editorUploadImg} accept="image/*" /><Icon style={{ marginRight: 10 }} type="picture" />添加图片</div>
<div className={pageStyle.uploadimg}><input type="file" id="uploadVideo" className={pageStyle.fileuploadinput} onChange={editorUploadVideo} accept="video/*" /><Icon style={{ marginRight: 10 }} type="video-camera" />添加视频</div> <div className={pageStyle.uploadimg}><input type="file" id="uploadVideo" className={pageStyle.fileuploadinput} onChange={e => this.editorUploadVideo(e)} accept="video/*" /><Icon style={{ marginRight: 10 }} type="video-camera" />添加视频</div>
<div className={pageStyle.uploadimg}><input type="file" id="uploadAudio" className={pageStyle.fileuploadinput} onChange={editorUploadAudio} accept="audio/*" /><Icon style={{ marginRight: 10 }} type="audio" />添加音频</div> <div className={pageStyle.uploadimg}><input type="file" id="uploadAudio" className={pageStyle.fileuploadinput} onChange={e => this.editorUploadAudio(e)} accept="audio/*" /><Icon style={{ marginRight: 10 }} type="audio" />添加音频</div>
</div> </div>
<Modal visible={previewVisible} footer={null} onCancel={this.handleCancel}> <Modal visible={previewVisible} footer={null} onCancel={this.handleCancel}>
<img alt="图片" style={{ width: '100%' }} src={imagify(previewImage)} /> <img alt="图片" style={{ width: '100%' }} src={imagify(previewImage)} />
......
...@@ -39,47 +39,51 @@ class CommentListForm extends React.Component { ...@@ -39,47 +39,51 @@ class CommentListForm extends React.Component {
} }
componentWillUnmount() { // 卸载 componentWillUnmount() { // 卸载
} }
handleClickStick =(record) => {
const { dispatch } = this.props;
dispatch({
type: 'onlineclasses/changeCourseStatus',
payload: {
place_top: 1,
id: record.id,
},
});
}
render() { render() {
const { const {
form: { getFieldDecorator, getFieldValue }, form: { getFieldDecorator, getFieldValue },
commentList,
commentListTotal,
} = this.props; } = this.props;
const dataSource = [
{
key: '1',
name: '胡彦斌',
age: 32,
address: '西湖区湖底公园1号',
},
{
key: '2',
name: '胡彦祖',
age: 42,
address: '西湖区湖底公园1号',
},
];
const columns = [ const columns = [
{ {
title: '序号', title: '序号',
dataIndex: 'name', dataIndex: 'id',
}, },
{ {
title: '用户', title: '用户',
dataIndex: 'age', dataIndex: 'comment_user',
render: (text, record) => {
return (
<div>
{record.comment_user.nickname}
</div>
);
},
}, },
{ {
title: '内容', title: '内容',
dataIndex: 'address', dataIndex: 'content',
}, },
{ {
title: '操作', title: '操作',
dataIndex: 'a', dataIndex: 'a',
render: () => { render: (text, record) => {
return ( return (
<div> <div>
<span className={pageStyle.hreflink}>回复</span> <span className={pageStyle.hreflink}>回复</span>
<Divider type="vertical" /> <Divider type="vertical" />
<span className={pageStyle.hreflink}>置顶</span> <span className={pageStyle.hreflink} onClick={() => this.handleClickStick(record)}>置顶</span>
<Divider type="vertical" /> <Divider type="vertical" />
<span className={pageStyle.hreflink}>删除</span> <span className={pageStyle.hreflink}>删除</span>
</div> </div>
...@@ -89,7 +93,7 @@ class CommentListForm extends React.Component { ...@@ -89,7 +93,7 @@ class CommentListForm extends React.Component {
]; ];
return ( return (
<div className={pageStyle.container}> <div className={pageStyle.container}>
<Table rowKey="id" dataSource={dataSource} columns={columns} /> <Table rowKey="id" dataSource={commentList} columns={columns} />
</div> </div>
); );
} }
...@@ -101,10 +105,12 @@ CommentListForm.propTypes = { ...@@ -101,10 +105,12 @@ CommentListForm.propTypes = {
const CommentList = Form.create()(CommentListForm); const CommentList = Form.create()(CommentListForm);
function mapStateToProps(state) { function mapStateToProps(state) {
const { const {
addCourseObj, commentList,
commentListTotal,
} = state.onlineclasses; } = state.onlineclasses;
return { return {
addCourseObj, commentList,
commentListTotal,
}; };
} }
export default connect(mapStateToProps)(CommentList); export default connect(mapStateToProps)(CommentList);
......
...@@ -57,16 +57,6 @@ class CourseDetailForm extends React.Component { ...@@ -57,16 +57,6 @@ class CourseDetailForm extends React.Component {
}, },
}); });
} }
courseUploadVideo = (e) => {
const { dispatch } = this.props;
dispatch({
type: 'onlineclasses/queryvideosignature',
payload: {
files: e.target,
uploadtype: 'uploadVideo',
},
});
}
courseChangeSize = (e, index) => { courseChangeSize = (e, index) => {
const { dispatch } = this.props; const { dispatch } = this.props;
const textValue = e.target.value; const textValue = e.target.value;
...@@ -109,13 +99,25 @@ class CourseDetailForm extends React.Component { ...@@ -109,13 +99,25 @@ class CourseDetailForm extends React.Component {
}, },
}); });
} }
courseUploadAudio = (e) => { courseUploadAudio = ({ files, uploadtype, time }) => {
const { dispatch } = this.props; const { dispatch } = this.props;
dispatch({ dispatch({
type: 'onlineclasses/queryvoiceignature', type: 'onlineclasses/queryvoiceignature',
payload: { payload: {
files: e.target, files,
uploadtype: 'uploadDescAudio', uploadtype,
time,
},
});
}
courseUploadVideo = ({ files, uploadtype, time }) => {
const { dispatch } = this.props;
dispatch({
type: 'onlineclasses/queryvideosignature',
payload: {
files,
uploadtype,
time,
}, },
}); });
} }
......
...@@ -189,7 +189,7 @@ class singleDetailForm extends React.Component { ...@@ -189,7 +189,7 @@ class singleDetailForm extends React.Component {
<TabPane tab="数据分析" key="2"> <TabPane tab="数据分析" key="2">
<StaticBox /> <StaticBox />
</TabPane> </TabPane>
<TabPane tab="评论管理" key="3"> <TabPane tab="留言管理" key="3">
<CommentList /> <CommentList />
</TabPane> </TabPane>
</Tabs> </Tabs>
......
...@@ -73,3 +73,19 @@ export function staticChart(params) { ...@@ -73,3 +73,19 @@ export function staticChart(params) {
data, data,
}); });
} }
export function selectComment(params) {
const data = qs.stringify(params);
return request({
url: `${api.onlineclasses.comments}?${data}`,
method: 'GET',
data,
});
}
export function commentStick(params) {
const data = qs.stringify(params);
return request({
url: `${api.onlineclasses.comments}/${params.id}`,
method: 'PUT',
data,
});
}
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