@@ -49,5 +55,6 @@ class MemoList extends Component {
);
}
}
+MemoList.contextType = ThemeContext;
export default ( MemoList );
diff --git a/public/react/src/modules/forums/PostItem.js b/public/react/src/modules/forums/PostItem.js
index 02d9fa273..43b63c3fa 100644
--- a/public/react/src/modules/forums/PostItem.js
+++ b/public/react/src/modules/forums/PostItem.js
@@ -7,10 +7,12 @@ import PropTypes from 'prop-types';
import classNames from 'classnames';
-import { getImageUrl, toPath } from 'educoder';
+import { getImageUrl, toPath, ThemeContext } from 'educoder';
import moment from 'moment';
+import { Tooltip } from 'antd'
+
class PostItem extends Component {
_toTenThousand(num) {
@@ -31,17 +33,19 @@ class PostItem extends Component {
{/* target="_blank" */}
-
+ 46 ? memo.subject : ''}
+ className="clearfix task-hide item_name fl" style={{maxWidth: '600px'}} >
{memo.subject}
{ memo.sticky && 置顶 }
{ memo.reward &&
-
- {memo.reward}
-
+
+
+ {memo.reward}
+
+
}
@@ -101,4 +105,6 @@ class PostItem extends Component {
);
}
}
+PostItem.contextType = ThemeContext;
+
export default PostItem
diff --git a/public/react/src/modules/moop_cases/CaseDetail.js b/public/react/src/modules/moop_cases/CaseDetail.js
new file mode 100644
index 000000000..193961240
--- /dev/null
+++ b/public/react/src/modules/moop_cases/CaseDetail.js
@@ -0,0 +1,165 @@
+import React,{ Component } from "react";
+import './css/moopCases.css'
+import '../courses/css/Courses.css'
+
+import { getImageUrl , MarkdownToHtml , ActionBtn } from 'educoder';
+
+import Tags from './CaseTags'
+
+import axios from 'axios';
+import Modals from '../modals/Modals'
+
+class CaseDetail extends Component{
+ constructor(props){
+ super(props);
+ this.state={
+ modalsType:"",
+ modalsTopval:"",
+ modalsBottomval:"",
+ modalCancel:"",
+ }
+ }
+
+ componentDidMount =()=>{
+ let caseID = this.props.match.params.caseID;
+ this.props.getDetail(caseID);
+ }
+ // 是否删除
+ delCases=()=>{
+ this.setState({
+ modalsType:true,
+ modalsTopval:"是否确认删除?",
+ modalsBottomval:""
+ })
+ }
+
+ // 取消删除
+ cancelDelClasses=()=>{
+ this.setState({
+ modalsType:false,
+ modalsTopval:"",
+ modalsBottomval:""
+ })
+ }
+ // 确定删除
+ sureDelClasses=()=>{
+ let caseID = this.props.match.params.caseID;
+ let url =`/libraries/${caseID}.json`;
+ axios.delete(url).then((result)=>{
+ if(result){
+ this.props.showNotification("删除成功");
+ this.props.history.push("/moop_cases");
+ }
+ }).catch((error)=>{
+ console.log(error);
+ })
+ }
+
+
+ render(){
+ let { CaseDetail , praise_count , creator , operation , user_praised , tags , attachments }=this.props
+ let {
+ modalsType,
+ modalsTopval,
+ modalsBottomval,
+ } = this.state;
+ return(
+
+
+
+
+ 教学案例 > { CaseDetail && CaseDetail.title}
+
+
+
+ { CaseDetail && CaseDetail.title}
+
+
+
+ {
+ CaseDetail && CaseDetail.status == "pending" && 草稿
+ }
+
+ 返回
+
+
+
+
+

+
+
+ {creator && creator.name}
+ {
+ operation && operation.can_deletable ? 删除:""
+ }
+
+ {
+ operation && operation.can_editable ? 编辑:""
+ }
+
+
+ {creator && creator.school_name}
+
+ 编码:{CaseDetail && CaseDetail.uuid}
+ 发布时间:{CaseDetail && CaseDetail.published_at}
+
+
+
+
+
+ 作者:{CaseDetail && CaseDetail.author_name}/{CaseDetail && CaseDetail.author_school_name}
+
+
+
+ { CaseDetail && CaseDetail.content && }
+
+ { attachments &&
+
+ {
+ attachments.map((item,key)=>{
+ return(
+
+
+
+
+ {item.title}
+ {item.filesize}
+
+ )
+ })
+ }
+
+ }
+
+ {
+ user_praised ?
+
+ 已赞
+ {praise_count}
+
+ :
+
this.props.praisePoint(this.props.match.params.caseID)} className="pointsBtn">
+
+ {praise_count}
+
+ }
+
+
+
+
+ )
+ }
+}
+export default CaseDetail;
\ No newline at end of file
diff --git a/public/react/src/modules/moop_cases/CaseItem.js b/public/react/src/modules/moop_cases/CaseItem.js
new file mode 100644
index 000000000..a5086133b
--- /dev/null
+++ b/public/react/src/modules/moop_cases/CaseItem.js
@@ -0,0 +1,48 @@
+import React,{ Component } from "react";
+import './css/moopCases.css'
+import '../courses/css/Courses.css'
+
+import { getUrl } from 'educoder';
+
+import Tags from './CaseTags'
+
+class CaseItem extends Component{
+ constructor(props){
+ super(props);
+ }
+
+ render(){
+ let { libraries } = this.props;
+ console.log(libraries)
+ return(
+
+ {
+ libraries && libraries.map((item,key)=>{
+ return(
+
+
+
+
+ {item.title}
+
+
+
+ {item.author_name}
+ {item.author_school_name}
+
+ {item.visited_count} 浏览
+ {item.praise_count} 赞
+ {item.download_count} 下载
+
+
+
+
+ )
+ })
+ }
+
+
+ )
+ }
+}
+export default CaseItem;
\ No newline at end of file
diff --git a/public/react/src/modules/moop_cases/CaseList.js b/public/react/src/modules/moop_cases/CaseList.js
new file mode 100644
index 000000000..b968cc930
--- /dev/null
+++ b/public/react/src/modules/moop_cases/CaseList.js
@@ -0,0 +1,134 @@
+import React,{ Component } from "react";
+import { Input , Spin , Pagination } from "antd";
+import './css/moopCases.css'
+import '../courses/css/Courses.css'
+
+import { ActionBtn } from 'educoder';
+
+import axios from 'axios'
+
+import NoneData from '../courses/coursesPublic/NoneData'
+
+import mainImg from '../../images/moop_cases/teach_ex.jpg'
+import CaseItem from './CaseItem'
+
+
+const Search = Input.Search;
+class CaseList extends Component{
+ constructor(props){
+ super(props);
+ this.state={
+ type:0,
+ search:undefined,
+ page:1,
+ pageSize:20,
+ libraries:undefined,
+ totalCount:undefined
+ }
+ }
+
+ componentDidMount = () =>{
+ let { type , search , page , pageSize } = this.state;
+ this.InitList(type,search,page,pageSize);
+ }
+
+ // 列表
+ InitList = (type,search,page,pageSize) =>{
+ let url = `/libraries.json`;
+ axios.get(url,{params:{
+ type:type == 0 ? undefined : "mine",
+ keyword:search,
+ page,
+ per_page:pageSize
+ }}).then((result)=>{
+ if(result){
+ this.setState({
+ libraries:result.data.libraries,
+ totalCount:result.data.count
+ })
+ }
+ }).catch((error)=>{
+ console.log(error);
+ })
+ }
+
+ // tab切换
+ changeType = (type) =>{
+ this.setState({
+ type,
+ page:1
+ })
+ let { search , page , pageSize } = this.state;
+ this.InitList(type,search,page,pageSize);
+ }
+
+ // 输入搜索内容
+ inputStudent=(e)=>{
+ this.setState({
+ search:e.target.value
+ })
+ }
+
+ // 搜索
+ searchInfo = () =>{
+ let { type , search , pageSize } = this.state;
+ this.InitList( type , search , 1 , pageSize );
+ }
+
+ // 切换分页
+ onChangePage =(pageNumber)=>{
+ this.setState({
+ page:pageNumber
+ })
+ let { type , search , pageSize } = this.state;
+ this.InitList( type , search , pageNumber , pageSize );
+ }
+
+ render(){
+ let { type , search ,libraries , totalCount ,pageSize ,page } = this.state;
+ return(
+
+
+
+
+
+ 教学案例
+ this.addQuestion(null, Q_TYPE_SINGLE)}>发布案例
+
+
+
+ - this.changeType(0)}>
+ 全部
+
+ - this.changeType(1)}>
+ 我的
+
+
+
+
+
+
+
+ {
+ libraries && libraries.length > 0 &&
+ }
+ {
+ libraries && libraries.length == 0 &&
+ }
+ {
+ totalCount && totalCount > pageSize &&
+
+ }
+
+
+ )
+ }
+}
+export default CaseList
\ No newline at end of file
diff --git a/public/react/src/modules/moop_cases/CaseNew.js b/public/react/src/modules/moop_cases/CaseNew.js
new file mode 100644
index 000000000..e855b5b71
--- /dev/null
+++ b/public/react/src/modules/moop_cases/CaseNew.js
@@ -0,0 +1,433 @@
+import React,{ Component } from "react";
+import './css/moopCases.css'
+import '../courses/css/Courses.css'
+import { Form , Input , Upload , Button , Icon , message , Tooltip } from "antd";
+
+import { getImageUrl , MarkdownToHtml , ActionBtn , appendFileSizeToUploadFile , appendFileSizeToUploadFileAll , getUrl , getUploadActionUrl } from 'educoder';
+
+import Tags from './CaseTags'
+
+import axios from 'axios';
+import TPMMDEditor from '../tpm/challengesnew/TPMMDEditor';
+import _ from 'lodash'
+const { Dragger } = Upload;
+function beforeUpload(file) {
+ const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
+ if (!isJpgOrPng) {
+ message.error('You can only upload JPG/PNG file!');
+ }
+ const isLt2M = file.size / 1024 / 1024 < 2;
+ if (!isLt2M) {
+ message.error('Image must smaller than 2MB!');
+ }
+ return isJpgOrPng && isLt2M;
+}
+function getBase64(img, callback) {
+ const reader = new FileReader();
+ reader.addEventListener('load', () => callback(reader.result));
+ reader.readAsDataURL(img);
+}
+ const $ = window.$;
+class CaseNew extends Component{
+ constructor(props){
+ super(props);
+ this.DescMdRef = React.createRef();
+
+ this.state={
+ casesTags:[],
+ contentFileList:[],
+ filesID:[],
+ imageUrl:undefined,
+ loading: false,
+ checkTag:false,
+ checkFile:false,
+ coverID:undefined
+ }
+ }
+
+ // 上传附件-删除确认框
+ onAttachmentRemove = (file, stateName) => {
+ this.props.confirm({
+ content: '是否确认删除?',
+ onOk: () => {
+ this.deleteAttachment(file, stateName)
+ },
+ onCancel() {
+ console.log('Cancel');
+ },
+ });
+ return false;
+ }
+
+ // 上传附件-确认删除
+ deleteAttachment = (file, stateName) => {
+ // 初次上传不能直接取uid
+ const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
+ axios.delete(url, {
+ }).then((response) => {
+ if (response.data) {
+ const { status } = response.data;
+ if (status == 0) {
+ console.log('--- success')
+
+ this.setState((state) => {
+ const index = state[stateName].indexOf(file);
+ const newFileList = state[stateName].slice();
+ newFileList.splice(index, 1);
+ return {
+ [stateName]: newFileList,
+ };
+ });
+ }
+ }
+ })
+ .catch(function (error) {
+ console.log(error);
+ });
+ }
+ // 上传附件-change
+ handleContentUploadChange = (info) => {
+ let contentFileList = info.fileList;
+ this.setState({ contentFileList: appendFileSizeToUploadFileAll(contentFileList)});
+ let list = appendFileSizeToUploadFileAll(contentFileList);
+ let arr = list.map(item=>{
+ return ( item.response && item.response.id )
+ })
+ this.setState({
+ filesID:arr,
+ checkFile:arr.length > 0 ? false : true
+ })
+ console.log("fujian");
+ console.log(list.map(item=>{
+ return ( item.response && item.response.id )
+ }));
+ }
+
+ // 上传封面图-change
+ handleChange = (info) => {
+ if (info.file.status === 'uploading') {
+ this.setState({ loading: true });
+ return;
+ }
+ if (info.file.status === 'done') {
+ // Get this url from response in real world.
+ getBase64(info.file.originFileObj, imageUrl =>
+ this.setState({
+ imageUrl,
+ loading: false
+ }),
+ );
+ console.log(info.file);
+ this.setState({
+ coverID:info.file.response && info.file.response.id
+ })
+ }
+ };
+
+ // 编辑时加载数据
+ componentDidMount=()=>{
+ if(this.props.match.params.caseID){
+ this.InitEditData();
+ }
+ }
+
+ componentDidUpdate=(prevState)=>{
+ if(this.props.CaseDetail && prevState.CaseDetail != this.props.CaseDetail){
+ this.props.form.setFieldsValue({
+ caseTitle:this.props.CaseDetail.title,
+ userName:this.props.CaseDetail.author_name,
+ userUnit:this.props.CaseDetail.author_school_name,
+ })
+ this.setState({
+ contentFileList:this.props.CaseDetail.attachments.map(item => {
+ return {
+ id: item.id,
+ uid: item.id,
+ name: appendFileSizeToUploadFile(item),
+ url: item.url,
+ filesize: item.filesize,
+ status: 'done'
+ }
+ }),
+ coverID:this.props.cover && this.props.cover.id,
+ imageUrl:this.props.CaseDetail.cover && getImageUrl(this.props.CaseDetail.cover.url),
+ casesTags:this.props.tags.map(item=>{
+ return (item.id);
+ })
+ })
+ }
+ }
+
+ InitEditData=()=>{
+ let caseID = this.props.match.params.caseID;
+ this.props.getDetail(caseID);
+ }
+
+ // 申请提交和保存
+ handleSubmit = (type) => {
+ let caseID = this.props.match.params.caseID;
+ console.log(type);
+ this.props.form.validateFieldsAndScroll((err, values) => {
+ let { casesTags , filesID } = this.state;
+ if(casesTags.length == 0){
+ $("html").animate({ scrollTop: $("#tagFormItem").offset().top - 100 });
+ this.setState({
+ checkTag:true
+ })
+ return;
+ }
+ if(filesID.length == 0){
+ $("html").animate({ scrollTop: $("#fileFormItem").offset().top - 100 });
+ this.setState({
+ checkFile:true
+ })
+ return;
+ }
+ //const mdContnet = this.DescMdRef.current.getValue().trim();
+ console.log(values);
+ let url = caseID ? `/libraries/${caseID}.json`: `/libraries.json`;
+ if(caseID){
+ axios.put((url),{
+ title:values.caseTitle,
+ author_name:values.userName,
+ author_school_name:values.userUnit,
+ content:values.description,
+ attachment_ids:this.state.filesID,
+ tag_ids:this.state.casesTags,
+ cover_id:this.state.coverID,
+ publish:type == 'save' ? false : true
+ }).then((result)=>{
+ if(result){
+ this.props.showNotification(type == 'save' ? `案例保存成功!`: `提交成功!`);
+ this.props.history.push(type == 'save' ? `/moop_cases/${result.data.id}` : `/moop_cases/${result.data.id}/publish_success`);
+ }
+ }).catch((error)=>{
+ console.log(error);
+ })
+ }else{
+ axios.post((url),{
+ title:values.caseTitle,
+ author_name:values.userName,
+ author_school_name:values.userUnit,
+ content:values.description,
+ attachment_ids:this.state.filesID,
+ tag_ids:this.state.casesTags,
+ cover_id:this.state.coverID,
+ publish:type == 'save' ? false : true
+ }).then((result)=>{
+ if(result){
+ this.props.showNotification(type == 'save' ? `案例保存成功!`: `提交成功!`);
+ this.props.history.push(type == 'save' ? `/moop_cases/${result.data.id}` : `/moop_cases/${result.data.id}/publish_success`);
+ }
+ }).catch((error)=>{
+ console.log(error);
+ })
+ }
+
+ })
+ }
+
+ // 选择标签
+ changeType=(type)=>{
+ let tags = [];
+ if(this.state.casesTags.indexOf(type) > -1){
+ tags = this.state.casesTags.filter(item => item != type);
+ }else{
+ tags = this.state.casesTags.concat(type);
+ }
+ const tagUniqed = _.uniq(tags);
+ this.setState({
+ casesTags: tagUniqed,
+ checkTag:tags.length > 0 ? false : true
+ })
+ }
+
+ render(){
+ let { caseID } = this.props.match.params;
+ let { CaseDetail } = this.props;
+ let { casesTags , contentFileList , imageUrl , checkTag , checkFile } = this.state;
+ const {getFieldDecorator} = this.props.form;
+
+
+ // 上传附件点击事件
+ const uploadProps = {
+ width: 600,
+ multiple: true,
+ fileList:contentFileList,
+ action: `${getUploadActionUrl()}`,
+ onChange: this.handleContentUploadChange,
+ onRemove: (file) => this.onAttachmentRemove(file, 'contentFileList'),
+ beforeUpload: (file) => {
+ const isLt150M = file.size / 1024 / 1024 < 150;
+ if (!isLt150M) {
+ message.error('文件大小必须小于150MB!');
+ }
+ return isLt150M;
+ }
+ };
+ // 上传封面图-html
+ const uploadButton = (
+
+
+
+ );
+ // 上传封面图点击事件
+ const uploadCover = {
+ listType:"picture-card",
+ className:"avatar-uploader",
+ showUploadList:false,
+ action:`${getUploadActionUrl()}`,
+ onChange:this.handleChange,
+ }
+ return(
+
+
+
+ 教学案例 > { caseID ? "编辑" : "新建" }
+
+
上传教学案例
+
+
+
+
+
+ )
+ }
+}
+const WrappedCoursesNewApp = Form.create({name: 'CaseNew'})(CaseNew);
+export default WrappedCoursesNewApp;
\ No newline at end of file
diff --git a/public/react/src/modules/moop_cases/CaseTags.js b/public/react/src/modules/moop_cases/CaseTags.js
new file mode 100644
index 000000000..4b4f0670c
--- /dev/null
+++ b/public/react/src/modules/moop_cases/CaseTags.js
@@ -0,0 +1,26 @@
+import React,{ Component } from "react";
+import './css/moopCases.css'
+import '../courses/css/Courses.css'
+
+class CaseTags extends Component{
+ constructor(props){
+ super(props);
+ }
+
+ render(){
+ let { tags } = this.props;
+ return(
+
+ {
+ tags && tags.map((item,key)=>{
+ return(
+ {item.name}
+ )
+ })
+ }
+
+
+ )
+ }
+}
+export default CaseTags;
\ No newline at end of file
diff --git a/public/react/src/modules/moop_cases/Success.js b/public/react/src/modules/moop_cases/Success.js
new file mode 100644
index 000000000..d612758c8
--- /dev/null
+++ b/public/react/src/modules/moop_cases/Success.js
@@ -0,0 +1,28 @@
+import React,{ Component } from "react";
+import './css/moopCases.css'
+import '../courses/css/Courses.css'
+import { getImageUrl } from 'educoder';
+import success from '../../images/moop_cases/success.png'
+
+class Success extends Component{
+ constructor(props){
+ super(props);
+ }
+ render(){
+ return(
+
+
+

+
恭喜!
+
提交成功
+
平台正在审核您的申请,审核结果将以平台消息的形式通知您
+
+ 查看已上传文档
+ 继续上传
+
+
+
+ )
+ }
+}
+export default Success;
\ No newline at end of file
diff --git a/public/react/src/modules/moop_cases/css/moopCases.css b/public/react/src/modules/moop_cases/css/moopCases.css
new file mode 100644
index 000000000..01668b637
--- /dev/null
+++ b/public/react/src/modules/moop_cases/css/moopCases.css
@@ -0,0 +1,155 @@
+.winput-300-35{
+ width: 300px;
+ height: 35px;
+ padding: 5px;
+ box-sizing: border-box;
+}
+.library_nav li {
+ float: left;
+ cursor: pointer;
+ margin-right: 30px;
+ position: relative;
+ color: #05101A;
+ height: 40px;
+ line-height: 20px;
+ font-size: 16px;
+}
+.library_nav li.active a, .library_nav li:hover a{
+ color: #4cacff!important;
+}
+.library_list {
+ margin-bottom: 30px;
+}
+.library_list_item:hover {
+ box-shadow: 0px 4px 8px rgba(158,158,158,0.16);
+}
+.library_list_item {
+ background: #fff;
+ padding: 20px 30px;
+ margin-bottom: 30px;
+ display: flex;
+}
+.library_list_item .library_l_name {
+ max-width: 600px;
+ float: left;
+}
+
+.edu-activity-red {
+ background-color: #FC2B6A;
+ color: #fff!important;
+ cursor: pointer;
+ border: 1px solid #FC2B6A;
+ line-height: 17px;
+}
+.edu-activity-green {
+ background-color: green;
+ color: #fff!important;
+ cursor: pointer;
+ border: 1px solid green;
+ line-height: 17px;
+}
+.edu-activity-blue {
+ background-color: #4CACFF;
+ color: #fff!important;
+ cursor: pointer;
+ border: 1px solid #4CACFF;
+ line-height: 17px;
+}
+
+.pointsBtn {
+ width: 70px;
+ height: 70px;
+ background-color: #4cacff;
+ border-radius: 50%;
+ color: #fff;
+ text-align: center;
+ margin: 0 auto;
+ -webkit-box-sizing: border-box;
+ box-sizing: border-box;
+ padding: 2px 0;
+ cursor: pointer;
+ line-height: 22px;
+ padding-top: 12px;
+}
+.pointedBtn{
+ background: #BCD1E3;
+ cursor: default
+}
+.pointsBtn span{
+ display: block;
+}
+.upload_Title {
+ position: relative;
+ margin-right: 20px;
+ float: left;
+ line-height: 35px;
+ font-size: 16px;
+ width: 56px;
+ color:rgba(0, 0, 0, 0.85);
+ text-align: center
+}
+.upload_Title.must:before {
+ display: inline-block;
+ margin-right: 4px;
+ color: #f5222d;
+ font-size: 14px;
+ font-family: SimSun, sans-serif;
+ line-height: 1;
+ content: '*';
+}
+.upload_Title:after{
+ content: ':';
+ position: relative;
+ top: -0.5px;
+ margin: 0 8px 0 2px;
+}
+.libraries_tab li {
+ width: 120px;
+ height: 35px;
+ line-height: 33px;
+ border-radius: 18px;
+ border: 1px solid #4C98FF;
+ color: #4C98FF;
+ cursor: pointer;
+ margin-right: 30px;
+ float: left;
+ text-align: center;
+}
+.libraries_tab li.active {
+ background: #4C98FF;
+ color: #fff;
+}
+.librariesField .ant-upload{
+ width: 100%;
+ background: #F2F9FF;
+ justify-content: center;
+ align-items: center;
+ display: -webkit-flex;
+ text-align: center;
+ height: 120px!important;
+ border-radius: 4px;
+ border: 1px dashed #4cacff!important;
+ display: block;
+ cursor: pointer;
+}
+.uploadImage .ant-upload.ant-upload-select-picture-card{
+ width:120px;
+ height: 90px;
+}
+.uploadImage .ant-upload.ant-upload-select-picture-card > .ant-upload{
+ padding:0px!important;
+}
+.successPage {
+ justify-content: center;
+ align-items: center;
+ display: -webkit-flex;
+ height: 570px;
+ text-align: center;
+ margin-bottom: 50px;
+}
+.changebtn {
+ width:166px;
+ font-size: 16px;
+ height: 45px;
+ line-height: 45px;
+}
\ No newline at end of file
diff --git a/public/react/src/modules/moop_cases/index.js b/public/react/src/modules/moop_cases/index.js
new file mode 100644
index 000000000..cc8ae68b9
--- /dev/null
+++ b/public/react/src/modules/moop_cases/index.js
@@ -0,0 +1,130 @@
+import React,{ Component } from "react";
+import './css/moopCases.css'
+import '../courses/css/Courses.css'
+
+import { SnackbarHOC } from 'educoder';
+
+import { TPMIndexHOC } from '../tpm/TPMIndexHOC';
+import { CNotificationHOC } from '../courses/common/CNotificationHOC'
+
+import {BrowserRouter as Router,Route,Switch} from 'react-router-dom';
+import Loading from '../../Loading';
+import Loadable from 'react-loadable';
+
+import axios from 'axios';
+
+const CaseList = Loadable({
+ loader: () => import('./CaseList'),
+ loading:Loading,
+})
+const CaseDetail = Loadable({
+ loader: () => import('./CaseDetail'),
+ loading:Loading,
+})
+const CaseNew = Loadable({
+ loader: () => import('./CaseNew'),
+ loading:Loading,
+})
+const CaseSuccess = Loadable({
+ loader: () => import('./Success'),
+ loading:Loading,
+})
+
+
+
+class Index extends Component{
+ constructor(props){
+ super(props);
+ this.state={
+ praise_count:0,
+ CaseDetail:undefined,
+ cover:undefined,
+ creator:undefined,
+ operation:undefined,
+ tags:undefined,
+ attachments:undefined,
+ user_praised:true,
+ }
+ }
+ // 获取案例详情
+ getDetail = (caseID) =>{
+ let url=`/libraries/${caseID}.json`
+ axios.get(url).then((result)=>{
+ if(result){
+ this.setState({
+ CaseDetail:result.data,
+ praise_count:result.data.praise_count,
+ cover:result.data.cover,
+ creator:result.data.creator,
+ operation:result.data.operation,
+ user_praised:result.data.operation.user_praised,
+ tags:result.data.tags,
+ attachments:result.data.attachments
+ })
+ }
+ }).catch((error)=>{
+ console.log(error);
+ })
+ }
+ // 点赞
+ praisePoint=(caseID)=>{
+ let { praise_count }=this.state;
+ let url =`/praise_tread/like.json`;
+ axios.post(url,{
+ object_id:caseID,
+ object_type:"library"
+ }).then((result)=>{
+ if(result){
+ this.setState({
+ praise_count: parseInt(praise_count)+1,
+ user_praised:true
+ })
+ }
+ }).catch((error)=>{
+ console.log(error);
+ })
+ }
+
+ render(){
+
+ return(
+
+
+
+ ()
+ }
+ >
+
+ ()
+ }
+ >
+
+ ()
+ }
+ >
+
+
+ ()
+ }
+ >
+
+ ()
+ }
+ >
+
+
+
+ )
+ }
+}
+export default CNotificationHOC() ( SnackbarHOC() ( TPMIndexHOC(Index) ));
\ No newline at end of file