detail.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <div style="display: flex; justify-content: center" class="main-content-wrapper">
  3. <div style="width: 1200px">
  4. <a-card>
  5. <div class="flt">
  6. <div class="flex-1">
  7. <div style="display: flex; justify-content: space-between" v-if="detailObj.userNickName">
  8. <div style="display: flex">
  9. <a-avatar
  10. style="width: 60px; height: 60px"
  11. :src="detailObj.userAvatar"
  12. :size="{ xs: 24, sm: 32, md: 40, lg: 64, xl: 80, xxl: 100 }"
  13. />
  14. <div class="snowy-index-card-left-one-username">
  15. <span style="font-weight: 600; margin: 2px; font-size: 18px; min-height: 20px">{{
  16. detailObj.userNickName
  17. }}</span>
  18. <span style="color: #6d737b; margin: 2px">
  19. {{ detailObj.typeName ? detailObj.typeName + '|' : '' }}
  20. {{ formatDateTime(detailObj.lastReplyTime) }}
  21. </span>
  22. </div>
  23. </div>
  24. </div>
  25. <div class="forum-list-title">{{ detailObj.postTitle }}</div>
  26. </div>
  27. <a-tooltip :getPopupContainer="(trigger) => trigger.parentElement">
  28. <template #title>
  29. <span>返回</span>
  30. </template>
  31. <a-button @click="goToHome" type="primary">
  32. <rollback-outlined />
  33. </a-button>
  34. </a-tooltip>
  35. </div>
  36. <a-descriptions title="设备信息" class="equ" v-if="detailObj.forumSupportEnv">
  37. <a-descriptions-item label="浏览器类型:">
  38. <span>{{ detailObj.forumSupportEnv.browserType }}</span>
  39. </a-descriptions-item>
  40. <a-descriptions-item label="浏览器版本号:">
  41. <span>{{ detailObj.forumSupportEnv.browserVersion }}</span>
  42. </a-descriptions-item>
  43. <a-descriptions-item label="操作系统:">
  44. <span>{{ detailObj.forumSupportEnv.osType }}</span>
  45. </a-descriptions-item>
  46. <a-descriptions-item label="操作系统版本号:">
  47. <span>{{ detailObj.forumSupportEnv.osVersion }}</span>
  48. </a-descriptions-item>
  49. </a-descriptions>
  50. <div class="htmlContent" v-html="detailObj.postContent"></div>
  51. <div class="flc">
  52. <div v-if="detailObj.userNickName">
  53. <a-tooltip title="顶">
  54. <template v-if="detailObj.isLike == 1">
  55. <HeartOutlined :style="{ color: '#fa6c8d' }" @click="like(detailObj, 0)" />
  56. </template>
  57. <template v-else>
  58. <HeartOutlined @click="like(detailObj, 1)" />
  59. </template>
  60. </a-tooltip>
  61. <span style="padding-left: 3px">
  62. {{ detailObj.likeCount }}
  63. </span>
  64. </div>
  65. <div v-if="detailObj.userNickName" class="ml-2">
  66. <a-tooltip title="踩">
  67. <template v-if="detailObj.isNotLike == 1">
  68. <dislike-outlined :style="{ color: '#fa6c8d' }" @click="postnotlike(detailObj, 0)" />
  69. </template>
  70. <template v-else>
  71. <dislike-outlined @click="postnotlike(detailObj, 1)" />
  72. </template>
  73. </a-tooltip>
  74. </div>
  75. <div
  76. v-if="detailObj.isSelf == 1"
  77. style="cursor: pointer"
  78. @click="formRef.onOpen(detailObj, detailObj.postId)"
  79. >
  80. <EditOutlined class="ml-2" />
  81. <span style="padding-left: 3px">编辑</span>
  82. </div>
  83. <div class="ml-2" style="cursor: pointer" @click="replyFormRef.onOpen(detailObj, detailObj.postId)">
  84. <span>评论</span>
  85. <span style="padding-left: 3px">{{ detailObj.replyCount }}</span>
  86. </div>
  87. <div
  88. class="ml-2"
  89. style="cursor: pointer"
  90. v-if="detailObj.userNickName"
  91. @click="reportFormRef.onOpen(detailObj, detailObj.postId)"
  92. >
  93. <WarningOutlined />
  94. <span style="padding-left: 3px">举报</span>
  95. </div>
  96. </div>
  97. </a-card>
  98. <a-button type="primary" class="mt-2" @click="replyFormRef.onOpen(detailObj, detailObj.postId)">
  99. <template #icon><comment-outlined /></template>
  100. 评论
  101. </a-button>
  102. <a-card class="mt-2">
  103. <Comment
  104. :commentList="detailObj.replyList?.records"
  105. :params="commentParams"
  106. @successful="resetGetList()"
  107. ></Comment>
  108. <div style="display: flex; justify-content: center" class="mt-8">
  109. <a-button type="primary" shape="round" @click="morePaging" v-if="moreType"> 加载更多 </a-button>
  110. <div v-else>全部加载完毕</div>
  111. </div>
  112. </a-card>
  113. <replyForm ref="replyFormRef" @successful="resetGetList()" />
  114. <Form ref="formRef" @successful="resetGetList()" />
  115. <reportForm ref="reportFormRef" @successful="resetGetList()"></reportForm>
  116. </div>
  117. </div>
  118. </template>
  119. <script setup name="forumDetail">
  120. import forumApi from '@/api/forum/forumApi'
  121. import { useRoute, useRouter } from 'vue-router'
  122. import { parseTime } from '@/utils/exam'
  123. import Comment from '@/components/Comment/index.vue'
  124. import replyForm from './replyForm.vue'
  125. import reportForm from './reportForm.vue'
  126. import Form from './form.vue'
  127. const reportFormRef = ref()
  128. const replyFormRef = ref()
  129. const formRef = ref()
  130. const route = useRoute()
  131. const router = useRouter()
  132. const detailObj = ref({})
  133. const moreType = ref(true)
  134. const commentParams = ref({
  135. likeType: 1,
  136. targetId: route.query.postId
  137. })
  138. const pagination = ref({
  139. current: 1,
  140. size: 10
  141. })
  142. function like(item, l) {
  143. forumApi.postlikeSubmit({ likeType: 0, targetId: route.query.postId }, item.isLike).then((data) => {
  144. item.isLike = l
  145. resetGetList()
  146. })
  147. }
  148. function postnotlike(item, l) {
  149. forumApi
  150. .postPostnotlikeSubmit(
  151. { likeType: 0, targetId: route.query.postId, notLikeId: route.query.postId },
  152. item.isNotLike
  153. )
  154. .then((data) => {
  155. item.isNotLike = l
  156. resetGetList()
  157. })
  158. }
  159. function formatDateTime(val) {
  160. if (!val) return ''
  161. return parseTime(val, '{y}-{m}-{d} {h}:{i}:{s}')
  162. }
  163. function getDetail(p) {
  164. forumApi
  165. .forumTypeDetail({
  166. postId: route.query.postId,
  167. ...pagination.value
  168. })
  169. .then((data) => {
  170. if (p) {
  171. if (data.replyList.records.length > 0) {
  172. detailObj.value.replyList.records = detailObj.value.replyList.records.concat(data.replyList.records)
  173. } else {
  174. pagination.value.current -= 1
  175. moreType.value = false
  176. }
  177. } else {
  178. detailObj.value = data
  179. }
  180. })
  181. }
  182. function morePaging() {
  183. pagination.value.current += 1
  184. if (route.query.postId) {
  185. getDetail(true)
  186. } else {
  187. submitFormGetChapter(true)
  188. }
  189. }
  190. function resetGetList() {
  191. pagination.value.size = 10
  192. pagination.value.current = 1
  193. moreType.value = true
  194. if (route.query.postId) {
  195. getDetail()
  196. } else {
  197. submitFormGetChapter()
  198. }
  199. }
  200. const submitFormGetChapter = (p) => {
  201. forumApi
  202. .submitFormGetChapter({
  203. courseId: route.query.courseId,
  204. chapterId: route.query.chapterId,
  205. courseName: route.query.courseName,
  206. chapterName: route.query.chapterName,
  207. courseName: `${route.query.courseName}-${route.query.title}-${route.query.chapterName}`,
  208. ...pagination.value
  209. })
  210. .then((data) => {
  211. if (p) {
  212. if (data.replyList.records.length > 0) {
  213. detailObj.value.replyList.records = detailObj.value.replyList.records.concat(data.replyList.records)
  214. } else {
  215. pagination.value.current -= 1
  216. moreType.value = false
  217. }
  218. } else {
  219. detailObj.value = data
  220. }
  221. })
  222. }
  223. //回到首页
  224. const goToHome = () => {
  225. router.go(-1)
  226. }
  227. onMounted(() => {
  228. if (route.query.postId) {
  229. getDetail()
  230. } else {
  231. submitFormGetChapter()
  232. }
  233. })
  234. </script>
  235. <style scoped>
  236. :deep(.htmlContent img) {
  237. max-width: 100% !important;
  238. }
  239. :deep(.equ .ant-descriptions-header){
  240. margin-bottom: 10px;
  241. }
  242. .snowy-index-card-left-one-username {
  243. margin-left: 8px;
  244. display: flex;
  245. flex-direction: column;
  246. justify-content: center;
  247. }
  248. .forum-list-title {
  249. font-size: 30px;
  250. font-weight: bold;
  251. }
  252. .forum-list-content {
  253. font-size: 14px;
  254. color: #696969;
  255. }
  256. .flt {
  257. display: flex;
  258. justify-content: flex-start;
  259. align-items: flex-start;
  260. }
  261. .flc {
  262. display: flex;
  263. justify-content: flex-start;
  264. align-items: center;
  265. }
  266. </style>