Commit 4f481ca9 authored by wangxuelai's avatar wangxuelai

''

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