TallList.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. <template>
  2. <div style="display: flex">
  3. <div class="tallList">
  4. <div>
  5. <span style="font-weight: bold; font-size: 14px">发表评论</span>
  6. <span class="tallListInfo">文明上网理性发言,请遵守评论服务协议</span>
  7. </div>
  8. <!-- 切换 -->
  9. <div v-if="false">
  10. <div style="display: flex">
  11. <div style="display: flex; flex-direction: column; margin-left: 10px; margin-right: 10px">
  12. <div
  13. style="
  14. width: 30px;
  15. height: 30px;
  16. background: #1e90ff;
  17. border-radius: 50%;
  18. margin-top: 15px;
  19. margin-right: 15px;
  20. "
  21. ></div>
  22. <span style="display: block; font-size: 10px">未登录</span>
  23. </div>
  24. <div style="width: 100%; height: 100%; display: flex; position: relative">
  25. <a-textarea placeholder="" :rows="4" disabled style="margin-top: 5px" />
  26. <div
  27. style="
  28. flex-direction: column;
  29. display: flex;
  30. justify-content: center;
  31. align-items: center;
  32. position: absolute;
  33. left: 50%;
  34. top: 50%;
  35. transform: translate(-50%, -50%);
  36. "
  37. >
  38. <span style="display: block; cursor: pointer; font-size: 12px">登陆后可以发表评论</span>
  39. <span style="display: block; cursor: pointer; font-size: 12px; color: #1e90ff">立即登录</span>
  40. </div>
  41. </div>
  42. </div>
  43. <div style="display: flex; justify-content: flex-end; margin-top: 10px">
  44. <a-button style="width: 100px" disabled>发布</a-button>
  45. </div>
  46. </div>
  47. <div>
  48. <div style="display: flex">
  49. <div style="display: flex; flex-direction: column; margin-left: 10px; margin-right: 10px">
  50. <div
  51. style="
  52. width: 30px;
  53. height: 30px;
  54. background: #1e90ff;
  55. border-radius: 50%;
  56. margin-top: 15px;
  57. margin-right: 15px;
  58. "
  59. ></div>
  60. <span style="display: block; font-size: 10px">未登录</span>
  61. </div>
  62. <div style="width: 100%; height: 100%; display: flex; position: relative">
  63. <a-textarea placeholder="" :rows="4" v-model:value="talk" style="margin-top: 5px" />
  64. </div>
  65. </div>
  66. <div style="display: flex; justify-content: flex-end; margin-top: 10px">
  67. <a-button style="width: 100px" @click="handerPublish">发布</a-button>
  68. </div>
  69. </div>
  70. <div style="display: flex; justify-content: space-between; margin-top: 40px">
  71. <div style="display: flex; align-items: center">
  72. <span style="font-weight: bold">全部评论</span>
  73. <span style="font-size: 10px; color: darkgray; margin-left: 5px">1000</span>
  74. </div>
  75. <TabSwitcher></TabSwitcher>
  76. </div>
  77. <div class="line"></div>
  78. <div>
  79. <TallItem v-for="(item, index) in list" :key="index" :item="item" :id="id" @publish="publish"></TallItem>
  80. </div>
  81. </div>
  82. <div class="equalList">
  83. <div style="display: flex; align-items: center">
  84. <div class="resInfoTitile"></div>
  85. <span style="font-size: 14px; font-weight: bold">同类型资源</span>
  86. </div>
  87. <!-- <div style="display: flex; flex-direction: column; padding: 10px">
  88. <EqualItem v-for="(item, index) in equalList" :key="index" :item="item"></EqualItem>
  89. </div> -->
  90. </div>
  91. </div>
  92. </template>
  93. <script setup>
  94. import { ref } from 'vue'
  95. import TabSwitcher from './TabSwitcher.vue'
  96. import TallItem from './TallItem.vue'
  97. import EqualItem from './EqualItem.vue'
  98. import { addViewCount, detail, add, cancel, queryList, pageComment, addComment } from '@/api/portal'
  99. import { useRoute } from 'vue-router'
  100. import EventBus from '@/utils/EventBus'
  101. import { list } from '@/api/portal'
  102. const currentPage = reactive({
  103. funcType: 1,
  104. current: 1,
  105. size: 6
  106. })
  107. const emit = defineEmits(['selectTab'])
  108. const listUnpublishedView = ref(null)
  109. const route = useRoute()
  110. const id = route.query.id
  111. const talk = ref('')
  112. const pagers = ref({
  113. pages: 1,
  114. size: 20
  115. })
  116. const equalList = ref([])
  117. // callBackTalk: [
  118. // {
  119. // id: 2,
  120. // name: '李四',
  121. // talk: '不给',
  122. // follw: 0
  123. // }
  124. // ]
  125. const getList = () => {
  126. list(currentPage)
  127. .then((res) => {
  128. console.log('下面列表获取', res)
  129. if (res.code == 200) {
  130. recommendations.value = res.data.records
  131. currentPage.current = res.data.current
  132. // "size": 20,
  133. // "current": 1,
  134. // "pages": 1
  135. }
  136. // {
  137. // "code": 200,
  138. // "msg": "操作成功",
  139. // "data": {
  140. // "records": [
  141. // {
  142. // "publishTime": 1750820852119,
  143. // "courseName": "转手绢",
  144. // "collegeIdName": "二人转研究学院",
  145. // "teacherId": "1936984714123436034",
  146. // "coverImageId": "1936957954687279104",
  147. // "collegeId": "1",
  148. // "timeLimitType": "0",
  149. // "viewCount": 0,
  150. // "courseId": "1937091089341124610",
  151. // "teacherIdName": "老师"
  152. // },
  153. // {
  154. // "publishTime": 1750820875604,
  155. // "courseName": "胸口碎大石",
  156. // "collegeIdName": "二人转研究学院",
  157. // "teacherId": "1936984714123436034",
  158. // "coverImageId": "1937056330116354050",
  159. // "coverImagePath": "http://localhost:9003/api/webapp/dev/file/download?id=1937056330116354050",
  160. // "collegeId": "1",
  161. // "timeLimitType": "0",
  162. // "viewCount": 10000,
  163. // "courseId": "1937326992873689089",
  164. // "teacherIdName": "老师"
  165. // }
  166. // ],
  167. // "total": 2,
  168. // "size": 20,
  169. // "current": 1,
  170. // "orders": [],
  171. // "optimizeCountSql": true,
  172. // "searchCount": true,
  173. // "maxLimit": null,
  174. // "countId": null,
  175. // "pages": 1
  176. // }
  177. // }
  178. })
  179. .catch((err) => {
  180. console.log(err)
  181. })
  182. }
  183. const publish = (data) => {
  184. // { pid: props.item.id, talk }
  185. addComment({ pid: data.id, resourceId: data.resourceId, commentName: data.talk })
  186. .then((res) => {
  187. getPageComment()
  188. talk.value = ''
  189. })
  190. .catch((err) => {
  191. console.log(err)
  192. })
  193. // list.value[0].callBackTalk.push({
  194. // id: 1,
  195. // name: '张三',
  196. // talk: '今天,我被你给打赏了1000元,请给我一个好评,谢谢123123123',
  197. // follw: 0
  198. // })
  199. // list.value = [...list.value]
  200. // console.log('最后的', list.value)
  201. }
  202. const handerPublish = () => {
  203. addComment({ resourceId: id, commentName: talk.value })
  204. .then((res) => {
  205. getPageComment()
  206. talk.value = ''
  207. EventBus.emit('upDataDetailsNum')
  208. })
  209. .catch((err) => {
  210. console.log(err)
  211. })
  212. //....
  213. // listUnpublishedView.value.setData(tableData.value)
  214. }
  215. const onQuery = (form) => {
  216. console.log('查询内容', form)
  217. //....
  218. // listUnpublishedView.value.setData(tableData.value)
  219. }
  220. const getPageComment = () => {
  221. pageComment({ resourceId: id, ...pagers.value })
  222. .then((res) => {
  223. if (res.code == 200) {
  224. list.value = res.data.records
  225. pagers.value.pages = res.data.pages
  226. pagers.value.size = res.data.size
  227. }
  228. })
  229. .catch((err) => {
  230. console.log(err)
  231. })
  232. }
  233. onMounted(() => {
  234. getList()
  235. getPageComment()
  236. })
  237. EventBus.off('onGetPageComment', getPageComment)
  238. EventBus.on('onGetPageComment', getPageComment)
  239. </script>
  240. <style scoped>
  241. .tab-switcher {
  242. display: flex;
  243. border-radius: 20px;
  244. border: 1px solid #1e90ff;
  245. overflow: hidden;
  246. }
  247. .tab-switcher div {
  248. padding: 2px 20px;
  249. background-color: #f5f5f5;
  250. cursor: pointer;
  251. }
  252. .tab-switcher div.active {
  253. background-color: #1e90ff;
  254. color: white;
  255. }
  256. .tab-switcher div:not(:last-child) {
  257. }
  258. .user-info {
  259. display: flex;
  260. align-items: center;
  261. width: 100%;
  262. height: 200px;
  263. border: 1px solid #dfe2e5;
  264. padding: 20px;
  265. }
  266. .resource-container {
  267. width: 850px;
  268. margin: 0 auto;
  269. padding: 20px;
  270. border: 1px solid #dfe2e5;
  271. }
  272. .user-avatar {
  273. width: 40px;
  274. height: 40px;
  275. background: #1e90ff;
  276. border-radius: 50%;
  277. margin-right: 10px;
  278. }
  279. .user-details {
  280. flex: 1;
  281. }
  282. .user-name {
  283. font-size: 13px;
  284. font-weight: bold;
  285. }
  286. .publish-time {
  287. font-size: 12px;
  288. color: #999;
  289. margin-top: 5px;
  290. }
  291. .metrics {
  292. display: flex;
  293. align-items: center;
  294. justify-content: center;
  295. }
  296. .metric-item {
  297. display: flex;
  298. flex-direction: column;
  299. align-items: center;
  300. padding-left: 10px;
  301. padding-right: 10px;
  302. }
  303. .metric-item span:first-child {
  304. font-size: 18px;
  305. font-weight: bold;
  306. }
  307. .metric-item span:last-child {
  308. font-size: 12px;
  309. color: #666;
  310. }
  311. .actions {
  312. display: flex;
  313. }
  314. .share-btn,
  315. .favorite-btn {
  316. background-color: transparent;
  317. border: none;
  318. cursor: pointer;
  319. }
  320. .course-info {
  321. margin-top: 20px;
  322. line-height: 1.6;
  323. }
  324. .liene {
  325. height: 35px;
  326. width: 1px;
  327. background: #00000018;
  328. }
  329. .resource-container {
  330. width: 850px;
  331. margin: 0 auto;
  332. padding: 20px;
  333. border: 1px solid #dfe2e5;
  334. }
  335. h1 {
  336. text-align: center;
  337. margin-bottom: 20px;
  338. }
  339. .ant-descriptions {
  340. margin-top: 20px;
  341. }
  342. .ant-typography-title {
  343. margin-top: 20px;
  344. }
  345. .ant-typography-paragraph {
  346. margin-top: 10px;
  347. }
  348. .ant-space {
  349. margin-top: 10px;
  350. }
  351. .video-info {
  352. height: 100%; /* 确保填满容器高度 */
  353. }
  354. .resInfo {
  355. margin-left: 10px;
  356. width: 350px;
  357. height: 570px;
  358. border: 1px solid #dfe2e5;
  359. padding: 10px;
  360. }
  361. .user-info-container {
  362. display: flex;
  363. }
  364. .resInfoTitile {
  365. width: 5px;
  366. height: 14px;
  367. background-color: cadetblue;
  368. margin-right: 5px;
  369. }
  370. .tallList {
  371. display: flex;
  372. flex-direction: column;
  373. width: 850px;
  374. border: 1px solid #dfe2e5;
  375. padding: 20px;
  376. margin-top: 10px;
  377. }
  378. .tallListInfo {
  379. color: rgba(0, 0, 0, 0.116);
  380. font-size: 12px;
  381. }
  382. .line {
  383. width: 100%;
  384. height: 0.5px;
  385. background-color: rgba(0, 0, 0, 0.075);
  386. margin-top: 10px;
  387. margin-bottom: 10px;
  388. }
  389. .equalList {
  390. display: flex;
  391. flex-direction: column;
  392. width: 300px;
  393. border: 1px solid #dfe2e5;
  394. padding: 10px;
  395. margin-top: 10px;
  396. margin-left: 10px;
  397. }
  398. .resInfoTitile {
  399. width: 5px;
  400. height: 14px;
  401. background-color: #1e90ff;
  402. margin-right: 5px;
  403. }
  404. </style>