diff --git a/src/App.tsx b/src/App.tsx index 5c410cc..291c456 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,11 +1,8 @@ import React, { Component } from 'react'; import './App.less'; -import { Routes, Route, Link } from "react-router-dom" -import req from '@utils/request.ts'; +import { Outlet } from "react-router-dom" import PubSub from 'pubsub-js'; import { Input } from 'antd'; -import QuestionBank from './views/question-bank'; -import UploadQuestions from './views/upload-questions'; import Logo from '@views/imgs/logo.jpg' import Head from '@views/imgs/head.jpg' import TopMenu from '@components/top-menu' @@ -25,22 +22,7 @@ class NavTop extends Component { timerRef = React.createRef(); componentDidMount() { - // req({ - // method: 'post', - // url: 'admin/interview/peo/getDirectorInfo', - // }).then((re) => { - // this.setState( - // { - // userName: re.data?.name ?? '', - // intervieweEamil: re.data?.email ?? '', - // headImg: '', - // }, - // () => { - // window.localStorage.setItem('interviewerName', re.data?.name ?? 'XXX'); - // window.localStorage.setItem('intervieweEamil', re.data?.email ?? 'XXX'); - // } - // ); - // }); + PubSub.subscribe('handleToRender', () => { this.setState({}); }); @@ -88,25 +70,12 @@ class NavTop extends Component { ); } } -class RouteExample extends Component { - render() { - return ( - <> - - - }> - }> - - - - ); - } -} export default class App extends Component { render() { return (
- + +
); } diff --git a/src/components/category-list/index.jsx b/src/components/category-list/index.jsx index 01f0cf2..23930c2 100644 --- a/src/components/category-list/index.jsx +++ b/src/components/category-list/index.jsx @@ -246,10 +246,10 @@ export default class CategoryList extends Component { }} onClick={this.onChangeCategory(categoryModuleItem.primaryCategoryId)}>
- {categoryModuleItem.levelName} + {categoryModuleItem.categoryName}
- {categoryModuleItem.count}道题 + {categoryModuleItem.count || 50}道题
); diff --git a/src/components/good-collection-error/constant.js b/src/components/good-collection-error/constant.js new file mode 100644 index 0000000..b5c404c --- /dev/null +++ b/src/components/good-collection-error/constant.js @@ -0,0 +1,9 @@ +export const good = { + 0: '未点赞', + 1: '已点赞', +}; + +export const collection = { + 0: '未收藏', + 1: '已收藏', +}; diff --git a/src/components/good-collection-error/index.jsx b/src/components/good-collection-error/index.jsx new file mode 100644 index 0000000..5766eb0 --- /dev/null +++ b/src/components/good-collection-error/index.jsx @@ -0,0 +1,262 @@ +import React, { Component } from 'react' +import { Modal, Input, Radio, message } from 'antd' +import { HeartTwoTone, LikeTwoTone, InfoCircleTwoTone } from '@ant-design/icons' +import { collection, good } from './constant' +import req from '@utils/request' +import './index.less' + +const { TextArea } = Input +export default class GoodCollectionError extends Component { + constructor(props) { + super(props) + this.state = { + isGood: false, //是否点赞 + isCollection: false, //是否收藏 + goodAmount: 0, //点赞数量 + collectionAmount: 0, //收藏数量 + // index: 1, + question: [], //题目列表 + isModal: false, //是否显示纠错弹框 + value: 1, //纠错类型对应值 + inputValue: '', //纠错详情内容 + questionId: '', //题目id + } + } + /**纠错类型 */ + errorType = [ + { + value: 1, + content: '答案错误', + }, + { + value: 2, + content: '题目与答案不符', + }, + ] + componentDidMount() { + // this.getDetail() + } + + getDetail() { + let params = { + subjectId: this.props.questionId, + } + req({ + method: 'post', + data: params, + url: 'admin/question/collect/getDetail', + }) + .then((res) => { + if (res.data) { + this.setState({ + isGood: res.data.isThump, + goodAmount: res.data.thumpCount, + isCollection: res.data.isCollect, + collectionAmount: res.data.collectCount, + }) + } + }) + .catch((err) => console.log(err)) + } + + /** + * 点击纠错按钮 + */ + handleModal = () => { + this.setState({ + isModal: true, + }) + } + /** + * 点击弹框确认按钮 + */ + handleOk = () => { + const { value, inputValue } = this.state + const { questionId } = this.props + + let params = { + subjectId: questionId, + errorType: value, + errorMsg: inputValue, + } + if (inputValue.length === 0) { + message.warning('请填写纠错详情!') + } else { + this.setState({ + isModal: false, + inputValue: '', + }) + message.success('感谢纠错,立即更改!') + JDreq({ + method: 'post', + data: params, + url: '/admin/question/subjectError/add', + }) + } + } + /** + * 点击弹框取消按钮 + */ + handleCancel = () => { + this.setState({ + isModal: false, + inputValue: '', + }) + } + /** + * + * @param {选择纠错类型} e + */ + handleChangeRadio = (e) => { + this.setState({ + value: e.target.value, + }) + } + /** + * + * @param {纠错详情中填写内容} e + */ + handleChangeInput = (e) => { + this.setState({ + inputValue: e.target.value, + }) + } + /** + * + * @returns 点击点赞按钮 + */ + handleChangeGood = () => { + return message.info('敬请期待') + const { isGood, goodAmount } = this.state + const { questionId } = this.props + let params = { + subjectId: questionId, + } + this.setState( + { + isGood: isGood === true ? false : true, + goodAmount: isGood === true ? goodAmount - 1 : goodAmount + 1, + }, + () => { + JDreq({ + method: 'post', + data: params, + url: 'admin/question/thump/addOrCancel', + }).catch((err) => console.log(err)) + } + ) + } + /** + * 点击收藏按钮 + */ + handleChangeCollection = () => { + return message.info('敬请期待') + const { isCollection, collectionAmount } = this.state + const { questionId } = this.props + let params = { + subjectId: questionId, + } + this.setState( + { + isCollection: isCollection === true ? false : true, + collectionAmount: isCollection === true ? collectionAmount - 1 : collectionAmount + 1, + }, + () => { + req({ + method: 'post', + data: params, + url: 'admin/question/collect/addOrCancel', + }).catch((err) => console.log(err)) + } + ) + } + render() { + const { isCollection, isGood, isModal, value, collectionAmount, goodAmount } = this.state + return ( +
+
{ + this.handleChangeGood() + }} + > + ({goodAmount}) +
+
{ + this.handleChangeCollection() + }} + > + ( + {collectionAmount}) +
+ {/*
+ + 评论 +
*/} +
{ + console.log('111') + this.handleModal() + }} + > + + 纠错 +
+ { + this.handleOk() + }} + onCancel={() => { + this.handleCancel() + }} + okText="确认" + cancelText="取消" + style={{ fontWeight: 500 }} + > +
+
纠错类型
+
+ {this.errorType.map((item, index) => { + return ( +
+ { + this.handleChangeRadio(e) + }} + defaultValue={1} + buttonStyle="solid" + value={value} + > + + {item.content} + + +
+ ) + })} +
+
纠错详情
+