index.vue 17 KB

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