detail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <section class="index_main">
  3. <!-- 面包屑导航 -->
  4. <div class="breadcrumb">
  5. <div class="inner">
  6. <span class="location">当前位置:</span>
  7. <el-breadcrumb :separator-icon="ArrowRight">
  8. <el-breadcrumb-item>
  9. <NuxtLink to="/">首页</NuxtLink>
  10. </el-breadcrumb-item>
  11. <el-breadcrumb-item v-if="parent_name != ''">
  12. <NuxtLink :to="`/${parent_pinyin}/index.html`"> {{ parent_name }}</NuxtLink>
  13. </el-breadcrumb-item>
  14. <el-breadcrumb-item v-if="routeName">
  15. <NuxtLink :to="`/${targetSegment}/${targetSegment1}/index.html`"> {{ routeName }}</NuxtLink>
  16. </el-breadcrumb-item>
  17. <el-breadcrumb-item v-if="routeName1">
  18. <NuxtLink :to="`list-1.html`"> {{ routeName1 }}</NuxtLink>
  19. </el-breadcrumb-item>
  20. <el-breadcrumb-item>{{ routeNewsTtitle }}</el-breadcrumb-item>
  21. </el-breadcrumb>
  22. </div>
  23. </div>
  24. <!-- 面包屑 end-->
  25. <div class="info_head_box clearfix">
  26. <div class="info_head_left">
  27. <a class="info_head_a info_head_only" :title="公司信息">公司信息</a>
  28. </div>
  29. </div>
  30. <section class="index_2 clearfix">
  31. <img class="index_2_img" :src="detailImg[0]" :title="routeNewsTtitle" alt="">
  32. <div class="index_2_right">
  33. <h4 class="index_2_h4"> {{ routeNewsTtitle }}</h4>
  34. <div class="index_2_title_box clearfix">
  35. <time class="index_2_title">
  36. 成立日期:
  37. <span v-if="time"> {{ time }}</span>
  38. </time>
  39. <span class="index_2_title">
  40. 所在城市:
  41. <span v-if="newsDetail.city_name">{{ newsDetail.city_name }}</span>
  42. </span>
  43. </div>
  44. <div class="index_2_ul clearfix">
  45. <div class="index_2_ul_left">
  46. <div class="index_2_li clearfix">
  47. <label class="index_2_li_label">机构性质</label>
  48. <span class="index_2_li_text " v-if="newsDetail.jobnature_name">
  49. {{ newsDetail.jobnature_name }}</span>
  50. </div>
  51. <div class="index_2_li clearfix">
  52. <label class="index_2_li_label">负 责 人</label>
  53. <span class="index_2_li_text" v-if="newsDetail.manager">
  54. {{ newsDetail.manager }}
  55. </span>
  56. </div>
  57. <div class="index_2_li clearfix">
  58. <label class="index_2_li_label">联 系 人</label>
  59. <span class="index_2_li_text " v-if="newsDetail.content_person">
  60. {{ newsDetail.content_person }}
  61. </span>
  62. </div>
  63. <div class="index_2_li clearfix">
  64. <label class="index_2_li_label">联系电话</label>
  65. <span class="index_2_li_text ">{{ newsDetail.telephone }}</span>
  66. </div>
  67. <div class="index_2_li clearfix">
  68. <label class="index_2_li_label">手 &nbsp;&nbsp;&nbsp;&nbsp; 机</label>
  69. <span class="index_2_li_text ">{{ newsDetail.mobile }}</span>
  70. </div>
  71. <div class="index_2_li clearfix">
  72. <label class="index_2_li_label">地 &nbsp;&nbsp;&nbsp;&nbsp; 址</label>
  73. <span class="index_2_li_text ">{{ newsDetail.adress }}</span>
  74. </div>
  75. </div>
  76. <div class="index_2_ul_left">
  77. <div class="index_2_li clearfix">
  78. <label class="index_2_li_label">所属行业</label>
  79. <span class="index_2_li_text ">{{ newsDetail.hy_name }}</span>
  80. </div>
  81. <div class="index_2_li clearfix">
  82. <label class="index_2_li_label">联系QQ</label>
  83. <span class="index_2_li_text ">{{ newsDetail.QQ }}</span>
  84. </div>
  85. <div class="index_2_li clearfix">
  86. <label class="index_2_li_label">网 &nbsp;&nbsp;&nbsp;&nbsp; 址</label>
  87. <span class="index_2_li_text ">{{ newsDetail.company_url }}</span>
  88. </div>
  89. <div class="index_2_li clearfix">
  90. <label class="index_2_li_label">邮政编码</label>
  91. <span class="index_2_li_text ">{{ newsDetail.post_code }}</span>
  92. </div>
  93. <div class="index_2_li clearfix">
  94. <label class="index_2_li_label">传 &nbsp;&nbsp;&nbsp;&nbsp; 真</label>
  95. <span class="index_2_li_text ">{{ newsDetail.fax }}</span>
  96. </div>
  97. </div>
  98. </div>
  99. </div>
  100. </section>
  101. <section class="index_3 clearfix">
  102. <div class="info_2_head_box clearfix">
  103. <div class="info_2_head_left">
  104. <a class="info_2_head_a info_2_head_only" title="">详情信息</a>
  105. </div>
  106. </div>
  107. <div class="info_article" v-html="newsDetail.content"></div>
  108. </section>
  109. </section>
  110. </template>
  111. <script setup>
  112. import { ref } from 'vue'
  113. import { ElBreadcrumb, ElBreadcrumbItem } from 'element-plus'
  114. import { ArrowRight } from '@element-plus/icons-vue'
  115. //2.页面路径 start ---------------------------------------->
  116. const route = useRoute();
  117. const articleId = parseInt(route.params.id);
  118. const targetSegment = getRoutePath(1);
  119. const targetSegment1 = getRoutePath(2);
  120. const targetSegment2 = getRoutePath(3);
  121. // 2.1 查询一级栏目的id
  122. //通过导航路径反向查询导航id
  123. let routeId;
  124. const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
  125. method: 'GET',
  126. query: {
  127. 'pinyin': targetSegment,
  128. },
  129. });
  130. if (getRouteId.code == 200) {
  131. routeId = getRouteId.data.category_id
  132. } else {
  133. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  134. console.log("错误位置:通过url路径查询导航池id")
  135. console.log("后端错误反馈:", getRouteId.message)
  136. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  137. }
  138. // 2.2查询二级栏目的id及名称
  139. let routeName = ref('');
  140. let routeId1 = ref('');
  141. const getRoutePName = await requestDataPromise('/web/getWebsiteRoute', {
  142. method: 'GET',
  143. query: {
  144. 'pinyin': targetSegment1,
  145. },
  146. });
  147. if (getRoutePName.code == 200) {
  148. routeId1.value = getRoutePName.data.category_id;
  149. routeName.value = getRoutePName.data.alias;
  150. } else {
  151. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  152. console.log("错误位置:通过url路径查询导航池id")
  153. console.log("后端错误反馈:", getRouteId.message)
  154. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  155. }
  156. // 2.3 查询三级栏目的id及名称
  157. let routeName1 = ref('');
  158. let routeId11 = ref('');
  159. const getRoutePName1 = await requestDataPromise('/web/getWebsiteRoute', {
  160. method: 'GET',
  161. query: {
  162. 'pinyin': targetSegment2,
  163. },
  164. });
  165. if (getRoutePName1.code == 200) {
  166. routeId11.value = getRoutePName1.data.category_id;
  167. routeName1.value = getRoutePName1.data.alias;
  168. } else {
  169. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  170. console.log("错误位置:通过url路径查询导航池id")
  171. console.log("后端错误反馈:", getRouteId.message)
  172. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  173. }
  174. //2.页面路径 end ---------------------------------------->
  175. //3.面包屑 start ---------------------------------------->
  176. const parent_name = ref("");
  177. const parent_id = ref("");
  178. const parent_pinyin = ref("");
  179. let getParentNav = async () => {
  180. const listData = await requestDataPromise('/web/getOneWebsiteCategory', {
  181. method: 'GET',
  182. query: {
  183. 'catid': routeId
  184. },
  185. });
  186. if (listData.code == 200) {
  187. parent_name.value = listData.data.alias;
  188. parent_id.value = listData.data.parent_id;
  189. parent_pinyin.value = listData.data.aLIas_pinyin;
  190. } else {
  191. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  192. console.log("错误位置:获取面包屑导航")
  193. console.log("后端错误反馈:", listData.message)
  194. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  195. }
  196. }
  197. //获得父级栏目详情
  198. getParentNav();
  199. //3.面包屑 end ------------------------------------------->
  200. //4.新闻详情 start ---------------------------------------->
  201. //4.1 资讯详情
  202. const newsDetail = ref({})
  203. const routeNewsTtitle = ref("");
  204. //4.2 发布日期
  205. const time = ref("");
  206. //4.3 路径
  207. const routLevelTitle = ref("");
  208. const routLevelId = ref("");
  209. //4.4 是否展示投票
  210. let detailImg = ref('');
  211. let seoTitle;
  212. let seoDescription;
  213. let seoKeywords;
  214. //4.5 获取详情
  215. const mkdata = await requestDataPromise('/web/getWebsiteCompanyInfo', {
  216. method: 'GET',
  217. query: {
  218. 'id': articleId
  219. },
  220. });
  221. if (mkdata.code == 200) {
  222. //获取内容
  223. newsDetail.value = mkdata.data;
  224. detailImg.value = JSON.parse(mkdata.data.imgurl);
  225. //修正标题长度
  226. if (newsDetail.value.title.length >= 20) {
  227. routeNewsTtitle.value = newsDetail.value.title.substr(0, 20) + "...";
  228. } else {
  229. routeNewsTtitle.value = newsDetail.value.title
  230. }
  231. //获取发布时间
  232. if (newsDetail.value.data) {
  233. time.value = newsDetail.value.data.split(' ')[0];
  234. }
  235. seoTitle = newsDetail.value.title;
  236. seoDescription = newsDetail.value.description;
  237. seoKeywords = newsDetail.value.keyword;
  238. } else {
  239. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  240. console.log("错误位置:获取详情内容")
  241. console.log("后端错误反馈:", mkdata.message)
  242. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  243. }
  244. //4.新闻详情 end ---------------------------------------->
  245. //5.设置seo信息 start---------------------------------------->
  246. const setData = await requestDataPromise('/web/getWebsiteCategoryHead', {
  247. method: 'GET',
  248. query: {
  249. 'catid': routeId1.value
  250. },
  251. });
  252. if (setData.code == 200) {
  253. let seoSuffix = setData.data.suffix;
  254. let seoName = setData.data.website_name;
  255. useSeoMeta({
  256. title: seoTitle + "_" + seoName + "_" + seoSuffix,
  257. meta: [
  258. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  259. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 }
  260. ]
  261. });
  262. } else {
  263. console.log("设置频道页SEO出错!", setData.message)
  264. }
  265. //5.设置seo信息 end---------------------------------------->
  266. //6.广告 start ---------------------------------------->
  267. let adImg1 = ref([]);
  268. let adImg2 = ref([]);
  269. onMounted(async () => {
  270. const { $webUrl, $CwebUrl } = useNuxtApp();
  271. //广告1
  272. let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nzgxw_detail_0001`
  273. const responseAd1 = await fetch(url, {
  274. headers: {
  275. 'Content-Type': 'application/json',
  276. 'Userurl': $CwebUrl,
  277. 'Origin': $CwebUrl
  278. }
  279. });
  280. const resultAd1 = await responseAd1.json();
  281. adImg1.value = resultAd1.data[0];
  282. //广告2
  283. let url2 = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nzgxw_detail_0002`
  284. const responseAd2 = await fetch(url2, {
  285. headers: {
  286. 'Content-Type': 'application/json',
  287. 'Userurl': $CwebUrl,
  288. 'Origin': $CwebUrl
  289. }
  290. });
  291. const resultAd2 = await responseAd2.json();
  292. adImg2.value = resultAd2.data[0];
  293. })
  294. //6.广告 end ---------------------------------------->
  295. </script>
  296. <style lang="less" scoped>
  297. @import url(@/assets/css/company/detail.less);
  298. </style>