index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  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">
  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. </NuxtLink>
  42. <div class="adEmpty" v-show="!currentPage">
  43. <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Blogs_empty.png" alt="">
  44. <span>暂无商圈列表~</span>
  45. </div>
  46. </el-tab-pane>
  47. <el-tab-pane :label="item.label" :name="item.value" v-for="item in typeList">
  48. <!-- 列表 -->
  49. <NuxtLink :to="`/topic/${item.id}`" v-for="item in listData">
  50. <div class="topicList">
  51. <div class="listHead">
  52. <div class="left">
  53. <span v-for="i in typeList" :key="index">
  54. <span v-if="item.type == i.value" class="one">{{ i.label }}</span>
  55. </span>
  56. </div>
  57. <div class="right">{{ item.created_at }}</div>
  58. </div>
  59. <div class="listFoot">
  60. <div class="left">
  61. <h2>{{ item.title }}</h2>
  62. <p>
  63. <img :src="item.avatar" alt="">
  64. <!-- <img v-else src='../../static/topic/Rectangle.png' alt=""> -->
  65. <span> {{ item.nickname }}</span>
  66. <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Chat.png"
  67. alt="">
  68. <span> {{ item.num ? item.num : 0 }}</span>
  69. </p>
  70. </div>
  71. <div class="right" v-show="item.group_name">
  72. <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Chat1.png" alt="">
  73. <span>{{ item.group_name }}</span>
  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-tabs>
  84. <!-- 分页 -->
  85. <div class="paginationBox" v-show="currentPage">
  86. <el-pagination background layout="prev, pager, next" :total="currentPage" prev-text="上一页"
  87. next-text="下一页" @change="pageChage" />
  88. </div>
  89. </div>
  90. </div>
  91. <!-- 页面底部 -->
  92. <HomeFoot1></HomeFoot1>
  93. </div>
  94. </template>
  95. <script setup>
  96. //1.引用模块 start ---------------------------------------->
  97. //使用ref和reactive动态变量
  98. import { ref, reactive, onMounted } from 'vue'
  99. //使用官方ssr请求模块
  100. // import { useNuxtApp, useFetch } from '#app'
  101. //使用element-plus组件
  102. import { ElTabs, ElTabPane, ElTable, ElTableColumn, ElPagination } from 'element-plus';
  103. // axios请求
  104. const nuxtApp = useNuxtApp();
  105. const axios = nuxtApp.$axios;
  106. //1.引用模块 end ---------------------------------------->
  107. // 定义响应式数据
  108. const seoData = ref({
  109. title: '商圈',
  110. description: '默认描述',
  111. keywords: '默认关键词',
  112. image: 'https://example.com/default-image.jpg'
  113. });
  114. // 在 onMounted 钩子中获取数据
  115. onMounted(() => {
  116. seoData.value.title = '商圈';
  117. seoData.value.description = '默认描述';
  118. seoData.value.keywords = '默认关键词';
  119. })
  120. //2.页面数据 start ---------------------------------------->
  121. const activeName = useState("activeName", () => '')
  122. const listData = useState("listData", () => [])//商圈列表
  123. const typeList = useState("typeList", () => [])//商圈分类
  124. const statusList = useState("statusList", () => [])//商圈状态
  125. // 分页相关
  126. const currentPage = useState("currentPage", () => 0)
  127. const pageSize = useState("pageSize", () => 10)
  128. const page = useState("page", () => 1)
  129. //2.页面数据 end ---------------------------------------->
  130. //3.分页 start ---------------------------------------->
  131. const pageChage = (val) => {
  132. page.value = val
  133. getTopicsList()
  134. }
  135. //3.分页 start ---------------------------------------->
  136. //4.请求商圈列表 start ---------------------------------------->
  137. const getTopicsList = () => {
  138. console.log('activeName', activeName.value);
  139. let data = new FormData()
  140. data.append('page', page.value)
  141. data.append('page_size', pageSize.value)
  142. data.append('status', 2)
  143. data.append('type', activeName.value)
  144. axios.post('chat/getTopicsList', data).then(response => {
  145. console.log(8899)
  146. console.log("response", response);
  147. listData.value = response.data.data;
  148. currentPage.value = response.data.total;
  149. })
  150. }
  151. const getTopicsList1 = () => {
  152. console.log('activeName', activeName.value);
  153. let data = new FormData()
  154. data.append('page', page.value)
  155. data.append('page_size', pageSize.value)
  156. data.append('status', 2)
  157. // data.append('type', activeName.value)
  158. axios.post('chat/getTopicsList', data).then(response => {
  159. // console.log(response);
  160. listData.value = response.data.data;
  161. currentPage.value = response.data.total;
  162. })
  163. }
  164. onMounted(() => {
  165. getTopicsList1();
  166. })
  167. //4.请求商圈列表 end ---------------------------------------->
  168. //5.获取分类和状态 start ---------------------------------------->
  169. const topicType = () => {
  170. axios.post('/chat/topicType').then(response => {
  171. console.log(111222333)
  172. console.log(response.data);
  173. // console.log(1);
  174. typeList.value = response.data;
  175. })
  176. }
  177. const topicStatus = () => {
  178. axios.post('chat/topicStatus').then(response => {
  179. console.log(response);
  180. })
  181. }
  182. onMounted(() => {
  183. //分类
  184. topicType();
  185. //状态
  186. topicStatus();
  187. })
  188. //5.获取分类和状态 end ---------------------------------------->
  189. //seo
  190. useSeoMeta({
  191. title: "商圈" + "_" + "三农资讯网_全国政务信息一体化应用平台",
  192. meta: [
  193. { name: 'description', content: "三农资讯网以服务于党和国家各级职能部门三农政务资讯发布及政务公开信息公示为基点,为全国县级以上各级党政机关及其职能部门配置各自公开独立网络发布平台。主要频道有:三农政务资讯,农科资讯,农资购销,农产购销,农贸资讯,三农致富信息,农村文化生活,三农政策法规,三农之窗,三农调查,三农服务,三农知识,农民工,打假维权等。三农资讯网打造最具影响力的三农信息发布平台,并成为最具权威的三农资讯网。_三农资讯网-测试专用_全国政务信息一体化应用平台", tagPriority: 10 },
  194. { name: 'keywords', content: "三农资讯,农业,三农,三农在线,农业新闻,三农资讯网_三农资讯网-测试专用_全国政务信息一体化应用平台", tagPriority: 10 }
  195. ]
  196. });
  197. </script>
  198. <style lang="less" scoped>
  199. .demo-tabs>.el-tabs__content {
  200. padding: 32px;
  201. color: #6b778c;
  202. font-size: 32px;
  203. font-weight: 600;
  204. }
  205. .topicBox {
  206. margin-bottom: 30px;
  207. .inner {
  208. width: 1200px;
  209. margin: 0 auto;
  210. :deep(.el-tabs__header) {
  211. width: 1200px;
  212. margin: 0 auto;
  213. }
  214. :deep(.el-tabs__item) {
  215. padding: 0 100px 0 20px;
  216. font-size: 16px;
  217. height: 60px;
  218. }
  219. :deep(.el-tabs__item.is-active),
  220. :deep(.el-tabs__item:hover) {
  221. color: #33b023;
  222. }
  223. :deep(.el-tabs__active-bar) {
  224. background-color: #33b023;
  225. height: 0;
  226. }
  227. :deep(.el-tabs__nav) {
  228. height: 60px;
  229. }
  230. .adEmpty {
  231. margin: 150px auto;
  232. text-align: center;
  233. img {
  234. width: 78px;
  235. height: 78px;
  236. vertical-align: -28px;
  237. margin-right: 10px;
  238. }
  239. span {
  240. font-family: Microsoft YaHei, Microsoft YaHei;
  241. font-weight: bold;
  242. font-size: 26px;
  243. color: #CCCCCC;
  244. line-height: 30px;
  245. text-align: center;
  246. font-style: normal;
  247. text-transform: none;
  248. }
  249. }
  250. }
  251. .topicList {
  252. margin-top: 30px;
  253. height: 200px;
  254. border: 1px solid #e7e7e7;
  255. .listHead {
  256. height: 60px;
  257. padding: 15px 24px 15px 50px;
  258. border-bottom: 1px solid #e7e7e7;
  259. box-sizing: border-box;
  260. background-color: #fafafa;
  261. .left {
  262. div {
  263. font-family: Microsoft YaHei, Microsoft YaHei;
  264. font-weight: 400;
  265. font-size: 16px;
  266. color: #FFAA33;
  267. background-color: #fbebd5;
  268. padding: 5px 17px;
  269. }
  270. .one {
  271. color: #FFAA33;
  272. background-color: #fbebd5;
  273. display: block;
  274. padding: 5px 17px;
  275. }
  276. .two {
  277. color: #33B023;
  278. background-color: #d5ecd2;
  279. }
  280. .three {
  281. color: #666;
  282. background-color: #ebebeb;
  283. }
  284. }
  285. .right {
  286. font-family: Microsoft YaHei, Microsoft YaHei;
  287. font-weight: bold;
  288. font-size: 16px;
  289. color: #333333;
  290. padding: 5px 0;
  291. }
  292. }
  293. .listFoot {
  294. margin: 30px 50px;
  295. .left {
  296. h2 {
  297. font-family: Microsoft YaHei, Microsoft YaHei;
  298. font-weight: bold;
  299. font-size: 20px;
  300. color: #333333;
  301. }
  302. p {
  303. margin-top: 30px;
  304. img {
  305. width: 24px;
  306. height: 24px;
  307. vertical-align: middle;
  308. margin-right: 10px;
  309. }
  310. span {
  311. margin-right: 40px;
  312. font-family: Microsoft YaHei, Microsoft YaHei;
  313. font-weight: 400;
  314. font-size: 16px;
  315. color: #333333;
  316. }
  317. }
  318. }
  319. .right {
  320. color: #139602;
  321. margin-top: 27px;
  322. img {
  323. width: 24px;
  324. height: 24px;
  325. vertical-align: middle;
  326. margin-right: 10px;
  327. }
  328. span {
  329. font-family: Microsoft YaHei, Microsoft YaHei;
  330. font-weight: 400;
  331. font-size: 16px;
  332. }
  333. }
  334. }
  335. }
  336. }
  337. //分页样式
  338. .paginationBox {
  339. display: flex;
  340. justify-content: center;
  341. margin-top: 60px;
  342. margin-bottom: 90px;
  343. // 鼠标移入后字体颜色
  344. :deep(.el-pagination:hover) {
  345. color: #139609;
  346. }
  347. :deep(.el-pagination.is-background .btn-next),
  348. :deep(.el-pagination.is-background .btn-prev) {
  349. width: 70px;
  350. height: 34px;
  351. margin: 0px 10px;
  352. border-radius: 4px;
  353. }
  354. :deep(.el-pagination.is-background .el-pager li) {
  355. margin: 0px 10px;
  356. width: 38px;
  357. height: 34px;
  358. border-radius: 4px;
  359. }
  360. :deep(.el-pagination.is-background .btn-next.is-active),
  361. :deep(.el-pagination.is-background .btn-prev.is-active),
  362. :deep(.el-pagination.is-background .el-pager li.is-active) {
  363. background-color: #028e21;
  364. color: #fff;
  365. }
  366. }
  367. </style>