list_sec.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  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=" ">&gt;</span>
  34. <NuxtLink :to="`/${parent_pinyin}/index.html`" v-if="parent_name !=''"> {{ parent_name }}</NuxtLink>
  35. <span class=" " v-if="parent_name !=''">&gt;</span>
  36. {{ name }}
  37. </div>
  38. <ul class="list">
  39. <li v-for="(item, index) in newsList" :key="index">
  40. <NuxtLink :href="`/${targetSegment1}/${targetSegment2}/${item.id}.html`" :title="item.alias">
  41. <span class="listTitle">{{ item.title }}</span>
  42. <span class="time phone_none">{{ 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
  63. pager-count="5"
  64. size="small"
  65. background
  66. layout=" pager "
  67. :total="total"
  68. class="mt-4"
  69. v-model:page-size="pageSize"
  70. :current-page="pageNum"
  71. @current-change="changePage" />
  72. </div>
  73. </div>
  74. <div class="innerRight">
  75. <DetailHotNews></DetailHotNews>
  76. <DetailHotNews2></DetailHotNews2>
  77. </div>
  78. </div>
  79. </div>
  80. <!-- 列表页广告二 -->
  81. <HomeTopTen :imgurl="adImg2" v-if="adImg2"></HomeTopTen>
  82. <!-- 页面底部 -->
  83. <HomeFoot1></HomeFoot1>
  84. </div>
  85. </template>
  86. <script setup>
  87. //1.页面必备依赖 start ---------------------------------------->
  88. import { ElBreadcrumb, ElBreadcrumbItem, ElPagination } from 'element-plus'
  89. import { ArrowRight } from '@element-plus/icons-vue'
  90. import { ref, onMounted } from 'vue';
  91. //1.页面必备依赖 end ---------------------------------------->
  92. //2.路径 start---------------------------------------->
  93. //当前列表名称
  94. const route = useRoute();
  95. let articleId = 0;//列表需要使用的导航id
  96. const targetSegment1 = getRoutePath(1);//根据路由反向查询导航id
  97. const targetSegment2 = getRoutePath(2);//根据路由反向查询导航id
  98. let pageNum = ref(1);//获得路由里面的分页数据
  99. //通过导航路径反向查询导航id
  100. const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
  101. method: 'GET',
  102. query: {
  103. 'pinyin':targetSegment1 + '/' + targetSegment2,
  104. },
  105. });
  106. if(getRouteId.code == 200){
  107. articleId = getRouteId.data.category_id
  108. }else{
  109. console.log("后端错误反馈:",getRouteId.message)
  110. }
  111. pageNum.value = parseInt(route.params.id);
  112. //2.路径 end---------------------------------------->
  113. //3.列表 start ---------------------------------------->
  114. let total = ref(1);
  115. let pageSize = ref(20);
  116. const newsList = ref([]);
  117. let newslists = async () => {
  118. const listData = await requestDataPromise('/web/getWebsiteCompanyList', {
  119. method: 'GET',
  120. query: {
  121. 'page': pageNum.value,
  122. 'pageSize': pageSize.value,
  123. 'category_id': articleId
  124. },
  125. });
  126. console.log("listData123111",listData);
  127. if (listData.code == 200) {
  128. newsList.value = listData.data.data;
  129. total.value = listData.data.count;
  130. } else {
  131. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  132. // console.log("错误位置:获取新闻列表")
  133. // console.log("后端错误反馈:", listData.message)
  134. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  135. }
  136. }
  137. newslists();
  138. //分页
  139. let changePage = (value) => {
  140. console.log("当前页码", value);
  141. navigateTo(`/${targetSegment2}/${value}.html`)
  142. }
  143. //3.列表 end ---------------------------------------->
  144. //4.面包屑 start---------------------------------------->
  145. //3.1 获得页面名称
  146. const name = ref('')
  147. let getPageName = async () => {
  148. const pageName = await requestDataPromise('/web/getOneWebsiteCategory', {
  149. method: 'GET',
  150. query: {
  151. 'catid': articleId
  152. },
  153. });
  154. if (pageName.code == 200) {
  155. name.value = pageName.data.alias
  156. } else {
  157. console.log("错误位置:设置页面标题")
  158. }
  159. }
  160. getPageName();
  161. //3.2 获得父级栏目
  162. const parent_name = ref([]);
  163. const parent_id = ref([]);
  164. const parent_pinyin = ref("");
  165. let getParentNav = async () => {
  166. const listData = await requestDataPromise('/web/getOneWebsiteCategory', {
  167. method: 'GET',
  168. query: {
  169. 'catid': articleId
  170. },
  171. });
  172. if (listData.code == 200) {
  173. console.log(111999)
  174. console.log(listData.data);
  175. parent_name.value = listData.data.parent_name;
  176. parent_id.value = listData.data.parent_id;
  177. parent_pinyin.value = listData.data.parent_pinyin;
  178. } else {
  179. console.log("错误位置:获取父级栏目")
  180. }
  181. getSecondNav();
  182. }
  183. getParentNav();
  184. // 3.3获取二级栏目
  185. const secondNav = ref([]);
  186. let getSecondNav = async () => {
  187. const listData = await requestDataPromise('/web/getWebsiteModelCategory', {
  188. method: 'GET',
  189. query: {
  190. 'placeid': 1,
  191. 'pid': parent_id.value,
  192. 'num': 20,
  193. },
  194. });
  195. console.log('listData', listData);
  196. if (listData.code == 200) {
  197. secondNav.value = listData.data;
  198. } else {
  199. console.log("错误位置:获取二级栏目列表")
  200. }
  201. }
  202. //4.面包屑 end ---------------------------------------->
  203. //5.设置seo信息 start---------------------------------------->
  204. const setData = await requestDataPromise('/web/getWebsiteCategoryHead', {
  205. method: 'GET',
  206. query: {
  207. 'catid': articleId
  208. },
  209. });
  210. if (setData.code == 200) {
  211. let seoTitle = setData.data.seo_title;
  212. let seoDescription = setData.data.seo_description;
  213. let seoKeywords = setData.data.seo_keywords;
  214. let seoSuffix = setData.data.suffix;
  215. let seoName = setData.data.website_name;
  216. useSeoMeta({
  217. title: seoTitle + "_" + seoName + "_" + seoSuffix,
  218. meta: [
  219. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix , tagPriority: 10 },
  220. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix , tagPriority: 10 },
  221. ,{ name: 'viewport', content: 'width=device-width,initial-scale=1,user-scalable=no',tagPriority: 10 }
  222. ]
  223. });
  224. } else {
  225. console.log("错误位置:设置列表页面SEO数据")
  226. }
  227. //5.设置seo信息 end---------------------------------------->
  228. //6.广告 start---------------------------------------->
  229. let adImg1 = ref({});
  230. let adImg2 = ref({});
  231. onMounted(async () => {
  232. //从客户端获取行政职能部门 加快打开速度
  233. const { $webUrl, $CwebUrl } = useNuxtApp();
  234. //广告1
  235. let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nfcpgxw_list_0001`
  236. const responseAd1 = await fetch(url, {
  237. headers: {
  238. 'Content-Type': 'application/json',
  239. 'Userurl': $CwebUrl,
  240. 'Origin': $CwebUrl
  241. }
  242. });
  243. const resultAd1 = await responseAd1.json();
  244. adImg1.value = resultAd1.data[0];
  245. //广告2
  246. let url2 = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nfcpgxw_list_0002`
  247. const responseAd2 = await fetch(url2, {
  248. headers: {
  249. 'Content-Type': 'application/json',
  250. 'Userurl': $CwebUrl,
  251. 'Origin': $CwebUrl
  252. }
  253. });
  254. const resultAd2 = await responseAd2.json();
  255. adImg2.value = resultAd2.data[0];
  256. })
  257. //6.广告 end---------------------------------------->
  258. </script>
  259. <style lang="less" scoped>
  260. @import url('@/assets/css/list.less');
  261. </style>
  262. <style lang="less" scoped>
  263. @media screen and (min-width:801px){/*pc*/
  264. .page_pc_none{display:none!important;}
  265. .pc_none{display:none;}
  266. }
  267. @media screen and (max-width:800px){/*ipad_phone*/
  268. .newsList .inner{width:92%;margin:0px auto 0px;}
  269. .newsList .inner .innerLeft{width:100%;float:none;}
  270. .newsList .inner .innerLeft{width:100%;float:none;margin:0px auto;}
  271. .newsList .inner .innerLeft .list li .time{display:none!important;}
  272. .newsList .inner .innerLeft .list li{display:block;width:100%;padding:14px 0!important;}
  273. .newsList .inner .innerLeft .list li .listTitle{font-size:16px;font-weight:normal!important;}
  274. .newsList .inner .innerLeft > .pagination{width:100%;}
  275. .newsList .inner .innerLeft > .pagination .el-pagination.is-background .el-pager li{margin:0px 4px;}
  276. .newsList .inner .innerLeft .list{margin-bottom:10px;border-top:solid 1px #004564;min-height:493px;}
  277. .breadcrumb_box{
  278. height:22px;width:100%;margin:10px auto;
  279. word-break: keep-all; white-space: nowrap;overflow:hidden;text-overflow:ellipsis;
  280. font-size:14px;
  281. color:#666;
  282. *{
  283. font-size:14px;
  284. display:inline ;
  285. color:#666;
  286. line-height:22px;height:22px;
  287. margin-right:5px;
  288. }
  289. }
  290. .newsList{margin-bottom:23px;}
  291. .page_phone_none{display:none!important;}
  292. .innerRight{display:none;}
  293. .phone_none{display:none;}
  294. }
  295. </style>