index.vue 13 KB

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