index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  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. <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.author }}</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. </NuxtLink>
  39. <div class="adEmpty" v-show="!currentPage">
  40. <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/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. <span v-for="i in typeList" :key="index">
  51. <span v-if="item.type == i.value" class="one">{{i.label}}</span>
  52. </span>
  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.author }}</span>
  63. <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/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="http://img.bjzxtw.org.cn/master/bjzxtw/public/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="http://img.bjzxtw.org.cn/master/bjzxtw/public/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(8899)
  142. console.log("response", response);
  143. listData.value = response.data.data;
  144. currentPage.value = response.data.total;
  145. })
  146. }
  147. const getTopicsList1 = () => {
  148. console.log('activeName', activeName.value);
  149. let data = new FormData()
  150. data.append('page', page.value)
  151. data.append('page_size', pageSize.value)
  152. data.append('status', 2)
  153. // data.append('type', activeName.value)
  154. axios.post('chat/getTopicsList', data).then(response => {
  155. // console.log(response);
  156. listData.value = response.data.data;
  157. currentPage.value = response.data.total;
  158. })
  159. }
  160. onMounted(() => {
  161. getTopicsList1();
  162. })
  163. //4.请求商圈列表 end ---------------------------------------->
  164. //5.获取分类和状态 start ---------------------------------------->
  165. const topicType = () => {
  166. axios.post('/chat/topicType').then(response => {
  167. console.log(111222333)
  168. console.log(response.data);
  169. // console.log(1);
  170. typeList.value = response.data;
  171. })
  172. }
  173. const topicStatus = () => {
  174. axios.post('chat/topicStatus').then(response => {
  175. console.log(response);
  176. })
  177. }
  178. onMounted(() => {
  179. //分类
  180. topicType();
  181. //状态
  182. topicStatus();
  183. })
  184. //5.获取分类和状态 end ---------------------------------------->
  185. //seo
  186. useSeoMeta({
  187. title: "商圈" + "_" + "三农资讯网_全国政务信息一体化应用平台",
  188. meta: [
  189. { name: 'description', content: "三农资讯网以服务于党和国家各级职能部门三农政务资讯发布及政务公开信息公示为基点,为全国县级以上各级党政机关及其职能部门配置各自公开独立网络发布平台。主要频道有:三农政务资讯,农科资讯,农资购销,农产购销,农贸资讯,三农致富信息,农村文化生活,三农政策法规,三农之窗,三农调查,三农服务,三农知识,农民工,打假维权等。三农资讯网打造最具影响力的三农信息发布平台,并成为最具权威的三农资讯网。_三农资讯网-测试专用_全国政务信息一体化应用平台" , tagPriority: 10 },
  190. { name: 'keywords', content: "三农资讯,农业,三农,三农在线,农业新闻,三农资讯网_三农资讯网-测试专用_全国政务信息一体化应用平台" , tagPriority: 10 }
  191. ]
  192. });
  193. </script>
  194. <style lang="less" scoped>
  195. .demo-tabs>.el-tabs__content {
  196. padding: 32px;
  197. color: #6b778c;
  198. font-size: 32px;
  199. font-weight: 600;
  200. }
  201. .topicBox {
  202. margin-bottom: 30px;
  203. .inner {
  204. width: 1200px;
  205. margin: 0 auto;
  206. :deep(.el-tabs__header) {
  207. width: 1200px;
  208. margin: 0 auto;
  209. }
  210. :deep(.el-tabs__item) {
  211. padding: 0 100px 0 20px;
  212. font-size: 16px;
  213. height: 60px;
  214. }
  215. :deep(.el-tabs__item.is-active),
  216. :deep(.el-tabs__item:hover) {
  217. color: #33b023;
  218. }
  219. :deep(.el-tabs__active-bar) {
  220. background-color: #33b023;
  221. height: 0;
  222. }
  223. :deep(.el-tabs__nav) {
  224. height: 60px;
  225. }
  226. .adEmpty {
  227. margin: 150px auto;
  228. text-align: center;
  229. img {
  230. width: 78px;
  231. height: 78px;
  232. vertical-align: -28px;
  233. margin-right: 10px;
  234. }
  235. span {
  236. font-family: Microsoft YaHei, Microsoft YaHei;
  237. font-weight: bold;
  238. font-size: 26px;
  239. color: #CCCCCC;
  240. line-height: 30px;
  241. text-align: center;
  242. font-style: normal;
  243. text-transform: none;
  244. }
  245. }
  246. }
  247. .topicList {
  248. margin-top: 30px;
  249. height: 200px;
  250. border: 1px solid #e7e7e7;
  251. .listHead {
  252. height: 60px;
  253. padding: 15px 24px 15px 50px;
  254. border-bottom: 1px solid #e7e7e7;
  255. box-sizing: border-box;
  256. background-color: #fafafa;
  257. .left {
  258. div {
  259. font-family: Microsoft YaHei, Microsoft YaHei;
  260. font-weight: 400;
  261. font-size: 16px;
  262. color: #FFAA33;
  263. background-color: #fbebd5;
  264. padding: 5px 17px;
  265. }
  266. .one {
  267. color: #FFAA33;
  268. background-color: #fbebd5;
  269. display: block;
  270. padding: 5px 17px;
  271. }
  272. .two {
  273. color: #33B023;
  274. background-color: #d5ecd2;
  275. }
  276. .three {
  277. color: #666;
  278. background-color: #ebebeb;
  279. }
  280. }
  281. .right {
  282. font-family: Microsoft YaHei, Microsoft YaHei;
  283. font-weight: bold;
  284. font-size: 16px;
  285. color: #333333;
  286. padding: 5px 0;
  287. }
  288. }
  289. .listFoot {
  290. margin: 30px 50px;
  291. .left {
  292. h2 {
  293. font-family: Microsoft YaHei, Microsoft YaHei;
  294. font-weight: bold;
  295. font-size: 20px;
  296. color: #333333;
  297. }
  298. p {
  299. margin-top: 30px;
  300. img {
  301. width: 24px;
  302. height: 24px;
  303. vertical-align: middle;
  304. margin-right: 10px;
  305. }
  306. span {
  307. margin-right: 40px;
  308. font-family: Microsoft YaHei, Microsoft YaHei;
  309. font-weight: 400;
  310. font-size: 16px;
  311. color: #333333;
  312. }
  313. }
  314. }
  315. .right {
  316. color: #139602;
  317. margin-top: 27px;
  318. img {
  319. width: 24px;
  320. height: 24px;
  321. vertical-align: middle;
  322. margin-right: 10px;
  323. }
  324. span {
  325. font-family: Microsoft YaHei, Microsoft YaHei;
  326. font-weight: 400;
  327. font-size: 16px;
  328. }
  329. }
  330. }
  331. }
  332. }
  333. //分页样式
  334. .paginationBox {
  335. display: flex;
  336. justify-content: center;
  337. margin-top: 60px;
  338. margin-bottom: 90px;
  339. // 鼠标移入后字体颜色
  340. :deep(.el-pagination:hover) {
  341. color: #139609;
  342. }
  343. :deep(.el-pagination.is-background .btn-next),
  344. :deep(.el-pagination.is-background .btn-prev) {
  345. width: 70px;
  346. height: 34px;
  347. margin: 0px 10px;
  348. border-radius: 4px;
  349. }
  350. :deep(.el-pagination.is-background .el-pager li) {
  351. margin: 0px 10px;
  352. width: 38px;
  353. height: 34px;
  354. border-radius: 4px;
  355. }
  356. :deep(.el-pagination.is-background .btn-next.is-active),
  357. :deep(.el-pagination.is-background .btn-prev.is-active),
  358. :deep(.el-pagination.is-background .el-pager li.is-active) {
  359. background-color: #028e21;
  360. color: #fff;
  361. }
  362. }
  363. </style>