index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  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 phone_none">
  13. <div class="listHead">
  14. <div class="left">
  15. <span v-for="i in typeList" :key="index">
  16. <span v-if="item.type == i.value" class="one">{{ i.label }}</span>
  17. </span>
  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
  27. src='http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Rectangle.png'
  28. alt="">
  29. <span> {{ item.nickname }}</span>
  30. <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Chat.png"
  31. alt="">
  32. <span> {{ item.num ? item.num : 0 }}</span>
  33. </p>
  34. </div>
  35. <div class="right" v-show="item.group_name">
  36. <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Chat1.png" alt="">
  37. <span>{{ item.group_name }}</span>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="phone_li pc_none">
  42. <div class=" phone_li_tip_head">
  43. <span v-for="i in typeList" :key="index" class="phone_li_tag_box">
  44. <span v-if="item.type == i.value" class="phone_li_tag"> {{ i.label }}</span>
  45. </span>
  46. <div class="phone_li_time"> {{ item.created_at }}</div>
  47. </div>
  48. <div class="phone_li_tip">
  49. <div class="phone_li_img_box">
  50. <img v-if='item.avatar' :src="item.avatar" alt="">
  51. <img v-else
  52. src='http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Rectangle.png'
  53. alt="">
  54. </div>
  55. <span class="phone_li_name"> {{ item.nickname }}</span>
  56. </div>
  57. <div class="phone_li_tip">
  58. <div class="phone_li_title"> {{ item.title }}</div>
  59. </div>
  60. <div class="phone_li_tip">
  61. <div class="phone_li_icon_1">
  62. <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Chat.png" alt="">
  63. <div>
  64. {{ item.num ? item.num : 0 }}
  65. </div>
  66. </div>
  67. </div>
  68. <div class="phone_li_tip">
  69. <div class="phone_li_icon_2" v-show="item.group_name">
  70. <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Chat1.png" alt="">
  71. <div>
  72. {{ item.group_name }}
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. </NuxtLink>
  78. <div class="adEmpty" v-show="!currentPage">
  79. <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Blogs_empty.png" alt="">
  80. <span>暂无商圈列表~</span>
  81. </div>
  82. </el-tab-pane>
  83. <el-tab-pane :label="item.label" :name="item.value" v-for="item in typeList">
  84. <!-- 列表 -->
  85. <NuxtLink :to="`/topic/${item.id}`" v-for="item in listData">
  86. <div class="topicList phone_none">
  87. <div class="listHead">
  88. <div class="left">
  89. <span v-for="i in typeList" :key="index">
  90. <span v-if="item.type == i.value" class="one">{{ i.label }}</span>
  91. </span>
  92. </div>
  93. <div class="right">{{ item.created_at }}</div>
  94. </div>
  95. <div class="listFoot">
  96. <div class="left">
  97. <h2>{{ item.title }}</h2>
  98. <p>
  99. <img :src="item.avatar" alt="">
  100. <!-- <img v-else src='../../static/topic/Rectangle.png' alt=""> -->
  101. <span> {{ item.nickname }}</span>
  102. <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Chat.png"
  103. alt="">
  104. <span> {{ item.num ? item.num : 0 }}</span>
  105. </p>
  106. </div>
  107. <div class="right" v-show="item.group_name">
  108. <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Chat1.png" alt="">
  109. <span>{{ item.group_name }}</span>
  110. </div>
  111. </div>
  112. </div>
  113. <div class="phone_li pc_none">
  114. <div class=" phone_li_tip_head">
  115. <span v-for="i in typeList" :key="index" class="phone_li_tag_box">
  116. <span v-if="item.type == i.value" class="phone_li_tag"> {{ i.label }}</span>
  117. </span>
  118. <div class="phone_li_time"> {{ item.created_at }}</div>
  119. </div>
  120. <div class="phone_li_tip">
  121. <div class="phone_li_img_box">
  122. <img v-if='item.avatar' :src="item.avatar" alt="">
  123. <img v-else
  124. src='http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Rectangle.png'
  125. alt="">
  126. </div>
  127. <span class="phone_li_name"> {{ item.nickname }}</span>
  128. </div>
  129. <div class="phone_li_tip">
  130. <div class="phone_li_title"> {{ item.title }}</div>
  131. </div>
  132. <div class="phone_li_tip">
  133. <div class="phone_li_icon_1">
  134. <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Chat.png" alt="">
  135. <div>
  136. {{ item.num ? item.num : 0 }}
  137. </div>
  138. </div>
  139. </div>
  140. <div class="phone_li_tip">
  141. <div class="phone_li_icon_2" v-show="item.group_name">
  142. <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Chat1.png" alt="">
  143. <div>
  144. {{ item.group_name }}
  145. </div>
  146. </div>
  147. </div>
  148. </div>
  149. </NuxtLink>
  150. <div class="adEmpty" v-show="!currentPage">
  151. <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Blogs_empty.png" alt="">
  152. <span>暂无商圈列表~</span>
  153. </div>
  154. </el-tab-pane>
  155. </el-tabs>
  156. <!-- 分页 -->
  157. <div class="paginationBox phone_none" v-show="currentPage">
  158. <el-pagination background layout="prev, pager, next" :total="currentPage" prev-text="上一页"
  159. next-text="下一页" @change="pageChage" />
  160. </div>
  161. <div class="paginationBox pc_none" v-show="currentPage">
  162. <el-pagination pager-count="5" background layout=" pager " :total="currentPage"
  163. @change="pageChage" />
  164. </div>
  165. </div>
  166. </div>
  167. <!-- 页面底部 -->
  168. <HomeFoot1></HomeFoot1>
  169. </div>
  170. </template>
  171. <script setup>
  172. //1.引用模块 start ---------------------------------------->
  173. //使用ref和reactive动态变量
  174. import { ref, reactive, onMounted } from 'vue'
  175. //使用官方ssr请求模块
  176. // import { useNuxtApp, useFetch } from '#app'
  177. //使用element-plus组件
  178. import { ElTabs, ElTabPane, ElTable, ElTableColumn, ElPagination } from 'element-plus';
  179. // axios请求
  180. const nuxtApp = useNuxtApp();
  181. const axios = nuxtApp.$axios;
  182. //1.引用模块 end ---------------------------------------->
  183. // 定义响应式数据
  184. const seoData = ref({
  185. title: '商圈',
  186. description: '默认描述',
  187. keywords: '默认关键词',
  188. image: 'https://example.com/default-image.jpg'
  189. });
  190. // 在 onMounted 钩子中获取数据
  191. onMounted(() => {
  192. seoData.value.title = '商圈';
  193. seoData.value.description = '默认描述';
  194. seoData.value.keywords = '默认关键词';
  195. })
  196. //2.页面数据 start ---------------------------------------->
  197. const activeName = useState("activeName", () => '')
  198. const listData = useState("listData", () => [])//商圈列表
  199. const typeList = useState("typeList", () => [])//商圈分类
  200. const statusList = useState("statusList", () => [])//商圈状态
  201. // 分页相关
  202. const currentPage = useState("currentPage", () => 0)
  203. const pageSize = useState("pageSize", () => 10)
  204. const page = useState("page", () => 1)
  205. //2.页面数据 end ---------------------------------------->
  206. //3.分页 start ---------------------------------------->
  207. const pageChage = (val) => {
  208. page.value = val
  209. getTopicsList()
  210. }
  211. //3.分页 start ---------------------------------------->
  212. //4.请求商圈列表 start ---------------------------------------->
  213. const getTopicsList = () => {
  214. console.log('activeName', activeName.value);
  215. let data = new FormData()
  216. data.append('page', page.value)
  217. data.append('page_size', pageSize.value)
  218. data.append('status', 2)
  219. data.append('type', activeName.value)
  220. axios.post('chat/getTopicsList', data).then(response => {
  221. console.log(8899)
  222. console.log("response", response);
  223. listData.value = response.data.data;
  224. currentPage.value = response.data.total;
  225. })
  226. }
  227. const getTopicsList1 = () => {
  228. console.log('activeName', activeName.value);
  229. let data = new FormData()
  230. data.append('page', page.value)
  231. data.append('page_size', pageSize.value)
  232. data.append('status', 2)
  233. // data.append('type', activeName.value)
  234. axios.post('chat/getTopicsList', data).then(response => {
  235. // console.log(response);
  236. listData.value = response.data.data;
  237. currentPage.value = response.data.total;
  238. })
  239. }
  240. onMounted(() => {
  241. getTopicsList1();
  242. })
  243. //4.请求商圈列表 end ---------------------------------------->
  244. //5.获取分类和状态 start ---------------------------------------->
  245. const topicType = () => {
  246. axios.post('/chat/topicType').then(response => {
  247. console.log(111222333)
  248. console.log(response.data);
  249. // console.log(1);
  250. typeList.value = response.data;
  251. })
  252. }
  253. const topicStatus = () => {
  254. axios.post('chat/topicStatus').then(response => {
  255. console.log(response);
  256. })
  257. }
  258. onMounted(() => {
  259. //分类
  260. topicType();
  261. //状态
  262. topicStatus();
  263. })
  264. //5.获取分类和状态 end ---------------------------------------->
  265. //seo
  266. useSeoMeta({
  267. title: "商圈" + "_" + "三农资讯网_全国政务信息一体化应用平台",
  268. meta: [
  269. { name: 'description', content: "三农资讯网以服务于党和国家各级职能部门三农政务资讯发布及政务公开信息公示为基点,为全国县级以上各级党政机关及其职能部门配置各自公开独立网络发布平台。主要频道有:三农政务资讯,农科资讯,农资购销,农产购销,农贸资讯,三农致富信息,农村文化生活,三农政策法规,三农之窗,三农调查,三农服务,三农知识,农民工,打假维权等。三农资讯网打造最具影响力的三农信息发布平台,并成为最具权威的三农资讯网。_三农资讯网-测试专用_全国政务信息一体化应用平台", tagPriority: 10 },
  270. { name: 'keywords', content: "三农资讯,农业,三农,三农在线,农业新闻,三农资讯网_三农资讯网-测试专用_全国政务信息一体化应用平台", tagPriority: 10 },
  271. { name: 'viewport', content: 'width=device-width,initial-scale=1,user-scalable=no', tagPriority: 10 }
  272. ]
  273. });
  274. </script>
  275. <style lang="less" scoped>
  276. .demo-tabs>.el-tabs__content {
  277. padding: 32px;
  278. color: #6b778c;
  279. font-size: 32px;
  280. font-weight: 600;
  281. }
  282. .topicBox {
  283. margin-bottom: 30px;
  284. .inner {
  285. width: 1200px;
  286. margin: 0 auto;
  287. :deep(.el-tabs__header) {
  288. width: 1200px;
  289. margin: 0 auto;
  290. }
  291. :deep(.el-tabs__item) {
  292. padding: 0 100px 0 20px;
  293. font-size: 16px;
  294. height: 60px;
  295. }
  296. :deep(.el-tabs__item.is-active),
  297. :deep(.el-tabs__item:hover) {
  298. color: #33b023;
  299. }
  300. :deep(.el-tabs__active-bar) {
  301. background-color: #33b023;
  302. height: 0;
  303. }
  304. :deep(.el-tabs__nav) {
  305. height: 60px;
  306. }
  307. .adEmpty {
  308. margin: 150px auto;
  309. text-align: center;
  310. img {
  311. width: 78px;
  312. height: 78px;
  313. vertical-align: -28px;
  314. margin-right: 10px;
  315. }
  316. span {
  317. font-family: Microsoft YaHei, Microsoft YaHei;
  318. font-weight: bold;
  319. font-size: 26px;
  320. color: #CCCCCC;
  321. line-height: 30px;
  322. text-align: center;
  323. font-style: normal;
  324. text-transform: none;
  325. }
  326. }
  327. }
  328. .topicList {
  329. margin-top: 30px;
  330. height: 200px;
  331. border: 1px solid #e7e7e7;
  332. .listHead {
  333. height: 60px;
  334. padding: 15px 24px 15px 50px;
  335. border-bottom: 1px solid #e7e7e7;
  336. box-sizing: border-box;
  337. background-color: #fafafa;
  338. .left {
  339. div {
  340. font-family: Microsoft YaHei, Microsoft YaHei;
  341. font-weight: 400;
  342. font-size: 16px;
  343. color: #FFAA33;
  344. background-color: #fbebd5;
  345. padding: 5px 17px;
  346. }
  347. .one {
  348. color: #FFAA33;
  349. background-color: #fbebd5;
  350. display: block;
  351. padding: 5px 17px;
  352. }
  353. .two {
  354. color: #33B023;
  355. background-color: #d5ecd2;
  356. }
  357. .three {
  358. color: #666;
  359. background-color: #ebebeb;
  360. }
  361. }
  362. .right {
  363. font-family: Microsoft YaHei, Microsoft YaHei;
  364. font-weight: bold;
  365. font-size: 16px;
  366. color: #333333;
  367. padding: 5px 0;
  368. }
  369. }
  370. .listFoot {
  371. margin: 30px 50px;
  372. .left {
  373. h2 {
  374. font-family: Microsoft YaHei, Microsoft YaHei;
  375. font-weight: bold;
  376. font-size: 20px;
  377. color: #333333;
  378. }
  379. p {
  380. margin-top: 30px;
  381. img {
  382. width: 24px;
  383. height: 24px;
  384. vertical-align: middle;
  385. margin-right: 10px;
  386. }
  387. span {
  388. margin-right: 40px;
  389. font-family: Microsoft YaHei, Microsoft YaHei;
  390. font-weight: 400;
  391. font-size: 16px;
  392. color: #333333;
  393. }
  394. }
  395. }
  396. .right {
  397. color: #139602;
  398. margin-top: 27px;
  399. img {
  400. width: 24px;
  401. height: 24px;
  402. vertical-align: middle;
  403. margin-right: 10px;
  404. }
  405. span {
  406. font-family: Microsoft YaHei, Microsoft YaHei;
  407. font-weight: 400;
  408. font-size: 16px;
  409. }
  410. }
  411. }
  412. }
  413. }
  414. //分页样式
  415. .paginationBox {
  416. display: flex;
  417. justify-content: center;
  418. margin-top: 60px;
  419. margin-bottom: 90px;
  420. // 鼠标移入后字体颜色
  421. :deep(.el-pagination:hover) {
  422. color: #139609;
  423. }
  424. :deep(.el-pagination.is-background .btn-next),
  425. :deep(.el-pagination.is-background .btn-prev) {
  426. width: 70px;
  427. height: 34px;
  428. margin: 0px 10px;
  429. border-radius: 4px;
  430. }
  431. :deep(.el-pagination.is-background .el-pager li) {
  432. margin: 0px 10px;
  433. width: 38px;
  434. height: 34px;
  435. border-radius: 4px;
  436. }
  437. :deep(.el-pagination.is-background .btn-next.is-active),
  438. :deep(.el-pagination.is-background .btn-prev.is-active),
  439. :deep(.el-pagination.is-background .el-pager li.is-active) {
  440. background-color: #028e21;
  441. color: #fff;
  442. }
  443. }
  444. </style>
  445. <style lang="less" scoped>
  446. @media screen and (min-width:801px) {
  447. /*pc*/
  448. .pc_none {
  449. display: none;
  450. }
  451. }
  452. @media screen and (max-width:800px) {
  453. /*ipad_phone*/
  454. .topicBox .inner {
  455. width: 92%;
  456. }
  457. .topicBox .inner /deep/.el-tabs__header {
  458. width: 100%;
  459. }
  460. /deep/.el-tabs__nav-prev {
  461. display: none;
  462. }
  463. /deep/.el-tabs__nav-next {
  464. display: none;
  465. }
  466. .topicBox .inner /deep/.el-tabs__nav-scroll {
  467. height: 50px;
  468. }
  469. .topicBox .inner /deep/.el-tabs__nav {
  470. height: 50px;
  471. display: block;
  472. }
  473. .topicBox .inner /deep/.el-tabs__item {
  474. padding: 0;
  475. float: left;
  476. height: 100%;
  477. line-height: 50px;
  478. box-sizing: border-box;
  479. margin-right: 22px;
  480. }
  481. /deep/.el-tabs__nav .is-active {
  482. border-bottom: 2px solid #489d97;
  483. font-weight: bold;
  484. color: #489d97 !important;
  485. }
  486. .phone_li {
  487. overflow: hidden;
  488. border: solid 1px #e7e7e7;
  489. margin-top: 11px;
  490. box-sizing: border-box;
  491. width: 100%;
  492. padding: 0 0 6px;
  493. .phone_li_tip {
  494. overflow: hidden;
  495. width: 96%;
  496. margin: 0px auto 11px;
  497. }
  498. .phone_li_tip_head {
  499. background: #fafafa;
  500. margin-bottom: 11px;
  501. width: 100%;
  502. padding: 0px 3%;
  503. overflow: hidden;
  504. box-sizing: border-box;
  505. border-bottom: solid 1px #e7e7e7;
  506. }
  507. .phone_li_tag_box {
  508. width: 100%;
  509. overflow: hidden;
  510. }
  511. .phone_li_tag {
  512. margin: 8px 0;
  513. color: #FFAA33;
  514. background-color: #fbebd5;
  515. float: left;
  516. font-size: 14px;
  517. padding: 4px 12px;
  518. }
  519. .phone_li_time {
  520. float: right;
  521. height: 33px;
  522. line-height: 33px;
  523. font-size: 14px;
  524. color: #333;
  525. margin-top: 5px;
  526. }
  527. .phone_li_img_box {
  528. float: left;
  529. height: 40px;
  530. }
  531. .phone_li_img_box img {
  532. display: block;
  533. height: 100%;
  534. }
  535. .phone_li_name {
  536. display: block;
  537. height: 40px;
  538. line-height: 40px;
  539. font-size: 16px;
  540. color: #333;
  541. padding-left: 11px;
  542. box-sizing: border-box;
  543. word-break: keep-all;
  544. white-space: nowrap;
  545. overflow: hidden;
  546. text-overflow: ellipsis;
  547. }
  548. .phone_li_title {
  549. float: left;
  550. line-height: 22px;
  551. max-height: 44px;
  552. font-size: 18px;
  553. color: #333;
  554. font-weight: bold;
  555. overflow: hidden;
  556. display: -webkit-box !important;
  557. -webkit-box-orient: vertical;
  558. -webkit-line-clamp: 2;
  559. word-wrap: break-word;
  560. overflow-wrap: break-word;
  561. white-space: pre-wrap;
  562. word-break: break-all;
  563. }
  564. .phone_li_icon_1 {
  565. width: 100%;
  566. height: 22px;
  567. }
  568. .phone_li_icon_1 img {
  569. float: left;
  570. height: 22px;
  571. margin-right: 8px;
  572. }
  573. .phone_li_icon_1 div {
  574. height: 22px;
  575. line-height: 22px;
  576. font-size: 14px;
  577. color: #333;
  578. word-break: keep-all;
  579. white-space: nowrap;
  580. overflow: hidden;
  581. text-overflow: ellipsis;
  582. }
  583. .phone_li_icon_2 {
  584. height: 22px;
  585. width: 100%;
  586. }
  587. .phone_li_icon_2 img {
  588. float: left;
  589. height: 22px;
  590. margin-right: 8px;
  591. }
  592. .phone_li_icon_2 div {
  593. height: 22px;
  594. line-height: 22px;
  595. font-size: 14px;
  596. color: #333;
  597. word-break: keep-all;
  598. white-space: nowrap;
  599. overflow: hidden;
  600. text-overflow: ellipsis;
  601. }
  602. }
  603. .paginationBox {
  604. margin: 22px 0 0;
  605. }
  606. /deep/.el-pagination.is-background .el-pager .is-active {
  607. background-color: #489d97 !important;
  608. color: #fff;
  609. }
  610. .paginationBox /deep/.el-pagination.is-background .el-pager li {
  611. margin: 0px 4px;
  612. }
  613. .phone_none {
  614. display: none;
  615. }
  616. }
  617. </style>