topic.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <script setup>
  2. import { EditPen, ArrowLeft, ArrowRight } from "@element-plus/icons-vue";
  3. import MomentLayout from "~/components/MomentLayout/index.vue";
  4. import { ref } from "vue";
  5. import { useRouter, useRoute } from "vue-router";
  6. const router = useRouter();
  7. const route = useRoute();
  8. //论坛接口
  9. import * as topic from "~/api/topic";
  10. import * as forum from "~/api/forum";
  11. import { onMounted } from "vue";
  12. //标题
  13. // document.title = toptitle ;
  14. //论坛列表
  15. let toptitle = ref();
  16. let foruminfo = ref([]);
  17. const __forum__ = async () => {
  18. try {
  19. const { data } = await forum.list({
  20. is_page: 0,
  21. topic_id: route.query.id,
  22. });
  23. foruminfo.value = data;
  24. toptitle.value = data[0].topic.title;
  25. document.title = "【" + toptitle.value + "】话题";
  26. } catch (error) {}
  27. };
  28. onMounted(__forum__);
  29. // 话题推荐
  30. let topList = ref([]);
  31. const __news__ = async () => {
  32. try {
  33. const { data } = await topic.list({
  34. is_recommend: 1,
  35. is_page: 0,
  36. });
  37. topList.value = data;
  38. } catch (error) {}
  39. };
  40. onMounted(__news__);
  41. //参加话题
  42. const jointopic = () => {
  43. router.push({
  44. path: "/forum/edit",
  45. query:{
  46. id:route.query.id
  47. }
  48. });
  49. };
  50. const handleRefreshListData = () => {
  51. // TODO: 刷新列表数据
  52. };
  53. //返回
  54. const returnup = () => {
  55. router.go(-1);
  56. };
  57. </script>
  58. <template>
  59. <div class="topic-container flex-row">
  60. <div class="topic__left-context">
  61. <div class="topic__header">
  62. <div class="topic-back-btn flex-row flex-aic">
  63. <el-icon :size="18"> <ArrowLeft /> </el-icon
  64. ><span @click="returnup">返回</span>
  65. </div>
  66. <div class="topic__header-main">
  67. <div class="topic-title">#{{ toptitle }}</div>
  68. <p class="topic-descs">descssssss</p>
  69. <el-button type="primary" :icon="EditPen" @click="jointopic"
  70. >参与</el-button
  71. >
  72. </div>
  73. </div>
  74. <div class="context">
  75. <template v-for="(item, idx) in foruminfo" :key="idx">
  76. <MomentLayout
  77. type="forum"
  78. :detail="item"
  79. @refresh="handleRefreshListData"
  80. />
  81. </template>
  82. </div>
  83. </div>
  84. <div class="topic__side">
  85. <div class="see-more flex-row flex-aic flex-jc-sb">
  86. <span>查看全部论坛</span>
  87. <el-icon :size="18">
  88. <ArrowRight></ArrowRight>
  89. </el-icon>
  90. </div>
  91. <!-- 论坛推荐 -->
  92. <dl class="forum-recommend">
  93. <dt>论坛推荐</dt>
  94. <dd class="ellipsis" v-for="(item, index) in topList" :key="index">
  95. {{ item.title }}
  96. </dd>
  97. </dl>
  98. </div>
  99. </div>
  100. </template>
  101. <style lang="scss" scoped>
  102. .topic {
  103. &-container {
  104. column-gap: 20px;
  105. }
  106. &__header {
  107. margin-bottom: 20px;
  108. background-color: #fff;
  109. border-radius: 10px;
  110. .topic-back-btn {
  111. font-size: 16px;
  112. font-weight: 400;
  113. color: #333333;
  114. line-height: 38px;
  115. border-bottom: 1px solid #f6f6f6;
  116. padding: 20px 20px 6px;
  117. margin-bottom: 18px;
  118. }
  119. &-main {
  120. padding: 0 20px 20px;
  121. }
  122. .topic-title {
  123. font-size: 26px;
  124. font-weight: 600;
  125. color: #222222;
  126. }
  127. .topic-descs {
  128. font-size: 14px;
  129. font-weight: 400;
  130. color: #777777;
  131. }
  132. }
  133. &__left-context {
  134. width: 0;
  135. flex: 1;
  136. .context {
  137. .moment-layout-container {
  138. margin-bottom: 20px;
  139. border-radius: 10px;
  140. }
  141. }
  142. }
  143. &__side {
  144. width: 400px;
  145. .see-more {
  146. padding: 16px 20px;
  147. border-radius: 10px;
  148. background-color: #fff;
  149. margin-bottom: 20px;
  150. font-size: 16px;
  151. font-weight: 500;
  152. color: #222222;
  153. }
  154. .forum-recommend {
  155. list-style: none;
  156. padding: 0;
  157. margin: 0;
  158. background-color: #fff;
  159. border-radius: 10px;
  160. padding-bottom: 13px;
  161. dt {
  162. font-size: 16px;
  163. font-weight: 500;
  164. color: #333333;
  165. padding: 14px 20px 10px;
  166. border-bottom: 1px solid #f6f6f6;
  167. }
  168. dd {
  169. padding: 6px 20px;
  170. margin: 0;
  171. }
  172. }
  173. }
  174. }
  175. </style>