index.vue 12 KB

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