detail.vue 15 KB

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