index.vue 23 KB

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