index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <template>
  2. <div>
  3. <!-- 页面头部 -->
  4. <TopicHead></TopicHead>
  5. <div class="topicBox">
  6. <div class="inner">
  7. <el-tabs v-model="activeName" class="demo-tabs" @tab-change="getTopicsList">
  8. <el-tab-pane label="推荐" name="">
  9. <!-- 列表 -->
  10. <NuxtLink :to="`/topic/${item.id}`" target="_blank" v-for="item in listData">
  11. <div class="topicList">
  12. <div class="listHead">
  13. <div class="left">
  14. <div class="one" v-if="item.type == 1">科研</div>
  15. <div class="two" v-else-if="item.type == 2">维权</div>
  16. <div class="three" v-else-if="item.type == 3">讨论</div>
  17. </div>
  18. <div class="right">{{ item.created_at }}</div>
  19. </div>
  20. <div class="listFoot">
  21. <div class="left">
  22. <h2>{{ item.title }}</h2>
  23. <p>
  24. <img :src="item.avatar" alt="">
  25. <span> {{ item.author }}</span>
  26. <img src="../../static/topic/Chat.png" alt="">
  27. <span> {{ item.num }}</span>
  28. </p>
  29. </div>
  30. <div class="right" v-show="item.group_name">
  31. <img src="../../static/topic/Chat1.png" alt="">
  32. <span>{{ item.group_name }}</span>
  33. </div>
  34. </div>
  35. </div>
  36. </NuxtLink>
  37. </el-tab-pane>
  38. <el-tab-pane :label="item.label" :name="item.value" v-for="item in typeList">
  39. <!-- 列表 -->
  40. <NuxtLink :to="`/topic/${item.id}`" target="_blank" v-for="item in listData">
  41. <div class="topicList">
  42. <div class="listHead">
  43. <div class="left">
  44. <div class="one" v-if="item.type == 1">科研</div>
  45. <div class="two" v-else-if="item.type == 2">维权</div>
  46. <div class="three" v-else-if="item.type == 3">讨论</div>
  47. </div>
  48. <div class="right">{{ item.created_at }}</div>
  49. </div>
  50. <div class="listFoot">
  51. <div class="left">
  52. <h2>{{ item.title }}</h2>
  53. <p>
  54. <img :src="item.avatar" alt="">
  55. <span> {{ item.author }}</span>
  56. <img src="../../static/topic/Chat.png" alt="">
  57. <span> {{ }}</span>
  58. </p>
  59. </div>
  60. <div class="right">
  61. <img src="../../static/topic/Chat1.png" alt="">
  62. <span>{{ item.group_name }}</span>
  63. </div>
  64. </div>
  65. </div>
  66. </NuxtLink>
  67. </el-tab-pane>
  68. </el-tabs>
  69. <!-- 分页 -->
  70. <div class="paginationBox">
  71. <el-pagination background layout="prev, pager, next" :total="currentPage" prev-text="上一页"
  72. next-text="下一页" @change="pageChage" />
  73. </div>
  74. </div>
  75. </div>
  76. <!-- 页面底部 -->
  77. <AdvertisingFoot></AdvertisingFoot>
  78. </div>
  79. </template>
  80. <script setup>
  81. //1.引用模块 start ---------------------------------------->
  82. //使用ref和reactive动态变量
  83. import { ref, reactive, onMounted } from 'vue'
  84. //使用官方ssr请求模块
  85. // import { useNuxtApp, useFetch } from '#app'
  86. //使用element-plus组件
  87. import { ElTabs, ElTabPane, ElTable, ElTableColumn, ElPagination } from 'element-plus';
  88. // axios请求
  89. const nuxtApp = useNuxtApp();
  90. const axios = nuxtApp.$axios;
  91. //1.引用模块 end ---------------------------------------->
  92. //2.页面数据 start ---------------------------------------->
  93. const activeName = ref('')
  94. const listData = ref([])//商圈列表
  95. const typeList = ref([])//商圈分类
  96. const statusList = ref([])//商圈状态
  97. // 分页相关
  98. const currentPage = ref(0)
  99. const pageSize = ref(10)
  100. const page = ref(1)
  101. //2.页面数据 end ---------------------------------------->
  102. //3.分页 start ---------------------------------------->
  103. const pageChage = (val) => {
  104. page.value = val
  105. getTopicsList()
  106. }
  107. //3.分页 start ---------------------------------------->
  108. //4.请求商圈列表 start ---------------------------------------->
  109. const getTopicsList = () => {
  110. console.log('activeName', activeName.value);
  111. let data = new FormData()
  112. data.append('page', page.value)
  113. data.append('page_size', pageSize.value)
  114. // data.append('status', 2)
  115. data.append('type', activeName.value)
  116. axios.post('chat/getTopicsList', data).then(response => {
  117. // console.log(response);
  118. listData.value = response.data.data;
  119. currentPage.value = response.data.total;
  120. })
  121. }
  122. const getTopicsList1 = () => {
  123. console.log('activeName', activeName.value);
  124. let data = new FormData()
  125. data.append('page', page.value)
  126. data.append('page_size', pageSize.value)
  127. // data.append('status', 2)
  128. // data.append('type', activeName.value)
  129. axios.post('chat/getTopicsList', data).then(response => {
  130. // console.log(response);
  131. listData.value = response.data.data;
  132. currentPage.value = response.data.total;
  133. })
  134. }
  135. onMounted(() => {
  136. getTopicsList1();
  137. })
  138. //4.请求商圈列表 end ---------------------------------------->
  139. //5.获取分类和状态 start ---------------------------------------->
  140. const topicType = () => {
  141. axios.post('/chat/topicType').then(response => {
  142. // console.log(response.data);
  143. // console.log(1);
  144. typeList.value = response.data;
  145. })
  146. }
  147. const topicStatus = () => {
  148. axios.post('chat/topicStatus').then(response => {
  149. console.log(response);
  150. })
  151. }
  152. onMounted(() => {
  153. //分类
  154. topicType();
  155. //状态
  156. topicStatus();
  157. })
  158. //5.获取分类和状态 end ---------------------------------------->
  159. </script>
  160. <style lang="less" scoped>
  161. .demo-tabs>.el-tabs__content {
  162. padding: 32px;
  163. color: #6b778c;
  164. font-size: 32px;
  165. font-weight: 600;
  166. }
  167. .topicBox {
  168. margin-bottom: 30px;
  169. .inner {
  170. width: 1200px;
  171. margin: 0 auto;
  172. :deep(.el-tabs__header) {
  173. width: 1200px;
  174. margin: 0 auto;
  175. }
  176. :deep(.el-tabs__item) {
  177. padding: 0 100px 0 20px;
  178. font-size: 16px;
  179. height: 60px;
  180. }
  181. :deep(.el-tabs__item.is-active),
  182. :deep(.el-tabs__item:hover) {
  183. color: #33b023;
  184. }
  185. :deep(.el-tabs__active-bar) {
  186. background-color: #33b023;
  187. height: 0;
  188. }
  189. :deep(.el-tabs__nav) {
  190. height: 60px;
  191. }
  192. }
  193. .topicList {
  194. margin-top: 30px;
  195. height: 200px;
  196. border: 1px solid #e7e7e7;
  197. .listHead {
  198. height: 60px;
  199. padding: 15px 24px 15px 50px;
  200. border-bottom: 1px solid #e7e7e7;
  201. box-sizing: border-box;
  202. background-color: #fafafa;
  203. .left {
  204. div {
  205. font-family: Microsoft YaHei, Microsoft YaHei;
  206. font-weight: 400;
  207. font-size: 16px;
  208. color: #FFAA33;
  209. background-color: #fbebd5;
  210. padding: 5px 17px;
  211. }
  212. .one {
  213. color: #FFAA33;
  214. background-color: #fbebd5;
  215. }
  216. .two {
  217. color: #33B023;
  218. background-color: #d5ecd2;
  219. }
  220. .three {
  221. color: #666;
  222. background-color: #ebebeb;
  223. }
  224. }
  225. .right {
  226. font-family: Microsoft YaHei, Microsoft YaHei;
  227. font-weight: bold;
  228. font-size: 16px;
  229. color: #333333;
  230. padding: 5px 0;
  231. }
  232. }
  233. .listFoot {
  234. margin: 30px 50px;
  235. .left {
  236. h2 {
  237. font-family: Microsoft YaHei, Microsoft YaHei;
  238. font-weight: bold;
  239. font-size: 20px;
  240. color: #333333;
  241. }
  242. p {
  243. margin-top: 30px;
  244. img {
  245. width: 24px;
  246. height: 24px;
  247. vertical-align: middle;
  248. margin-right: 10px;
  249. }
  250. span {
  251. margin-right: 40px;
  252. font-family: Microsoft YaHei, Microsoft YaHei;
  253. font-weight: 400;
  254. font-size: 16px;
  255. color: #333333;
  256. }
  257. }
  258. }
  259. .right {
  260. color: #139602;
  261. margin-top: 27px;
  262. img {
  263. width: 24px;
  264. height: 24px;
  265. vertical-align: middle;
  266. margin-right: 10px;
  267. }
  268. span {
  269. font-family: Microsoft YaHei, Microsoft YaHei;
  270. font-weight: 400;
  271. font-size: 16px;
  272. }
  273. }
  274. }
  275. }
  276. }
  277. //分页样式
  278. .paginationBox {
  279. display: flex;
  280. justify-content: center;
  281. margin-top: 60px;
  282. margin-bottom: 90px;
  283. // 鼠标移入后字体颜色
  284. :deep(.el-pagination:hover) {
  285. color: #139609;
  286. }
  287. :deep(.el-pagination.is-background .btn-next),
  288. :deep(.el-pagination.is-background .btn-prev) {
  289. width: 70px;
  290. height: 34px;
  291. margin: 0px 10px;
  292. border-radius: 4px;
  293. }
  294. :deep(.el-pagination.is-background .el-pager li) {
  295. margin: 0px 10px;
  296. width: 38px;
  297. height: 34px;
  298. border-radius: 4px;
  299. }
  300. :deep(.el-pagination.is-background .btn-next.is-active),
  301. :deep(.el-pagination.is-background .btn-prev.is-active),
  302. :deep(.el-pagination.is-background .el-pager li.is-active) {
  303. background-color: #028e21;
  304. color: #fff;
  305. }
  306. }
  307. </style>