list_sec.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. <template>
  2. <div id="newsList">
  3. <!-- 页面头部 -->
  4. <HomePageHead></HomePageHead>
  5. <!-- 导航栏 -->
  6. <HomePageNavigation></HomePageNavigation>
  7. <!-- 列表页广告一 -->
  8. <HomeTopTen :imgurl="adImg1" v-if="adImg1"></HomeTopTen>
  9. <!-- 二级标题-->
  10. <HomeListSecondaryHeading v-if="parent_name != ''" :name="parent_name" :nav="secondNav" :pinyin="parent_pinyin"></HomeListSecondaryHeading>
  11. <!-- 资讯列表 -->
  12. <div class="newsList">
  13. <div class="inner">
  14. <div class="innerLeft">
  15. <!-- 面包屑导航 -->
  16. <div class="breadcrumb phone_none">
  17. <div class="inner">
  18. <span class="location">当前位置:</span>
  19. <el-breadcrumb :separator-icon="ArrowRight">
  20. <el-breadcrumb-item>
  21. <NuxtLink to="/">首页</NuxtLink>
  22. </el-breadcrumb-item>
  23. <el-breadcrumb-item v-if="parent_name !=''">
  24. <NuxtLink :to="`/${parent_pinyin}/index.html`"> {{ parent_name }}</NuxtLink>
  25. </el-breadcrumb-item>
  26. <el-breadcrumb-item>{{ name }}</el-breadcrumb-item>
  27. </el-breadcrumb>
  28. </div>
  29. </div>
  30. <div class="breadcrumb_box pc_none">
  31. <span class=" ">当前位置:</span>
  32. <NuxtLink to="/">首页</NuxtLink>
  33. <span class=" " v-if="parent_name !=''">&gt;</span>
  34. <NuxtLink v-if="parent_name !=''" :to="`/${parent_pinyin}/index.html`"> {{ parent_name }}</NuxtLink>
  35. <span class="" >&gt;</span>
  36. {{ name }}
  37. </div>
  38. <ul class="list">
  39. <li v-for="(item, index) in newsList" :key="index">
  40. <NuxtLink :href="`/${targetSegment1}/${targetSegment}/${item.id}.html`" :title="item.alias">
  41. <span class="listTitle">{{ item.title }}</span>
  42. <span class="time">{{ getTime(item.updated_at, 'month', 1) }}</span>
  43. </NuxtLink>
  44. </li>
  45. </ul>
  46. <!-- 分页器 -->
  47. <div class="pagination page_phone_none" v-if="total > 0">
  48. <el-pagination
  49. size="small"
  50. background
  51. layout="prev, pager, next"
  52. :total="total"
  53. class="mt-4"
  54. :page-size="pageSize"
  55. :current-page="pageNum"
  56. prev-text="上一页"
  57. next-text="下一页"
  58. @current-change="changePage"
  59. />
  60. </div>
  61. <div class="pagination page_pc_none" v-if="total > 0">
  62. <el-pagination pager-count="5" size="small" background layout=" pager " :total="total"
  63. class="mt-4" v-model:page-size="pageSize" :current-page="pageNum"
  64. @current-change="changePage" />
  65. </div>
  66. </div>
  67. <div class="innerRight">
  68. <DetailHotNews></DetailHotNews>
  69. <DetailHotNews2></DetailHotNews2>
  70. </div>
  71. </div>
  72. </div>
  73. <!-- 列表页广告二 -->
  74. <HomeTopTen :imgurl="adImg2" v-if="adImg2"></HomeTopTen>
  75. <!-- 页面底部 -->
  76. <HomeFoot1></HomeFoot1>
  77. </div>
  78. </template>
  79. <script setup>
  80. //1.页面必备依赖 start ---------------------------------------->
  81. import { ElBreadcrumb, ElBreadcrumbItem, ElPagination } from 'element-plus'
  82. import { ArrowRight } from '@element-plus/icons-vue'
  83. import { ref, onMounted } from 'vue';
  84. //1.页面必备依赖 end ---------------------------------------->
  85. //2.路径 start---------------------------------------->
  86. //当前列表名称
  87. const route = useRoute();
  88. let articleId = 0;//列表需要使用的导航id
  89. let routeType;
  90. const targetSegment = getRoutePath(2);
  91. const targetSegment1 = getRoutePath(1);//根据路由反向查询导航id
  92. const allSegment = targetSegment1 + '/' + targetSegment;
  93. let pageNum = ref(1);//获得路由里面的分页数据
  94. //通过导航路径反向查询导航id
  95. const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
  96. method: 'GET',
  97. query: {
  98. 'pinyin': allSegment,
  99. },
  100. });
  101. if(getRouteId.code == 200){
  102. articleId = getRouteId.data.category_id
  103. routeType = getRouteId.data.type
  104. }else{
  105. console.log("后端错误反馈:",getRouteId.message)
  106. }
  107. pageNum.value = parseInt(route.params.id);
  108. //2.路径 end---------------------------------------->
  109. //3.列表 start ---------------------------------------->
  110. let total = ref(1);
  111. let pageSize = ref(20);
  112. const newsList = ref([]);
  113. let companyList = async () => {
  114. const listData = await requestDataPromise('/web/getWebsiteCompanyList', {
  115. method: 'GET',
  116. query: {
  117. 'page': pageNum.value,
  118. 'pageSize': pageSize.value,
  119. 'category_id': articleId
  120. },
  121. });
  122. console.log("listData123111",listData);
  123. if (listData.code == 200) {
  124. newsList.value = listData.data.data;
  125. total.value = listData.data.count;
  126. } else {
  127. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  128. console.log("错误位置:获取新闻列表")
  129. console.log("后端错误反馈:", listData.message)
  130. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  131. }
  132. }
  133. let newslists = async () => {
  134. const listData = await requestDataPromise('/web/getWebsiteArticleList', {
  135. method: 'GET',
  136. query: {
  137. 'page': pageNum.value,
  138. 'pageSize': pageSize.value,
  139. 'catid': articleId
  140. },
  141. });
  142. if (listData.code == 200) {
  143. newsList.value = listData.data.rows;
  144. total.value = listData.data.count;
  145. } else {
  146. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  147. // console.log("错误位置:获取新闻列表")
  148. // console.log("后端错误反馈:", listData.message)
  149. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  150. }
  151. }
  152. if(routeType == 1){
  153. newslists();
  154. }else if(routeType == 6){
  155. companyList();
  156. }
  157. //分页
  158. let changePage = (value) => {
  159. console.log("当前页码", value);
  160. navigateTo(`/${targetSegment}/${value}.html`)
  161. }
  162. //3.列表 end ---------------------------------------->
  163. //4.面包屑 start---------------------------------------->
  164. //3.1 获得页面名称
  165. const name = ref('')
  166. let getPageName = async () => {
  167. const pageName = await requestDataPromise('/web/getOneWebsiteCategory', {
  168. method: 'GET',
  169. query: {
  170. 'catid': articleId
  171. },
  172. });
  173. if (pageName.code == 200) {
  174. name.value = pageName.data.alias
  175. } else {
  176. console.log("错误位置:设置页面标题")
  177. }
  178. }
  179. getPageName();
  180. //3.2 获得父级栏目
  181. const parent_name = ref([]);
  182. const parent_id = ref([]);
  183. const parent_pinyin = ref("");
  184. let getParentNav = async () => {
  185. const listData = await requestDataPromise('/web/getOneWebsiteCategory', {
  186. method: 'GET',
  187. query: {
  188. 'catid': articleId
  189. },
  190. });
  191. if (listData.code == 200) {
  192. console.log(111999)
  193. console.log(listData.data);
  194. parent_name.value = listData.data.parent_name;
  195. parent_id.value = listData.data.parent_id;
  196. parent_pinyin.value = listData.data.parent_pinyin;
  197. } else {
  198. console.log("错误位置:获取父级栏目")
  199. }
  200. getSecondNav();
  201. }
  202. getParentNav();
  203. // 3.3获取二级栏目
  204. const secondNav = ref([]);
  205. let getSecondNav = async () => {
  206. const listData = await requestDataPromise('/web/getWebsiteModelCategory', {
  207. method: 'GET',
  208. query: {
  209. 'placeid': 1,
  210. 'pid': parent_id.value,
  211. 'num': 20,
  212. },
  213. });
  214. console.log('listData', listData);
  215. if (listData.code == 200) {
  216. secondNav.value = listData.data;
  217. } else {
  218. console.log("错误位置:获取二级栏目列表")
  219. }
  220. }
  221. //4.面包屑 end ---------------------------------------->
  222. //5.设置seo信息 start---------------------------------------->
  223. const setData = await requestDataPromise('/web/getWebsiteCategoryHead', {
  224. method: 'GET',
  225. query: {
  226. 'catid': articleId
  227. },
  228. });
  229. if (setData.code == 200) {
  230. let seoTitle = setData.data.seo_title;
  231. let seoDescription = setData.data.seo_description;
  232. let seoKeywords = setData.data.seo_keywords;
  233. let seoSuffix = setData.data.suffix;
  234. let seoName = setData.data.website_name;
  235. useSeoMeta({
  236. title: seoTitle + "_" + seoName + "_" + seoSuffix,
  237. meta: [
  238. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix , tagPriority: 10 },
  239. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix , tagPriority: 10 },
  240. { name: 'viewport', content: 'width=device-width,initial-scale=1,user-scalable=no',tagPriority: 10 }
  241. ]
  242. });
  243. } else {
  244. console.log("错误位置:设置列表页面SEO数据")
  245. }
  246. //5.设置seo信息 end---------------------------------------->
  247. //6.广告 start---------------------------------------->
  248. let adImg1 = ref({});
  249. let adImg2 = ref({});
  250. onMounted(async () => {
  251. //从客户端获取行政职能部门 加快打开速度
  252. const { $webUrl, $CwebUrl } = useNuxtApp();
  253. //广告1
  254. let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nzgxw_list_0001`
  255. const responseAd1 = await fetch(url, {
  256. headers: {
  257. 'Content-Type': 'application/json',
  258. 'Userurl': $CwebUrl,
  259. 'Origin': $CwebUrl
  260. }
  261. });
  262. const resultAd1 = await responseAd1.json();
  263. adImg1.value = resultAd1.data[0];
  264. //广告2
  265. let url2 = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nzgxw_list_0002`
  266. const responseAd2 = await fetch(url2, {
  267. headers: {
  268. 'Content-Type': 'application/json',
  269. 'Userurl': $CwebUrl,
  270. 'Origin': $CwebUrl
  271. }
  272. });
  273. const resultAd2 = await responseAd2.json();
  274. adImg2.value = resultAd2.data[0];
  275. })
  276. //6.广告 end---------------------------------------->
  277. </script>
  278. <style lang="less" scoped>
  279. @import url('@/assets/css/list.less');
  280. </style>
  281. <style lang="less" scoped>
  282. @media screen and (min-width:801px) {
  283. /*pc*/
  284. .page_pc_none {
  285. display: none !important;
  286. }
  287. .pc_none {
  288. display: none;
  289. }
  290. }
  291. @media screen and (max-width:800px) {
  292. /*ipad_phone*/
  293. .newsList .inner {
  294. width: 92%;
  295. margin: 0px auto 0px;
  296. }
  297. .newsList .inner .innerLeft {
  298. width: 100%;
  299. float: none;
  300. }
  301. .newsList .inner .innerLeft {
  302. width: 100%;
  303. float: none;
  304. margin: 0px auto;
  305. }
  306. .newsList .inner .innerLeft .list li .time {
  307. display: none !important;
  308. }
  309. .newsList .inner .innerLeft .list li {
  310. display: block;
  311. width: 100%;
  312. padding: 14px 0 !important;
  313. }
  314. .newsList .inner .innerLeft .list li .listTitle {
  315. font-size: 16px;
  316. font-weight: normal !important;
  317. }
  318. .newsList .inner .innerLeft>.pagination {
  319. width: 100%;
  320. }
  321. .newsList .inner .innerLeft>.pagination .el-pagination.is-background .el-pager li {
  322. margin: 0px 4px;
  323. }
  324. .newsList .inner .innerLeft .list {
  325. margin-bottom: 10px;
  326. border-top: solid 1px #a91b33;
  327. min-height:493px;
  328. }
  329. .breadcrumb_box {
  330. height: 22px;
  331. width: 100%;
  332. margin: 10px auto;
  333. word-break: keep-all;
  334. white-space: nowrap;
  335. overflow: hidden;
  336. text-overflow: ellipsis;
  337. font-size: 14px;
  338. color: #666;
  339. * {
  340. font-size: 14px;
  341. display: inline;
  342. color: #666;
  343. line-height: 22px;
  344. height: 22px;
  345. margin-right: 5px;
  346. }
  347. }
  348. .newsList .inner .innerLeft>.pagination::v-deep(.el-pagination.is-background .el-pager li) {
  349. margin: 0px 4px;
  350. }
  351. .newsList {
  352. margin-bottom: 23px;
  353. }
  354. .page_phone_none {
  355. display: none !important;
  356. }
  357. .innerRight {
  358. display: none;
  359. }
  360. .phone_none {
  361. display: none;
  362. }
  363. }
  364. </style>