detail.vue 7.7 KB

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