index.vue 13 KB

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