|
|
@@ -1,24 +1,71 @@
|
|
|
<template>
|
|
|
<div class="discussion-area">
|
|
|
<h1 class="title">讨论 & 问答</h1>
|
|
|
- <discussion-type-bar></discussion-type-bar>
|
|
|
+ <!-- <discussion-type-bar></discussion-type-bar>-->
|
|
|
+ <write-new-comment @comment-submit="handleCommentSubmit" :placeholder="writingAreaPlaceholder"></write-new-comment>
|
|
|
<div class="discussion-area-content">
|
|
|
- <c-comment></c-comment>
|
|
|
- <c-comment></c-comment>
|
|
|
- <c-comment></c-comment>
|
|
|
- <c-comment></c-comment>
|
|
|
- <c-comment></c-comment>
|
|
|
- <c-comment></c-comment>
|
|
|
+ <div class="sub-title mb-8">本页讨论区</div>
|
|
|
+ <template v-for="comment of comments">
|
|
|
+ <c-comment :key="comment.id" :comment="comment"
|
|
|
+ :clickHandler="null">
|
|
|
+ </c-comment>
|
|
|
+ </template>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import CComment from '@/components/CComment'
|
|
|
-import DiscussionTypeBar from '@/components/DiscussionTypeBar'
|
|
|
+import WriteNewComment from '@/components/WriteNewComment'
|
|
|
+import { mapState } from 'vuex'
|
|
|
+import { createComment, getComments } from '@/server/comment'
|
|
|
|
|
|
export default {
|
|
|
- components: { DiscussionTypeBar, CComment }
|
|
|
+ components: { WriteNewComment, CComment },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ comments: null
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted () {
|
|
|
+ if (!this.userInfo) {
|
|
|
+ this.$setInfoMessage('需要登录本系统才可以浏览课程内容')
|
|
|
+ this.$router.push('login')
|
|
|
+ }
|
|
|
+ this.updateComments()
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapState({
|
|
|
+ userInfo: state => state.main.userInfo,
|
|
|
+ currentPage: state => state.pdf.currentPage,
|
|
|
+ slide: state => state.pdf.slideInfo
|
|
|
+ }),
|
|
|
+ writingAreaPlaceholder () {
|
|
|
+ // if (this.userInfo.type === 'TEACHER') {
|
|
|
+ return '写下针对本页的讨论(标题)'
|
|
|
+ // } else {
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ updateComments () {
|
|
|
+ getComments({ slideId: this.slide.id, pageNumber: this.currentPage }).then(res => {
|
|
|
+ this.comments = res.data
|
|
|
+ }).catch(err => {
|
|
|
+ this.$setErrorMessage('获取本页评论区的过程中:' + err.response.data.msg)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handleCommentSubmit (comment) {
|
|
|
+ createComment({
|
|
|
+ slideId: this.slide.id,
|
|
|
+ pageNumber: this.currentPage,
|
|
|
+ title: comment.title,
|
|
|
+ content: comment.content
|
|
|
+ }).then(res => {
|
|
|
+ this.$setSuccessMessage('您的讨论帖发表成功')
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
</script>
|
|
|
|