detail_sec.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. <template>
  2. <!-- 页面头部 -->
  3. <HomePageHead></HomePageHead>
  4. <!-- 导航栏 -->
  5. <HomePageNavigation></HomePageNavigation>
  6. <!-- 列表页广告一 -->
  7. <HomeTopTen :imgurl="adImg1" v-if="adImg1"></HomeTopTen>
  8. <!-- 资讯列表 -->
  9. <div class="newsDetail">
  10. <div class="inner">
  11. <div class="innerLeft">
  12. <!-- 面包屑导航 -->
  13. <div class="breadcrumb breadcrumb_phone_none">
  14. <div class="inner">
  15. <span class="location">当前位置:</span>
  16. <el-breadcrumb :separator-icon="ArrowRight">
  17. <el-breadcrumb-item>
  18. <NuxtLink to="/">首页</NuxtLink>
  19. </el-breadcrumb-item>
  20. <el-breadcrumb-item v-if="parent_name != ''">
  21. <NuxtLink :to="`/${parent_pinyin}/index.html`"> {{ parent_name }}</NuxtLink>
  22. </el-breadcrumb-item>
  23. <el-breadcrumb-item>
  24. <NuxtLink :to="`list-1.html`"> {{ routLevelTitle }}</NuxtLink>
  25. </el-breadcrumb-item>
  26. <el-breadcrumb-item>{{ routeNewsTtitle }}</el-breadcrumb-item>
  27. </el-breadcrumb>
  28. </div>
  29. </div>
  30. <div class="breadcrumb_box breadcrumb_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. <NuxtLink :to="`list-1.html`"> {{ routLevelTitle }}</NuxtLink>
  37. <span class=" " >&gt;</span>
  38. <span class=" ">
  39. {{ routeNewsTtitle }}
  40. </span>
  41. </div>
  42. <div class="LeftTop">
  43. <h1>{{ newsDetail.title }}</h1>
  44. <p class="phone_none">
  45. 来源: <span>{{ newsDetail.copyfrom }}</span>
  46. 作者: <span>{{ newsDetail.author }}</span>
  47. 发布时间: <span>{{ time }}</span>
  48. </p>
  49. <p class="pc_none">
  50. <span>{{ newsDetail.copyfrom }}</span>
  51. <span>{{ newsDetail.author }}</span>
  52. <span>{{ time }}</span>
  53. </p>
  54. </div>
  55. <div class="leftBottom" v-html="newsDetail.content" v-if="newsDetail.content" @click="openPreview">
  56. </div>
  57. <div v-if="previewVisible" class="preview-modal" @click="closePreview">
  58. <img :src="selectedImage" alt="Preview">
  59. </div>
  60. <!-- 免责声明: -->
  61. <div class="disclaimer" v-if="newsDetail.copyfrom != '本网'">
  62. <p>原文链接:{{ newsDetail.fromurl }}</p>
  63. <p>[免责声明]本文来源于网络转载,仅供学习交流使用,不构成商业目的。 版权归原作者所有,如涉及作品内容,版权和其他问题,请在30日与本网联系,我们将第一时间处理。</p>
  64. </div>
  65. <div v-if="articleChoice">
  66. <HomeSurveyvote></HomeSurveyvote>
  67. </div>
  68. <!-- 推荐阅读 -->
  69. <div class="recommendRead" v-if="newsDetail.commendArticle != false">
  70. <div class="recommendReadTitle phone_none">
  71. 推荐阅读
  72. </div>
  73. <div class="phone_box_1_head pc_none">
  74. <a class="" title="">推荐阅读</a>
  75. </div>
  76. <div class="recommendReadList">
  77. <div class="recommendReadListTitle" v-for="(item, index) in newsDetail.commendArticle"
  78. :key="item.id">
  79. <a :href="`/${item.alias_pinyin}/${item.id}.html`" v-if="index < 3">
  80. {{ item.title }}
  81. </a>
  82. <span v-if="index < 3">{{ getTime(item.created_at,"month",1) }}</span>
  83. </div>
  84. </div>
  85. </div>
  86. </div>
  87. <div class="innerRight">
  88. <!-- 热点资讯1 -->
  89. <div class="hotList1">
  90. <DetailHotNews></DetailHotNews>
  91. </div>
  92. <!-- 热点资讯2 -->
  93. <div class="hotList2">
  94. <DetailHotNews2></DetailHotNews2>
  95. </div>
  96. </div>
  97. </div>
  98. </div>
  99. <!-- 列表页广告二 -->
  100. <HomeTopTen :imgurl="adImg2" v-if="adImg2"></HomeTopTen>
  101. <!-- 页面底部 -->
  102. <HomeFoot1></HomeFoot1>
  103. </template>
  104. <script setup>
  105. //1.页面依赖 start ---------------------------------------->
  106. import { onMounted } from 'vue'
  107. import { ElBreadcrumb, ElBreadcrumbItem, ElRadio, ElRadioGroup, ElCheckbox, ElCheckboxGroup, ElMessage, ElInput } from 'element-plus'
  108. import { ArrowRight } from '@element-plus/icons-vue'
  109. //1.页面依赖 end ---------------------------------------->
  110. //2.页面路径 start ---------------------------------------->
  111. const route = useRoute();
  112. const articleId = parseInt(route.params.id);
  113. const targetSegment = getRoutePath(1);
  114. let routeId;
  115. //通过导航路径反向查询导航id
  116. const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
  117. method: 'GET',
  118. query: {
  119. 'pinyin': targetSegment,
  120. },
  121. });
  122. if (getRouteId.code == 200) {
  123. routeId = getRouteId.data.category_id
  124. } else {
  125. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  126. console.log("错误位置:通过url路径查询导航池id")
  127. console.log("后端错误反馈:", getRouteId.message)
  128. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  129. }
  130. //2.页面路径 end ---------------------------------------->
  131. //3.面包屑 start ---------------------------------------->
  132. const parent_name = ref("");
  133. const parent_id = ref("");
  134. const parent_pinyin = ref("");
  135. let getParentNav = async () => {
  136. const listData = await requestDataPromise('/web/getOneWebsiteCategory', {
  137. method: 'GET',
  138. query: {
  139. 'catid': routeId
  140. },
  141. });
  142. if (listData.code == 200) {
  143. parent_name.value = listData.data.alias;
  144. parent_id.value = listData.data.parent_id;
  145. parent_pinyin.value = listData.data.aLIas_pinyin;
  146. } else {
  147. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  148. console.log("错误位置:获取面包屑导航")
  149. console.log("后端错误反馈:", listData.message)
  150. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  151. }
  152. }
  153. //获得父级栏目详情
  154. getParentNav();
  155. //3.面包屑 end ---------------------------------------->
  156. //4.新闻详情 start ---------------------------------------->
  157. //4.1 资讯详情
  158. const newsDetail = ref({})
  159. const routeNewsTtitle = ref("");
  160. //4.2 发布日期
  161. const time = ref("");
  162. //4.3 路径
  163. const routLevelTitle = ref("");
  164. const routLevelId = ref("");
  165. //4.4 是否展示投票
  166. const articleChoice = ref(false);
  167. //4.5 获取详情
  168. async function getPageData() {
  169. const mkdata = await requestDataPromise('/web/selectWebsiteArticleInfo', {
  170. method: 'GET',
  171. query: {
  172. 'articleid': articleId
  173. },
  174. });
  175. if (mkdata.code == 200) {
  176. //判断是否显示投票
  177. if (mkdata.data.is_survey == 1) {
  178. console.log("本篇文章含有投票!")
  179. articleChoice.value = true;
  180. }
  181. //获取内容
  182. newsDetail.value = mkdata.data;
  183. //获取路径
  184. routLevelTitle.value = newsDetail.value.cat_name;
  185. routLevelId.value = newsDetail.value.category_id;
  186. //获取发布时间
  187. time.value = newsDetail.value.updated_at.split(' ')[0];
  188. //修正标题长度
  189. if (newsDetail.value.title.length >= 20) {
  190. routeNewsTtitle.value = newsDetail.value.title.substr(0, 20) + "...";
  191. } else {
  192. routeNewsTtitle.value = newsDetail.value.title
  193. }
  194. } else {
  195. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  196. // console.log("错误位置:获取详情内容")
  197. // console.log("后端错误反馈:", mkdata.message)
  198. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  199. }
  200. }
  201. getPageData();
  202. //4.新闻详情 end ---------------------------------------->
  203. //5.广告 start ---------------------------------------->
  204. let adImg1 = ref([]);
  205. let adImg2 = ref([]);
  206. onMounted(async () => {
  207. const { $webUrl, $CwebUrl } = useNuxtApp();
  208. //广告1
  209. let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nfcpgxw_detail_0001`
  210. const responseAd1 = await fetch(url, {
  211. headers: {
  212. 'Content-Type': 'application/json',
  213. 'Userurl': $CwebUrl,
  214. 'Origin': $CwebUrl
  215. }
  216. });
  217. const resultAd1 = await responseAd1.json();
  218. adImg1.value = resultAd1.data[0];
  219. //广告2
  220. let url2 = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nfcpgxw_detail_0002`
  221. const responseAd2 = await fetch(url2, {
  222. headers: {
  223. 'Content-Type': 'application/json',
  224. 'Userurl': $CwebUrl,
  225. 'Origin': $CwebUrl
  226. }
  227. });
  228. const resultAd2 = await responseAd2.json();
  229. adImg2.value = resultAd2.data[0];
  230. })
  231. //5.广告 end ---------------------------------------->
  232. //6.设置seo信息 start---------------------------------------->
  233. const setData = await requestDataPromise('/web/selectWebsiteArticleInfo', {
  234. method: 'GET',
  235. query: {
  236. 'articleid': articleId
  237. },
  238. });
  239. if (setData.code == 200) {
  240. let seoTitle = setData.data.title;
  241. let seoDescription = setData.data.introduce;
  242. let seoKeywords = setData.data.keyword;
  243. let seoSuffix = setData.data.suffix;
  244. let seoName = setData.data.website_name;
  245. useSeoMeta({
  246. title: seoTitle + "_" + seoName + "_" + seoSuffix,
  247. meta: [
  248. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  249. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  250. { name: 'viewport', content: 'width=device-width,initial-scale=1,user-scalable=no',tagPriority: 10 }
  251. ]
  252. });
  253. } else {
  254. console.log("获取广告数据失败!", setData.message)
  255. }
  256. //6.设置seo信息 end---------------------------------------->
  257. //8.页面图片放大 start---------------------------------------->
  258. const previewVisible = ref(false)
  259. const selectedImage = ref(' ')
  260. const openPreview = (event) => {
  261. if (event.target.tagName === 'IMG') {
  262. selectedImage.value = event.target.src;
  263. previewVisible.value = true;
  264. }
  265. }
  266. const closePreview = () => {
  267. previewVisible.value = false;
  268. }
  269. //8.页面图片放大 end---------------------------------------->
  270. </script>
  271. <style lang="less" scoped>
  272. @import url('@/assets/css/detail.less');
  273. </style>
  274. <style lang="less" scoped>
  275. @media screen and (min-width:801px){/*pc*/
  276. .breadcrumb_pc_none{display:none!important;}
  277. .pc_none{display:none;}
  278. }
  279. @media screen and (max-width:800px){/*ipad_phone*/
  280. .index_3_box_vote{overflow:hidden;margin-top:39px;}
  281. .index_3_box_vote .inquire{margin-top:15px;height:auto;}
  282. .index_3_box_vote .inquire p{height:auto;padding:0;font-size:14px;
  283. margin:0px 0px 5px 18px;}
  284. .index_3_box_vote .inquire .radio .el-radio.el-radio--large .el-radio__label span{font-size:14px;}
  285. .index_3_box_vote .voteTitle{font-size:14px;}
  286. .index_3_box_vote .inquire .btn{padding-left:22px;}
  287. .index_3_box_vote .inquire .radio .el-radio.el-radio--large{margin-bottom:3px;}
  288. .index_3_box_vote .inquire .radioBox{height:auto;
  289. padding:0px 0px 12px 18px;}
  290. .index_3_box_vote .inquire .radio .el-radio-group{width:100%;}
  291. .index_3_box_vote .inquire .btn button{width:auto;padding:0px 10px;line-height:33px;height:33px;font-size:14px;margin-bottom:14px;}
  292. .newsDetail .inner{width:92%;}
  293. .newsDetail .inner .innerLeft{width:100%;margin:0;float:none; }
  294. .newsDetail .inner .innerLeft .LeftTop{margin-top:9px;border-top:solid 1px #004564;}
  295. .newsDetail .inner .innerLeft .LeftTop > h1{font-size:20px;line-height:28px;margin:15px auto 15px;}
  296. .newsDetail .inner .innerLeft .leftBottom{width:100%;margin-top:20px;}
  297. .newsDetail .inner .innerLeft .leftBottom *,
  298. .newsDetail .inner .innerLeft .leftBottom{ font-size:16px!important;line-height:24px!important;}
  299. .newsDetail .inner .innerLeft .leftBottom /deep/img{max-width:100%;height:auto; }
  300. .newsDetail .inner .innerLeft .LeftTop > p{height:auto;}
  301. .breadcrumb_box{
  302. height:22px;width:100%;margin:16px auto 9px;
  303. word-break: keep-all; white-space: nowrap;overflow:hidden;text-overflow:ellipsis;
  304. font-size:14px;
  305. color:#666;
  306. *{
  307. font-size:14px;
  308. display:inline ;
  309. color:#666;
  310. line-height:22px;height:22px;
  311. margin-right:5px;
  312. }
  313. }
  314. .newsDetail .inner .innerLeft .disclaimer{width:100%; }
  315. .newsDetail .inner .innerLeft .disclaimer *{word-wrap: break-word;width:100%!important;display:block!important;
  316. overflow-wrap: break-word;font-size:16px;
  317. white-space: pre-wrap;
  318. word-break: break-all;
  319. }
  320. // 推荐阅读
  321. .phone_box_1_head{
  322. height:33px;line-height:33px;background:#fff;border-bottom:1px solid #004564;
  323. margin-top:15px;width:100%;
  324. a{
  325. float:left;height:33px;line-height:33px;margin:0;position:relative;
  326. color:#004564;font-size:14px; font-weight:bold;box-sizing:border-box;
  327. }
  328. }
  329. .newsDetail .inner .innerLeft .recommendRead .recommendReadList{
  330. height:auto;margin-top:11px; min-height:auto;padding-bottom:8px;
  331. }
  332. .newsDetail .inner .innerLeft .recommendRead .recommendReadList .recommendReadListTitle{
  333. margin-top:0px;overflow:hidden;width:100%;
  334. }
  335. .newsDetail .inner .innerLeft .recommendRead .recommendReadList .recommendReadListTitle a{
  336. line-height:33px;height:33px;font-size:14px;float:left;max-width:90%;font-weight:normal;
  337. word-break: keep-all; white-space: nowrap;overflow:hidden;text-overflow:ellipsis;
  338. }
  339. .newsDetail .inner .innerLeft .LeftTop > p span:nth-last-of-type(1){margin-right:0px;}
  340. .newsDetail .inner .innerLeft .recommendRead .recommendReadList .recommendReadListTitle span{display:none;}
  341. .newsDetail .inner .innerRight{display:none;}
  342. .breadcrumb_phone_none{display:none!important;}
  343. .phone_none{display:none;}
  344. }
  345. </style>