index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. <template>
  2. <div>
  3. <!-- 页面头部 -->
  4. <!-- <HomePageHead></HomePageHead>
  5. <HomePageNavigation1></HomePageNavigation1> -->
  6. <!-- 头部 -->
  7. <templateHead v-if="skinId <= 4"></templateHead>
  8. <!-- 皮肤5头部 -->
  9. <templateHead5 v-if="skinId == 5"></templateHead5>
  10. <!-- 菜单 -->
  11. <templateMenu v-if="skinId <= 4"></templateMenu>
  12. <!-- 皮肤5菜单 -->
  13. <templateMenu5 v-if="skinId == 5"></templateMenu5>
  14. <div class="topicBox">
  15. <div class="inner">
  16. <el-tabs v-model="activeName" class="demo-tabs" @tab-change="getTopicsList">
  17. <el-tab-pane label="推荐" name="">
  18. <!-- 列表 -->
  19. <NuxtLink :to="`/topic/${item.id}`" v-for="item in listData" :key="index">
  20. <div class="topicList">
  21. <div class="listHead">
  22. <div class="left">
  23. <span v-for="i in typeList" :key="index">
  24. <span v-if="item.type == i.value" class="one">{{ i.label }}</span>
  25. </span>
  26. </div>
  27. <div class="right">{{ item.created_at }}</div>
  28. </div>
  29. <div class="listFoot">
  30. <div class="left">
  31. <h2>{{ item.title }}</h2>
  32. <p>
  33. <img v-if='item.avatar' :src="item.avatar" alt="">
  34. <img v-else
  35. src='http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Rectangle.png'
  36. alt="">
  37. <span> {{ item.nickname }}</span>
  38. <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Chat.png"
  39. alt="">
  40. <span> {{ item.num ? item.num : 0 }}</span>
  41. </p>
  42. </div>
  43. <div class="right" v-show="item.group_name">
  44. <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Chat1.png" alt="">
  45. <span>{{ item.group_name }}</span>
  46. </div>
  47. </div>
  48. </div>
  49. </NuxtLink>
  50. <div class="adEmpty" v-show="!currentPage">
  51. <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Blogs_empty.png" alt="">
  52. <span>暂无商圈列表~</span>
  53. </div>
  54. </el-tab-pane>
  55. <el-tab-pane :label="item.label" :name="item.value" v-for="item in typeList">
  56. <!-- 列表 -->
  57. <NuxtLink :to="`/topic/${item.id}`" v-for="item in listData">
  58. <div class="topicList">
  59. <div class="listHead">
  60. <div class="left">
  61. <span v-for="i in typeList" :key="index">
  62. <span v-if="item.type == i.value" class="one">{{ i.label }}</span>
  63. </span>
  64. </div>
  65. <div class="right">{{ item.created_at }}</div>
  66. </div>
  67. <div class="listFoot">
  68. <div class="left">
  69. <h2>{{ item.title }}</h2>
  70. <p>
  71. <img :src="item.avatar" alt="">
  72. <!-- <img v-else src='../../static/topic/Rectangle.png' alt=""> -->
  73. <span> {{ item.nickname }}</span>
  74. <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Chat.png"
  75. alt="">
  76. <span> {{ item.num ? item.num : 0 }}</span>
  77. </p>
  78. </div>
  79. <div class="right" v-show="item.group_name">
  80. <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Chat1.png" alt="">
  81. <span>{{ item.group_name }}</span>
  82. </div>
  83. </div>
  84. </div>
  85. </NuxtLink>
  86. <div class="adEmpty" v-show="!currentPage">
  87. <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Blogs_empty.png" alt="">
  88. <span>暂无商圈列表~</span>
  89. </div>
  90. </el-tab-pane>
  91. </el-tabs>
  92. <!-- 分页 -->
  93. <div class="paginationBox" v-show="currentPage">
  94. <el-pagination background layout="prev, pager, next" :total="currentPage" prev-text="上一页"
  95. next-text="下一页" @change="pageChage" />
  96. </div>
  97. </div>
  98. </div>
  99. <!-- 页面底部 -->
  100. <!-- <HomeFoot1></HomeFoot1> -->
  101. <templateFoot v-if="skinId <= 4"></templateFoot>
  102. <!-- 皮肤5底部 -->
  103. <templateFoot1 v-if="skinId == 5"></templateFoot1>
  104. </div>
  105. </template>
  106. <script setup>
  107. //1.引用模块 start ---------------------------------------->
  108. //使用ref和reactive动态变量
  109. import { ref, reactive, onMounted } from 'vue'
  110. //使用官方ssr请求模块
  111. // import { useNuxtApp, useFetch } from '#app'
  112. //使用element-plus组件
  113. import { ElTabs, ElTabPane, ElTable, ElTableColumn, ElPagination } from 'element-plus';
  114. // axios请求
  115. const nuxtApp = useNuxtApp();
  116. const axios = nuxtApp.$axios;
  117. //1.引用模块 end ---------------------------------------->
  118. // 定义响应式数据
  119. const seoData = ref({
  120. title: '商圈',
  121. description: '默认描述',
  122. keywords: '默认关键词',
  123. image: 'https://example.com/default-image.jpg'
  124. });
  125. // 在 onMounted 钩子中获取数据
  126. onMounted(() => {
  127. seoData.value.title = '商圈';
  128. seoData.value.description = '默认描述';
  129. seoData.value.keywords = '默认关键词';
  130. })
  131. //2.页面数据 start ---------------------------------------->
  132. const activeName = useState("activeName", () => '')
  133. const listData = useState("listData", () => [])//商圈列表
  134. const typeList = useState("typeList", () => [])//商圈分类
  135. const statusList = useState("statusList", () => [])//商圈状态
  136. // 分页相关
  137. const currentPage = useState("currentPage", () => 0)
  138. const pageSize = useState("pageSize", () => 10)
  139. const page = useState("page", () => 1)
  140. //2.页面数据 end ---------------------------------------->
  141. //3.分页 start ---------------------------------------->
  142. const pageChage = (val) => {
  143. page.value = val
  144. getTopicsList()
  145. }
  146. //3.分页 start ---------------------------------------->
  147. //4.请求商圈列表 start ---------------------------------------->
  148. const getTopicsList = () => {
  149. console.log('activeName', activeName.value);
  150. let data = new FormData()
  151. data.append('page', page.value)
  152. data.append('page_size', pageSize.value)
  153. data.append('status', 2)
  154. data.append('type', activeName.value)
  155. axios.post('chat/getTopicsList', data).then(response => {
  156. console.log(8899)
  157. console.log("response", response);
  158. listData.value = response.data.data;
  159. currentPage.value = response.data.total;
  160. })
  161. }
  162. const getTopicsList1 = () => {
  163. console.log('activeName', activeName.value);
  164. let data = new FormData()
  165. data.append('page', page.value)
  166. data.append('page_size', pageSize.value)
  167. data.append('status', 2)
  168. // data.append('type', activeName.value)
  169. axios.post('chat/getTopicsList', data).then(response => {
  170. // console.log(response);
  171. listData.value = response.data.data;
  172. currentPage.value = response.data.total;
  173. })
  174. }
  175. onMounted(() => {
  176. getTopicsList1();
  177. })
  178. //4.请求商圈列表 end ---------------------------------------->
  179. //5.获取分类和状态 start ---------------------------------------->
  180. const topicType = () => {
  181. axios.post('/chat/topicType').then(response => {
  182. console.log(111222333)
  183. console.log(response.data);
  184. // console.log(1);
  185. typeList.value = response.data;
  186. })
  187. }
  188. const topicStatus = () => {
  189. axios.post('chat/topicStatus').then(response => {
  190. console.log(response);
  191. })
  192. }
  193. onMounted(() => {
  194. //分类
  195. topicType();
  196. //状态
  197. topicStatus();
  198. })
  199. //5.获取分类和状态 end ---------------------------------------->
  200. //自助建站 start---------------------------------------->
  201. //1.获得自助建站头部底部
  202. import templateHead from '@/components/template/sector/head/1200x200/1.vue'
  203. import templateHead5 from '@/components/template/sector/head/1200x250/1.vue'
  204. import templateMenu from '@/components/template/sector/menu/1200x130/1.vue'
  205. import templateMenu5 from '@/components/template/sector/menu/1200x187/1.vue'
  206. import templateFoot from '@/components/template/sector/foot/1200x580/1.vue'
  207. import templateFoot1 from '@/components/template/sector/foot/1200x680/1.vue'
  208. //2.获得pinia源
  209. import { useTemplateBaseStore } from '@/stores/templateBase'
  210. const templateBaseStore = useTemplateBaseStore()
  211. //3.获得该页的皮肤id
  212. const skinId = ref("")
  213. const websiteId = ref("")
  214. //4.获得站点基本信息
  215. const responseStatus = await requestDataPromise('/web/getWebsiteAllinfo', {
  216. method: 'GET',
  217. query: {
  218. 'link_textnum': 24,
  219. 'link_imgnum': 18,
  220. 'link_footnum': 4
  221. },
  222. });
  223. if (responseStatus.code == 200) {
  224. if (responseStatus.data.website_foot.foot_info.status == 1) {
  225. //网站模板已停用,直接转入404页面
  226. navigateTo('/error?findPage=index')
  227. } else {
  228. //4.1设置站点基本信息
  229. templateBaseStore.setWebSiteInfo(responseStatus.data)
  230. websiteId.value = responseStatus.data.website_head.id;
  231. //4.2设置皮肤id
  232. skinId.value = templateBaseStore.webSiteInfo.website_foot.foot_info.template_id;
  233. //4.3设置seo
  234. useSeoMeta({
  235. title: "商圈" + "_" + "三农资讯网_全国政务信息一体化应用平台",
  236. meta: [
  237. { name: 'description', content: "三农资讯网以服务于党和国家各级职能部门三农政务资讯发布及政务公开信息公示为基点,为全国县级以上各级党政机关及其职能部门配置各自公开独立网络发布平台。主要频道有:三农政务资讯,农科资讯,农资购销,农产购销,农贸资讯,三农致富信息,农村文化生活,三农政策法规,三农之窗,三农调查,三农服务,三农知识,农民工,打假维权等。三农资讯网打造最具影响力的三农信息发布平台,并成为最具权威的三农资讯网。_三农资讯网-测试专用_全国政务信息一体化应用平台", tagPriority: 10 },
  238. { name: 'keywords', content: "三农资讯,农业,三农,三农在线,农业新闻,三农资讯网_三农资讯网-测试专用_全国政务信息一体化应用平台", tagPriority: 10 }
  239. ]
  240. });
  241. }
  242. }
  243. //5.获得广告池
  244. const adData = ref([]);
  245. const adResponseStatus = await requestDataPromise('/web/getWebsiteAdvertisement', {
  246. method: 'GET',
  247. query: {},
  248. });
  249. if (adResponseStatus.code == 200) {
  250. templateBaseStore.setAdList(adResponseStatus.data)
  251. adData.value = adResponseStatus.data;
  252. }
  253. //6.是否使用了搜索页
  254. const response = await requestDataPromise('/client/indexData', {
  255. method: 'POST',
  256. body: {
  257. 'website_id': websiteId.value,
  258. 'getpage': 'article'
  259. },
  260. });
  261. if (response.code == 200) {
  262. //是否启用搜索功能
  263. templateBaseStore.setIsSearch(response.data.isSearch)
  264. }
  265. //自助建站 end---------------------------------------->
  266. </script>
  267. <style lang="less" scoped>
  268. .demo-tabs>.el-tabs__content {
  269. padding: 32px;
  270. color: #6b778c;
  271. font-size: 32px;
  272. font-weight: 600;
  273. }
  274. .topicBox {
  275. margin-bottom: 30px;
  276. .inner {
  277. width: 1200px;
  278. margin: 0 auto;
  279. :deep(.el-tabs__header) {
  280. width: 1200px;
  281. margin: 0 auto;
  282. }
  283. :deep(.el-tabs__item) {
  284. padding: 0 100px 0 20px;
  285. font-size: 16px;
  286. height: 60px;
  287. }
  288. :deep(.el-tabs__item.is-active),
  289. :deep(.el-tabs__item:hover) {
  290. color: #33b023;
  291. }
  292. :deep(.el-tabs__active-bar) {
  293. background-color: #33b023;
  294. height: 0;
  295. }
  296. :deep(.el-tabs__nav) {
  297. height: 60px;
  298. }
  299. .adEmpty {
  300. margin: 150px auto;
  301. text-align: center;
  302. img {
  303. width: 78px;
  304. height: 78px;
  305. vertical-align: -28px;
  306. margin-right: 10px;
  307. }
  308. span {
  309. font-family: Microsoft YaHei, Microsoft YaHei;
  310. font-weight: bold;
  311. font-size: 26px;
  312. color: #CCCCCC;
  313. line-height: 30px;
  314. text-align: center;
  315. font-style: normal;
  316. text-transform: none;
  317. }
  318. }
  319. }
  320. .topicList {
  321. margin-top: 30px;
  322. height: 200px;
  323. border: 1px solid #e7e7e7;
  324. .listHead {
  325. height: 60px;
  326. padding: 15px 24px 15px 50px;
  327. border-bottom: 1px solid #e7e7e7;
  328. box-sizing: border-box;
  329. background-color: #fafafa;
  330. .left {
  331. div {
  332. font-family: Microsoft YaHei, Microsoft YaHei;
  333. font-weight: 400;
  334. font-size: 16px;
  335. color: #FFAA33;
  336. background-color: #fbebd5;
  337. padding: 5px 17px;
  338. }
  339. .one {
  340. color: #FFAA33;
  341. background-color: #fbebd5;
  342. display: block;
  343. padding: 5px 17px;
  344. }
  345. .two {
  346. color: #33B023;
  347. background-color: #d5ecd2;
  348. }
  349. .three {
  350. color: #666;
  351. background-color: #ebebeb;
  352. }
  353. }
  354. .right {
  355. font-family: Microsoft YaHei, Microsoft YaHei;
  356. font-weight: bold;
  357. font-size: 16px;
  358. color: #333333;
  359. padding: 5px 0;
  360. }
  361. }
  362. .listFoot {
  363. margin: 30px 50px;
  364. .left {
  365. h2 {
  366. font-family: Microsoft YaHei, Microsoft YaHei;
  367. font-weight: bold;
  368. font-size: 20px;
  369. color: #333333;
  370. }
  371. p {
  372. margin-top: 30px;
  373. img {
  374. width: 24px;
  375. height: 24px;
  376. vertical-align: middle;
  377. margin-right: 10px;
  378. }
  379. span {
  380. margin-right: 40px;
  381. font-family: Microsoft YaHei, Microsoft YaHei;
  382. font-weight: 400;
  383. font-size: 16px;
  384. color: #333333;
  385. }
  386. }
  387. }
  388. .right {
  389. color: #139602;
  390. margin-top: 27px;
  391. img {
  392. width: 24px;
  393. height: 24px;
  394. vertical-align: middle;
  395. margin-right: 10px;
  396. }
  397. span {
  398. font-family: Microsoft YaHei, Microsoft YaHei;
  399. font-weight: 400;
  400. font-size: 16px;
  401. }
  402. }
  403. }
  404. }
  405. }
  406. //分页样式
  407. .paginationBox {
  408. display: flex;
  409. justify-content: center;
  410. margin-top: 60px;
  411. margin-bottom: 90px;
  412. // 鼠标移入后字体颜色
  413. :deep(.el-pagination:hover) {
  414. color: #139609;
  415. }
  416. :deep(.el-pagination.is-background .btn-next),
  417. :deep(.el-pagination.is-background .btn-prev) {
  418. width: 70px;
  419. height: 34px;
  420. margin: 0px 10px;
  421. border-radius: 4px;
  422. }
  423. :deep(.el-pagination.is-background .el-pager li) {
  424. margin: 0px 10px;
  425. width: 38px;
  426. height: 34px;
  427. border-radius: 4px;
  428. }
  429. :deep(.el-pagination.is-background .btn-next.is-active),
  430. :deep(.el-pagination.is-background .btn-prev.is-active),
  431. :deep(.el-pagination.is-background .el-pager li.is-active) {
  432. background-color: #028e21;
  433. color: #fff;
  434. }
  435. }
  436. </style>