123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301 |
- <template>
- <!-- 资讯详情 -->
- <div class="news">
- <main class="index_main">
- <section class="clearfix">
- <div class="info_1_left">
- <div class="breadcrumb">
- <div class="inner">
- <span class="location">当前位置 :</span>
- <el-breadcrumb :separator-icon="ArrowRight">
- <el-breadcrumb-item>
- <NuxtLink to="/">首页</NuxtLink>
- </el-breadcrumb-item>
- <el-breadcrumb-item v-if="p_parent_name != ''">
- <NuxtLink :to="`/${targetSegment}/index.html`"> {{ p_parent_name }}</NuxtLink>
- </el-breadcrumb-item>
- <el-breadcrumb-item v-if="parent_name != ''">
- <NuxtLink :to="`/${targetSegment}/${targetSegment1}/index.html`"> {{ parent_name }}
- </NuxtLink>
- </el-breadcrumb-item>
- <el-breadcrumb-item>{{ navTitle }}</el-breadcrumb-item>
- </el-breadcrumb>
- </div>
- </div>
- <h4 class="show_1_h4">{{ newsDetail.title }}</h4>
- <div class="show_1_title_box clearfix">
- <span class="show_1_title">来源:{{ newsDetail.copyfrom }}</span>
- <span class="show_1_title">作者:{{ newsDetail.author }}</span>
- <span class="show_1_title">时间:{{ getTime(newsDetail.updated_at, 'year', 1) }}</span>
- </div>
- <article class="show_1_article" v-html="newsDetail.content">
- </article>
- <footer class="show_foot" v-if="newsDetail.copyfrom != '本网'">
- 原文链接:{{ newsDetail.fromurl }}
- <br>
- [免责声明]本文来源于网络转载,仅供学习交流使用,不构成商业目的。 版权归原作者所有,如涉及作品内容,版权和其他问题,请在30日与本网联系,我们将第一时间处理。
- </footer>
- </div>
- <aside class="info_1_aside">
- <DetailHotNews></DetailHotNews>
- <DetailHotNews2></DetailHotNews2>
- <!-- <div class="shop_head_1 clearfix">
- <div class="shop_head_1_name">供求信息</div>
- </div>
- <div class="shop_img_ul_1 clearfix">
- <div class="shop_img_li_1 clearfix" v-for="(per_obj, per_index) in 2" :key="per_obj">
- <a class="shop_img_li_1_a" href="" title="">
- <img class="shop_img_li_1_img" src="@/public/img/7.png" title="" alt="">
- <div class="shop_img_li_1_right clearfix">
- <div class="shop_img_li_1_dot3 dot3 clearfix">
- 供求信息供求信息供求信息供求信息供求信息供求信息供求信息供求信息供求信息供求信息供求信息
- </div>
- <div class="shop_img_li_1_btn">供应</div>
- </div>
- </a>
- </div>
- </div>
- <div class="shop_ul_1 clearfix">
- <a class="shop_li_1 clearfix dot1" href="" title="" v-for="(per_obj, per_index) in 4"
- :key="per_obj">农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态</a>
- </div>
- <div class="shop_head_2 clearfix">
- <div class="shop_head_2_name">名品之窗</div>
- </div>
- <div class="shop_img_ul_2 clearfix">
- <div class="shop_img_li_2 clearfix" v-for="(per_obj, per_index) in 2" :key="per_obj">
- <a class="shop_img_li_2_a" href="" title="">
- <img class="shop_img_li_2_img" src="@/public/img/7.png" title="" alt="">
- <div class="shop_img_li_2_right clearfix">
- <div class="shop_img_li_2_dot3 dot3 clearfix">
- 供求信息供求信息供求信息供求信息供求信息供求信息供求信息供求信息供求信息供求信息供求信息
- </div>
- <div class="shop_img_li_2_btn">供应</div>
- </div>
- </a>
- </div>
- </div>
- <div class="shop_ul_2 clearfix">
- <a class="shop_li_2 clearfix dot1" href="" title="" v-for="(per_obj, per_index) in 4"
- :key="per_obj">农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态农产动态</a>
- </div> -->
- </aside>
- </section>
- </main>
- </div>
- </template>
- <script setup>
- //0.页面依赖 start ---------------------------------------->
- import { onMounted } from 'vue'
- import { ElBreadcrumb, ElBreadcrumbItem, ElRadio, ElRadioGroup, ElCheckbox, ElCheckboxGroup, ElMessage, ElInput } from 'element-plus'
- import { ArrowRight } from '@element-plus/icons-vue'
- //0.页面依赖 end ---------------------------------------->
- //1.获得路由id start ---------------------------------------->
- const route = useRoute();
- const articleId = parseInt(route.params.id);
- const targetSegment = getRoutePath(1);
- const targetSegment1 = getRoutePath(2);
- const targetSegment2 = getRoutePath(3);
- //1.1 获得当前的路由id
- let routeId;
- let routeType;
- let navTitle = ref('')//二级导航标题
- let navCid = ref('')//二级导航id
- //通过导航路径反向查询导航id
- const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
- method: 'GET',
- query: {
- 'pinyin': targetSegment2,
- },
- });
- console.log("getRouteId", getRouteId);
- if (getRouteId.code == 200) {
- navTitle.value = getRouteId.data.alias
- navCid.value = getRouteId.data.category_id
- } else {
- console.log("获得路由id出错!", getRouteId.message)
- }
- //1.2 获取二级栏目
- let parent_name = ref('');//父级名称
- let parent_id = ref('');//父级id
- let parent_pinyin = ref('');//父级拼音
- const getRoutePName = await requestDataPromise('/web/getWebsiteRoute', {
- method: 'GET',
- query: {
- 'pinyin': targetSegment1,
- },
- });
- console.log("getRoutePName", getRoutePName);
- if (getRoutePName.code == 200) {
- routeId = getRoutePName.data.category_id
- parent_id.value = getRoutePName.data.category_id
- parent_name.value = getRoutePName.data.alias
- routeType = getRoutePName.data.type
- } else {
- console.log("获得路由id出错!", getRoutePName.message)
- }
- //1.3 获取一级栏目
- let p_parent_name = ref('');//父级名称
- let p_parent_id = ref('');//父级id
- let p_parent_pinyin = ref('');//父级拼音
- const getRoutePName_parent = await requestDataPromise('/web/getWebsiteRoute', {
- method: 'GET',
- query: {
- 'pinyin': targetSegment,
- },
- });
- console.log("getRoutePName_parent", getRoutePName_parent);
- if (getRoutePName_parent.code == 200) {
- p_parent_id.value = getRoutePName_parent.data.category_id
- p_parent_name.value = getRoutePName_parent.data.alias
- // p_parent_pinyin.value = getRoutePName_parent.data.aLIas_pinyin
- } else {
- console.log("获得路由id出错!", getRoutePName_parent.message)
- }
- //1.4 获取某个栏目
- const getParentId = await requestDataPromise('/web/getOneWebsiteCategory', {
- method: 'GET',
- query: {
- 'catid': parent_id.value,
- },
- });
- console.log("getParentId", getParentId);
- if (getParentId.code == 200) {
- parent_pinyin.value = getParentId.data.aLIas_pinyin
- } else {
- console.log("获得路由id出错!", getParentId.message)
- }
- //1.获得路由id end ---------------------------------------->
- //4.新闻详情 start ---------------------------------------->
- //4.1 资讯详情
- const newsDetail = ref({})
- const routeNewsTtitle = ref("");
- //4.2 发布日期
- const time = ref("");
- //4.3 路径
- const routLevelTitle = ref("");
- const routLevelId = ref("");
- //4.4 是否展示投票
- const articleChoice = ref(false);
- //4.5 获取详情
- async function getPageData() {
- const mkdata = await requestDataPromise('/web/selectWebsiteArticleInfo', {
- method: 'GET',
- query: {
- 'articleid': articleId
- },
- });
- console.log('111111111111111', mkdata.data);
- if (mkdata.code == 200) {
- //判断是否显示投票
- if (mkdata.data.is_survey == 1) {
- console.log("本篇文章含有投票!")
- articleChoice.value = true;
- }
- //获取内容
- newsDetail.value = mkdata.data;
- //获取路径
- routLevelTitle.value = newsDetail.value.cat_name;
- routLevelId.value = newsDetail.value.category_id;
- //获取发布时间
- time.value = newsDetail.value.updated_at.split(' ')[0];
- //修正标题长度
- if (newsDetail.value.title.length >= 20) {
- routeNewsTtitle.value = newsDetail.value.title.substr(0, 20) + "...";
- } else {
- routeNewsTtitle.value = newsDetail.value.title
- }
- } else {
- console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
- console.log("错误位置:获取详情内容")
- console.log("后端错误反馈:", mkdata.message)
- console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
- }
- }
- getPageData();
- //4.新闻详情 end ---------------------------------------->
- //5.广告 start ---------------------------------------->
- let adImg1 = ref([]);
- let adImg2 = ref([]);
- onMounted(async () => {
- const { $webUrl, $CwebUrl } = useNuxtApp();
- //广告1
- let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=snscw_detail_0001`
- const responseAd1 = await fetch(url, {
- headers: {
- 'Content-Type': 'application/json',
- 'Userurl': $CwebUrl,
- 'Origin': $CwebUrl
- }
- });
- const resultAd1 = await responseAd1.json();
- adImg1.value = resultAd1.data[0];
- //广告2
- let url2 = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=snscw_detail_0002`
- const responseAd2 = await fetch(url2, {
- headers: {
- 'Content-Type': 'application/json',
- 'Userurl': $CwebUrl,
- 'Origin': $CwebUrl
- }
- });
- const resultAd2 = await responseAd2.json();
- adImg2.value = resultAd2.data[0];
- })
- //5.广告 end ---------------------------------------->
- //6.设置seo信息 start---------------------------------------->
- // const setData = await requestDataPromise('/web/selectWebsiteArticleInfo', {
- // method: 'GET',
- // query: {
- // 'articleid': articleId
- // },
- // });
- // if (setData.code == 200) {
- // let seoTitle = setData.data.title;
- // let seoDescription = setData.data.introduce;
- // let seoKeywords = setData.data.keyword;
- // let seoSuffix = setData.data.suffix;
- // let seoName = setData.data.website_name;
- // useSeoMeta({
- // title: seoTitle + "_" + seoName + "_" + seoSuffix,
- // meta: [
- // { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
- // { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 }
- // ]
- // });
- // } else {
- // console.log("获取广告数据失败!", setData.message)
- // }
- //6.设置seo信息 end---------------------------------------->
- //8.页面图片放大 start---------------------------------------->
- const previewVisible = ref(false)
- const selectedImage = ref(' ')
- const openPreview = (event) => {
- if (event.target.tagName === 'IMG') {
- selectedImage.value = event.target.src;
- previewVisible.value = true;
- }
- }
- const closePreview = () => {
- previewVisible.value = false;
- }
- //8.页面图片放大 end---------------------------------------->
- </script>
- <style lang="less" scoped>
- @import url('@/assets/css/shop/newsDetail.less');
- </style>
|