<template>
    <div>
        <HomePageHead></HomePageHead>
        <HomePageNavigation></HomePageNavigation>


        <div>当前皮肤：{{ skinId }}</div>
        <div>/sannongzixun/601517.html</div>
        <div><br/><br/><br/></div>
        <HomeSecondaryHeading :titleData="pageData" :pinyinid="routeId"></HomeSecondaryHeading>
        
        <!-- 页脚部分 -->
        <HomeFoot></HomeFoot>
    </div>
</template>

<script setup>
//0.获得基本信息单元 start---------------------------------------->
//0.0获得页面依赖
import { ref, onMounted } from 'vue';
import { ElMessage } from 'element-plus';
//0.1获得pinia源
import { useTemplateBaseStore } from '@/stores/templateBase'
const templateBaseStore = useTemplateBaseStore()
//0.2获得该页的皮肤id - 在每个组件中也是同样的获得方法
const skinId = ref("")
//0.3获得站点基本信息
const responseStatus = await requestDataPromise('/web/getWebsiteAllinfo', {
    method: 'GET',
    query: {
        'link_textnum':24,
        'link_imgnum':18,
        'link_footnum':4
    },
});
if (responseStatus.code == 200) {
    //0.3.1设置站点基本信息
    templateBaseStore.setWebSiteInfo(responseStatus.data)
    //0.3.2设置皮肤id
    skinId.value = templateBaseStore.webSiteInfo.website_foot.foot_info.template_id;
}
//0.4获得广告池
const adResponseStatus = await requestDataPromise('/web/getWebsiteAdvertisement', {
    method: 'GET',
    query: {},
});
if (adResponseStatus.code == 200) {
    //console.log(responseStatus.data)
    templateBaseStore.setAdList(adResponseStatus.data)
    //获取广告
    //adImg.value = requestAd(templateBaseStore.webAdList,templateBaseStore.webSiteInfo.website_head.ad_key + "_" + "top")
}
//0.获得基本信息单元 end---------------------------------------->

//1.获得路由id start ---------------------------------------->
const targetSegment = getRoutePath(1);
//1.1 获得当前的路由id
let routeId;
//1.2 通过导航路径反向查询导航id
const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
    method: 'GET',
    query: {
        'pinyin': targetSegment,
    },
});
if (getRouteId.code == 200) {
    routeId = getRouteId.data.category_id
} else {
    console.log("获得路由id出错！", getRouteId.message)
}
//1.获得路由id end ---------------------------------------->

//2.设置seo信息 start---------------------------------------->
const setData = await requestDataPromise('/web/getWebsiteCategoryHead', {
    method: 'GET',
    query: {
        'catid': routeId
    },
});

if (setData.code == 200) {
    let seoTitle = setData.data.seo_title;
    let seoDescription = setData.data.seo_description;
    let seoKeywords = setData.data.seo_keywords;
    let seoSuffix = setData.data.suffix;
    let seoName = setData.data.website_name;
    useSeoMeta({
        title: seoTitle + "_" + seoSuffix,
        meta: [
            { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
            { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 }
        ]
    });
} else {
    console.log("设置频道页SEO出错！", setData.message)
}
//2.设置seo信息 end---------------------------------------->
</script>

<style lang="less" scoped>
@import '@/assets/css/class.less';
</style>