detail_sec.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <div class="newsDetail">
  3. <div class="inner">
  4. <div class="innerLeft">
  5. <!-- 面包屑导航 -->
  6. <div class="breadcrumb">
  7. <div class="inner">
  8. <span class="location">当前位置:</span>
  9. <el-breadcrumb :separator-icon="ArrowRight">
  10. <el-breadcrumb-item>
  11. <NuxtLink to="/">首页</NuxtLink>
  12. </el-breadcrumb-item>
  13. <el-breadcrumb-item v-if="parent_name != ''">
  14. <NuxtLink :to="`/${parent_pinyin}/index.html`"> {{ parent_name }}</NuxtLink>
  15. </el-breadcrumb-item>
  16. <el-breadcrumb-item>
  17. <NuxtLink :to="`list-1.html`"> {{ routLevelTitle }}</NuxtLink>
  18. </el-breadcrumb-item>
  19. <el-breadcrumb-item>{{ routeNewsTtitle }}</el-breadcrumb-item>
  20. </el-breadcrumb>
  21. </div>
  22. </div>
  23. <div class="LeftTop">
  24. <h1>{{ newsDetail.title }}</h1>
  25. <p>
  26. 来源: <span>{{ newsDetail.copyfrom }}</span>
  27. 作者: <span>{{ newsDetail.author }}</span>
  28. 发布时间: <span>{{ time }}</span>
  29. </p>
  30. </div>
  31. <div class="leftBottom" v-html="newsDetail.content" v-if="newsDetail.content" @click="openPreview">
  32. </div>
  33. <div v-if="previewVisible" class="preview-modal" @click="closePreview">
  34. <img :src="selectedImage" alt="Preview">
  35. </div>
  36. <!-- 免责声明: -->
  37. <div class="disclaimer" v-if="newsDetail.copyfrom != '本网'">
  38. <p>原文链接:{{ newsDetail.fromurl }}</p>
  39. <p>[免责声明]本文来源于网络转载,仅供学习交流使用,不构成商业目的。 版权归原作者所有,如涉及作品内容,版权和其他问题,请在30日与本网联系,我们将第一时间处理。</p>
  40. </div>
  41. <div v-if="articleChoice">
  42. <HomeSurveyvote></HomeSurveyvote>
  43. </div>
  44. </div>
  45. <div class="innerRight">
  46. <!-- 热点资讯1 -->
  47. <div class="hotList1">
  48. <DetailHotNews></DetailHotNews>
  49. </div>
  50. <!-- 热点资讯2 -->
  51. <div class="hotList2">
  52. <DetailHotNews2></DetailHotNews2>
  53. </div>
  54. </div>
  55. </div>
  56. </div>
  57. </template>
  58. <script setup>
  59. //1.页面依赖 start ---------------------------------------->
  60. import { onMounted } from 'vue'
  61. import { ElBreadcrumb, ElBreadcrumbItem, ElRadio, ElRadioGroup, ElCheckbox, ElCheckboxGroup, ElMessage, ElInput } from 'element-plus'
  62. import { ArrowRight } from '@element-plus/icons-vue'
  63. //1.页面依赖 end ---------------------------------------->
  64. //2.页面路径 start ---------------------------------------->
  65. const route = useRoute();
  66. const articleId = parseInt(route.params.id);
  67. const targetSegment = getRoutePath(1);
  68. let routeId;
  69. //通过导航路径反向查询导航id
  70. const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
  71. method: 'GET',
  72. query: {
  73. 'pinyin': targetSegment,
  74. },
  75. });
  76. if (getRouteId.code == 200) {
  77. routeId = getRouteId.data.category_id
  78. } else {
  79. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  80. console.log("错误位置:通过url路径查询导航池id")
  81. console.log("后端错误反馈:", getRouteId.message)
  82. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  83. }
  84. //2.页面路径 end ---------------------------------------->
  85. //3.面包屑 start ---------------------------------------->
  86. const parent_name = ref("");
  87. const parent_id = ref("");
  88. const parent_pinyin = ref("");
  89. let getParentNav = async () => {
  90. const listData = await requestDataPromise('/web/getOneWebsiteCategory', {
  91. method: 'GET',
  92. query: {
  93. 'catid': routeId
  94. },
  95. });
  96. if (listData.code == 200) {
  97. parent_name.value = listData.data.alias;
  98. parent_id.value = listData.data.parent_id;
  99. parent_pinyin.value = listData.data.aLIas_pinyin;
  100. } else {
  101. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  102. console.log("错误位置:获取面包屑导航")
  103. console.log("后端错误反馈:", listData.message)
  104. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  105. }
  106. }
  107. //获得父级栏目详情
  108. getParentNav();
  109. //3.面包屑 end ---------------------------------------->
  110. //4.新闻详情 start ---------------------------------------->
  111. //4.1 资讯详情
  112. const newsDetail = ref({})
  113. const routeNewsTtitle = ref("");
  114. //4.2 发布日期
  115. const time = ref("");
  116. //4.3 路径
  117. const routLevelTitle = ref("");
  118. const routLevelId = ref("");
  119. //4.4 是否展示投票
  120. const articleChoice = ref(false);
  121. //4.5 获取详情
  122. async function getPageData() {
  123. const mkdata = await requestDataPromise('/web/selectWebsiteArticleInfo', {
  124. method: 'GET',
  125. query: {
  126. 'articleid': articleId
  127. },
  128. });
  129. if (mkdata.code == 200) {
  130. //判断是否显示投票
  131. if (mkdata.data.is_survey == 1) {
  132. console.log("本篇文章含有投票!")
  133. articleChoice.value = true;
  134. }
  135. //获取内容
  136. newsDetail.value = mkdata.data;
  137. //获取路径
  138. routLevelTitle.value = newsDetail.value.cat_name;
  139. routLevelId.value = newsDetail.value.category_id;
  140. //获取发布时间
  141. time.value = newsDetail.value.updated_at.split(' ')[0];
  142. //修正标题长度
  143. if (newsDetail.value.title.length >= 20) {
  144. routeNewsTtitle.value = newsDetail.value.title.substr(0, 20) + "...";
  145. } else {
  146. routeNewsTtitle.value = newsDetail.value.title
  147. }
  148. } else {
  149. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  150. console.log("错误位置:获取详情内容")
  151. console.log("后端错误反馈:", mkdata.message)
  152. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  153. }
  154. }
  155. getPageData();
  156. //4.新闻详情 end ---------------------------------------->
  157. //5.广告 start ---------------------------------------->
  158. let adImg1 = ref([]);
  159. let adImg2 = ref([]);
  160. onMounted(async () => {
  161. const { $webUrl, $CwebUrl } = useNuxtApp();
  162. //广告1
  163. let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=snscw_detail_0001`
  164. const responseAd1 = await fetch(url, {
  165. headers: {
  166. 'Content-Type': 'application/json',
  167. 'Userurl': $CwebUrl,
  168. 'Origin': $CwebUrl
  169. }
  170. });
  171. const resultAd1 = await responseAd1.json();
  172. adImg1.value = resultAd1.data[0];
  173. //广告2
  174. let url2 = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=snscw_detail_0002`
  175. const responseAd2 = await fetch(url2, {
  176. headers: {
  177. 'Content-Type': 'application/json',
  178. 'Userurl': $CwebUrl,
  179. 'Origin': $CwebUrl
  180. }
  181. });
  182. const resultAd2 = await responseAd2.json();
  183. adImg2.value = resultAd2.data[0];
  184. })
  185. //5.广告 end ---------------------------------------->
  186. //6.设置seo信息 start---------------------------------------->
  187. const setData = await requestDataPromise('/web/selectWebsiteArticleInfo', {
  188. method: 'GET',
  189. query: {
  190. 'articleid': articleId
  191. },
  192. });
  193. if (setData.code == 200) {
  194. let seoTitle = setData.data.title;
  195. let seoDescription = setData.data.introduce;
  196. let seoKeywords = setData.data.keyword;
  197. let seoSuffix = setData.data.suffix;
  198. let seoName = setData.data.website_name;
  199. useSeoMeta({
  200. title: seoTitle + "_" + seoName + "_" + seoSuffix,
  201. meta: [
  202. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  203. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 }
  204. ]
  205. });
  206. } else {
  207. console.log("获取广告数据失败!", setData.message)
  208. }
  209. //6.设置seo信息 end---------------------------------------->
  210. //8.页面图片放大 start---------------------------------------->
  211. const previewVisible = ref(false)
  212. const selectedImage = ref(' ')
  213. const openPreview = (event) => {
  214. if (event.target.tagName === 'IMG') {
  215. selectedImage.value = event.target.src;
  216. previewVisible.value = true;
  217. }
  218. }
  219. const closePreview = () => {
  220. previewVisible.value = false;
  221. }
  222. //8.页面图片放大 end---------------------------------------->
  223. </script>
  224. <style lang="less" scoped>
  225. @import url('@/assets/css/detail.less');
  226. </style>