index.vue 17 KB

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