index.vue 23 KB

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