<template>
    <div>
        <HomePageHead></HomePageHead>
        <HomePageNavigation></HomePageNavigation>
        <HomeSecondaryHeading :titleData="pageData" :pinyinid="routeId"></HomeSecondaryHeading>
        
        <div class="farmingPartOne">
            <div class="inner">
                <div class="innerLeft" v-if="pageData.length>0">
                    <div class="title">
                        <h3>
                            <NuxtLink :href="getLinkPath(pageData[0])" v-if="pageData[0]" :title="pageData[0].alias">
                                {{ pageData[0].alias }}
                            </NuxtLink>
                            <span>
                                <NuxtLink :href="getLinkPath(pageData[0])" v-if="pageData[0]" :title="pageData[0].title">
                                    查看更多
                                </NuxtLink>
                            </span>
                        </h3>
                    </div>
                    <div class="leftTop">
                        <div class="leftTopPhoto left" v-if="pageData[0].data[0]">
                            <NuxtLink :href="getLinkPathDetail(pageData[0].data[0])" :title="pageData[0].data[0].title">
                                <img :src="pageData[0].data[0].imgurl" :alt="pageData[0].data[0].title">
                                <span>{{pageData[0].data[0].title }}</span>
                            </NuxtLink>
                        </div>
                        <div class="leftTopPhoto left" v-else></div>
                        <ul class="left">
                            <li v-for="item in pageData[0].data3">
                                <em></em>
                                <span>
                                    <NuxtLink :href="getLinkPathDetail(item)" :title="item.title">
                                        {{ item.title }}
                                    </NuxtLink>
                                </span>
                            </li>
                        </ul>
                    </div>
                    <ul class="leftBottom" v-if="pageData[0].data2[0]!=null">
                        <li v-for="item in pageData[0].data2">
                            <NuxtLink :href="getLinkPathDetail(item)" :title="item.title">
                                <img :src="item.imgurl" :alt="item.title">
                            </NuxtLink>
                            <p>
                                <NuxtLink :href="getLinkPathDetail(item)" :title="item.title">
                                    {{ item.title }}
                                </NuxtLink>
                            </p>
                        </li> 
                    </ul>
                </div>
                
                <div class="innerRight" v-if="pageData.length>=2">
                    <div class="title">
                        <h3>
                            <NuxtLink :href="getLinkPath(pageData[1])" v-if="pageData[1]" :title="pageData[1].alias">
                                {{ pageData[1].alias }}
                            </NuxtLink>
                            <span>
                                <NuxtLink :href="getLinkPath(pageData[1])" v-if="pageData[1]" :title="pageData[1].title">
                                    查看更多
                                </NuxtLink>
                            </span>
                        </h3>
                    </div>
                    <ul class="rightList">
                        <li v-for="item in pageData[1].data">
                            <NuxtLink :href="getLinkPathDetail(item)" :title="item.title">
                                <img class="left" :src="item.imgurl" :alt="item.title">
                            </NuxtLink>
                            <p class="left">
                                <NuxtLink :href="getLinkPathDetail(item)" :title="item.title">
                                    {{ item.title }}
                                </NuxtLink>
                            </p>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        <HomeTopTen :imgurl="adImg1" v-if="adImg1"></HomeTopTen>
        <div class="farmingPartTwo" v-if="pageData.length>=3">
            <div class="inner">
                <div class="farmer"  v-if="pageData.length>=3">
                    <div class="title">
                        <h3>
                            <NuxtLink :href="getLinkPath(pageData[2])" v-if="pageData[2]" :title="pageData[2].alias">
                                {{ pageData[2].alias }}
                            </NuxtLink>
                            <span>
                                <NuxtLink :href="getLinkPath(pageData[2])" v-if="pageData[2]" :title="pageData[2].title">
                                    查看更多
                                </NuxtLink>
                            </span>
                        </h3>
                    </div>
                    <div class="PartTwoPhoto">
                        <div v-if="pageData[2].data[0]">
                            <NuxtLink :href="getLinkPathDetail(pageData[2].data[0])" :title="pageData[2].data[0].title">
                                <img :src="pageData[2].data[0].imgurl" :alt="pageData[2].data[0].title">
                                <span>{{ pageData[2].data[0].title }}</span>
                            </NuxtLink>
                        </div>
                    </div>
                    <ul class="PartTwoList">
                        <li v-for="item in pageData[2].data2">
                            <em></em>
                            <NuxtLink :href="getLinkPathDetail(item)" :title="item.title">
                                {{ item.title }}
                            </NuxtLink>
                        </li>
                    </ul>
                </div>
                <div class="farmer" v-if="pageData.length>=4">
                    <div class="title">
                        <h3>
                            <NuxtLink :href="getLinkPath(pageData[3])" v-if="pageData[3]" :title="pageData[3].alias">
                                {{ pageData[3].alias }}
                            </NuxtLink>
                            <span>
                                <NuxtLink :href="getLinkPath(pageData[3])" v-if="pageData[3]" :title="pageData[3].title">
                                    查看更多
                                </NuxtLink>
                            </span>
                        </h3>
                    </div>
                    <div class="PartTwoPhoto">
                        <div v-if="pageData[3].data[0]">
                            <NuxtLink :href="getLinkPathDetail(pageData[3].data[0])" :title="pageData[3].data[0].title">
                                <img :src="pageData[3].data[0].imgurl" :alt="pageData[3].data[0].title">
                                <span>{{ pageData[3].data[0].title }}</span>
                            </NuxtLink>
                        </div>
                    </div>
                    <ul class="PartTwoList">
                        <li v-for="item in pageData[3].data2">
                            <em></em>
                            <NuxtLink :href="getLinkPathDetail(item)" :title="item.title">
                                {{ item.title }}
                            </NuxtLink>
                        </li>
                    </ul>
                </div>
                <div class="farmer" v-if="pageData.length>=5">
                    <div class="title">
                        <h3>
                            <NuxtLink :href="getLinkPath(pageData[4])" v-if="pageData[4]" :title="pageData[4].alias">
                                {{ pageData[4].alias }}
                            </NuxtLink>
                            <span>
                                <NuxtLink :href="getLinkPath(pageData[4])" v-if="pageData[4]" :title="pageData[4].title">
                                    查看更多
                                </NuxtLink>
                            </span>
                        </h3>
                    </div>
                    <div class="PartTwoPhoto">
                        <div v-if="pageData[4].data[0]">
                            <NuxtLink :href="getLinkPathDetail(pageData[4].data[0])" :title="pageData[4].data[0].title">
                                <img :src="pageData[4].data[0].imgurl" :alt="pageData[4].data[0].title">
                                <span>{{ pageData[4].data[0].title }}</span>
                            </NuxtLink>
                        </div>
                    </div>
                    <ul class="PartTwoList">
                        <li v-for="item in pageData[4].data2">
                            <em></em>
                            <NuxtLink :href="getLinkPathDetail(item)" :title="item.title">
                                {{ item.title }}
                            </NuxtLink>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        <HomeTopTen :imgurl="adImg2" v-if="adImg2"></HomeTopTen>
        <div class="zixuntuijian" v-if="pageData.length>=6">
            <div class="inner">
                <div class="innerLeft" >
                    <div class="zixunTop">
                        <div class="zixunLeft" v-if="pageData.length>=6">
                            <div class="title">
                                <h3>
                                    <NuxtLink :href="getLinkPath(pageData[5])" v-if="pageData[5]" :title="pageData[5].alias">
                                        {{ pageData[5].alias }}
                                    </NuxtLink>
                                    <span>
                                        <NuxtLink :href="getLinkPath(pageData[5])" v-if="pageData[5]" :title="pageData[5].title">
                                            查看更多
                                        </NuxtLink>
                                    </span>
                                </h3>
                            </div>
                            <ul class="photo_text" v-if="pageData[5].data[0]!= null">
                                <li v-for="item in pageData[5].data">
                                    <article>
                                        <NuxtLink :href="getLinkPathDetail(item)" :title="item.title">
                                            <img :src="item.imgurl" :alt="item.title">
                                        </NuxtLink>
                                        <div>
                                            <h5>
                                                <NuxtLink :href="getLinkPathDetail(item)" :title="item.title">
                                                    {{ item.title }}
                                                </NuxtLink>
                                            </h5>
                                            <p>
                                                <span>{{ item.author }}</span>
                                                <span>{{ getTime(item.updated_at,'month',1) }}</span>
                                            </p>
                                        </div>
                                    </article>
                                </li>
                                <li v-for="item in pageData[5].data2">
                                    <article>
                                        <em></em>
                                        <NuxtLink :href="getLinkPathDetail(item)" :title="item.title">
                                            {{ item.title }}
                                        </NuxtLink>
                                    </article>
                                </li>
                            </ul>
                        </div>
                        <div class="zixunRight"  v-if="pageData.length>=7">
                            <div class="title">
                                <h3>
                                    <NuxtLink :href="getLinkPath(pageData[6])" v-if="pageData[6]" :title="pageData[6].alias">
                                        {{ pageData[6].alias }}
                                    </NuxtLink>
                                    <span>
                                        <NuxtLink :href="getLinkPath(pageData[6])" v-if="pageData[6]" :title="pageData[6].title">
                                            查看更多
                                        </NuxtLink>
                                    </span>
                                </h3>
                            </div>
                            <div class="towPic">
                                <div v-for="item in pageData[6].data" class="picBox">
                                    <div>
                                        <NuxtLink :href="getLinkPathDetail(item)" :title="item.title">
                                            <img :src="item.imgurl" :alt="item.title">
                                        </NuxtLink>
                                    </div>
                                </div>
                            </div>
                            <ul class="photo_text">
                                <li v-for="item in pageData[6].data2">
                                    <article>
                                        <em></em>
                                        <NuxtLink :href="getLinkPathDetail(item)" :title="item.title">
                                            {{ item.title }}
                                        </NuxtLink>
                                    </article>
                                </li>
                            </ul>
                        </div>
                    </div>
                    <div class="zixunBottom" v-if="pageData[7].data[0] != null">
                        <img class="left" :src="pageData[7].data[0].imgurl" :alt="pageData[7].data[0].title"
                            v-if="pageData[7].data[0] && hoverStatus == 0">
                        <img class="left" :src="pageData[7].data[1].imgurl" :alt="pageData[7].data[1].title"
                            v-if="pageData[7].data[1] && hoverStatus == 1">
                        <img class="left" :src="pageData[7].data[2].imgurl" :alt="pageData[7].data[2].title"
                            v-if="pageData[7].data[2] && hoverStatus == 2">
                        <img class="left" :src="pageData[7].data[3].imgurl" :alt="pageData[7].data[3].title"
                            v-if="pageData[7].data[3] && hoverStatus == 3">
                        <img class="left" :src="pageData[7].data[4].imgurl" :alt="pageData[7].data[4].title"
                            v-if="pageData[7].data[4] && hoverStatus == 4">
                        <img class="left" :src="pageData[7].data[5].imgurl" :alt="pageData[7].data[5].title"
                            v-if="pageData[7].data[5] && hoverStatus == 5">
                            
                        <ul class="leftList left">
                            <li v-for="(item, index) in pageData[7].data" @mouseenter="qhPic(index)">
                                <h4>
                                    <em></em>
                                    <NuxtLink :href="getLinkPathDetail(item)" :title="item.title">
                                        {{ item.title }}
                                    </NuxtLink>
                                </h4>
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="innerRight" v-if="pageData.length>=8">
                    <div class="title">
                        <h3>
                            <NuxtLink :href="getLinkPath(pageData[7])" v-if="pageData[7]" :title="pageData[7].alias">
                                {{ pageData[7].alias }}
                            </NuxtLink>
                            <span>
                                <NuxtLink :href="getLinkPath(pageData[7])" v-if="pageData[7]" :title="pageData[7].title">
                                    查看更多
                                </NuxtLink>
                            </span>
                        </h3>
                    </div>
                    <ul class="information">
                        <li v-for="item in pageData[7].data2">
                            <NuxtLink :href="getLinkPathDetail(item)" :title="item.title">
                                <img :src="item.imgurl" :alt="item.title">
                            </NuxtLink>
                            <div class="text">
                                <h5>
                                    <NuxtLink :href="getLinkPathDetail(item)" :title="item.title">
                                        {{ item.title }}
                                    </NuxtLink>
                                </h5>
                                <p>{{ item.author }}</p>
                            </div>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        <HomeTopTen :imgurl="adImg3" v-if="adImg3"></HomeTopTen>
        <!-- 十强称号logo -->
        <HomeTopTen :imgurl="adImg4" v-if="adImg4"></HomeTopTen>
        <!-- 页脚部分 -->
        <HomeFoot1></HomeFoot1>
    </div>
</template>

<script setup>
//0.加载页面依赖 start ---------------------------------------->
import { ref, onMounted } from 'vue';
import { ElMessage } from 'element-plus';

//格式化跳转路径 - 标题
//首页分类栏目标题，不需要考虑外链
const getLinkPath = (item) => {
    //return `/${item.url}/1.html`;
    //return `/newsList/${item.cid}?page=1`;
    return `/${item.aLIas_pinyin}/list-1.html`;
}
//首页跳转到详情，这里需要考虑外链
const getLinkPathDetail = (item) => {
    if (item.islink == 1) {
        return `${item.linkurl}`;
    } else {
        //return `/${item.aLIas_pinyin}/${item.id}`;
        //return `/newsDetail/${item.id}`
        return `/${item.pinyin}/${item.id}.html`;
    }
}
//0.加载页面依赖 end ---------------------------------------->

//1.获得路由id start ---------------------------------------->
const route = useRoute();

//获得当前的完整路径
const fullPath = route.path;
//拆分，取出来中间这一段，然后提取数字部分
const segments = fullPath.split('/'); 
const targetSegment = segments[1]; 
//let routeId = 11 //排除路径错误可以打开这个
//const numberPart = targetSegment.match(/\d+$/)?.[0]; 
//let routeId = numberPart;
let routeId;
//通过导航路径反向查询导航id
const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
    method: 'GET',
    query: {
        'pinyin': targetSegment,
    },
});
if(getRouteId.code == 200){
    routeId = getRouteId.data.category_id
}else{
    console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
    console.log("错误位置：通过url路径查询导航池id")
    console.log("后端错误反馈：",getRouteId.message)
    console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
}
//1.获得路由id end ---------------------------------------->

//2.页面交互效果 start ---------------------------------------->
//2.1 新闻图片切换
const hoverStatus = ref(0)
const qhPic = function (num) {
    console.log(num)
    hoverStatus.value = num;
}

//2.2 选项卡切换
let showTabs = ref(1)
let qhtabs = function (number) {
    console.log(number)
    showTabs.value = number
}

//2.3 展示广告
let adImg1 = ref({})
let adImg2 = ref({})
let adImg3 = ref({})
let adImg4 = ref({})
onMounted(async ()  => {
    //从客户端获取行政职能部门 加快打开速度
    const { $webUrl, $CwebUrl } = useNuxtApp();
    //广告1
    let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=snzxw_category_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=snzxw_category_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];

    //广告3
    let url3 = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=snzxw_category_0003`
    const responseAd3 = await fetch(url3, {
        headers: {
            'Content-Type': 'application/json',
            'Userurl': $CwebUrl,
            'Origin': $CwebUrl
        }
    });
    const resultAd3 = await responseAd3.json();
    adImg3.value = resultAd3.data[0];

    //广告4
    let url4 = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=snzxw_category_0004`
    const responseAd4 = await fetch(url4, {
        headers: {
            'Content-Type': 'application/json',
            'Userurl': $CwebUrl,
            'Origin': $CwebUrl
        }
    });
    const resultAd4 = await responseAd4.json();
    adImg4.value = resultAd4.data[0];

})
//2.页面交互效果 end ---------------------------------------->

//3.渲染页面数据 start ---------------------------------------->
//3.1 该页面上所有的导航池 转为动态数据
const pageCategory = ref([]);
//3.2 该页面上需要渲染的所有数据
const pageData = ref([
    // { id: 0, data: [], data2: [], title: "", cid: "" },
    // { id: 1, data: [], title: "", cid: "" },
    // { id: 2, data: [], title: "", cid: "" },
    // { id: 3, data: [], title: "", cid: "" },
    // { id: 4, data: [], title: "", cid: "" },
    // { id: 5, data: [], title: "", cid: "" },
    // { id: 6, data: [], title: "", cid: "" },
    // { id: 7, data: [], title: "", cid: "" },
    // { id: 8, data: [], title: "", cid: "" },
    // { id: 9, data: [], title: "", cid: "" },
    // { id: 10, data: [], title: "", cid: "" },
    // { id: 10, data: [], title: "", cid: "" },
    // {
    //     id: 11,
    //     title: "",
    //     data: [],
    //     data1: [],
    //     data2: [],
    //     data3: [],
    //     data4: [],
    //     category_id1: "",
    //     category_id2: "",
    //     category_id3: "",
    //     category_id4: "",
    //     title1: "",
    //     title2: "",
    //     title3: "",
    //     title4: "",
    //     cid: ""
    // },
    // { id: 12, data1: [], data2: [], data3: [], cid: "" },
])

const navSize = ref("");

//3.3 获取所有导航
try {
    const navigateData = await requestDataPromise('/web/getWebsiteModelCategory', {
        method: 'GET',
        query: {
            'placeid': 1,
            'pid': routeId,
            'num': 8
        },
    });
    if(navigateData.code == 200){
        // 遍历可用的导航池放到页面中
        for (let index in navigateData.data) {
            let data = {
                title: navigateData.data[index].name,
                cid: navigateData.data[index].category_id,
                children_count: navigateData.data[index].children_count,
                alias: navigateData.data[index].alias,
                aLIas_pinyin: targetSegment + "/" + navigateData.data[index].aLIas_pinyin,
                data:[],
                data1:[],
                data2:[],
                data3:[],
                data4:[],
                category_id1:"",
                category_id2:"",
                category_id3:"",
                category_id4:"",
                title1: "",
                title2: "",
                title3: "",
                title4: ""
            };
            if (navigateData.data[index].is_url == 1) {
                // 处理 URL 的逻辑
            } else {
                //每个页面最多8个模块
                pageData.value.push(data);
            }
        }
        //导航池加载完毕，开始申请模块数据
        // await getPageData1();
        // await getPageData2();
        // await getPageData3();
        // await getPageData4();
        // await getPageData5();
        // await getPageData6();
        // await getPageData7();
        // await getPageData8();
        let getJson = [
            {"parent":routeId + ",0,0","child":pageData.value[0].cid + ",5,8"},//模块1理论前沿
            {"parent":routeId + ",0,0","child":pageData.value[0].cid + ",5,0"},//模块2典型经验
            {"parent":routeId + ",0,0","child":pageData.value[0].cid + ",1,6"},//模块3农业天地
            {"parent":routeId + ",0,0","child":pageData.value[0].cid + ",1,6"},//模块4美丽乡村
            {"parent":routeId + ",0,0","child":pageData.value[0].cid + ",1,6"},//模块5农民之家
            {"parent":routeId + ",0,0","child":pageData.value[0].cid + ",6,3"},//模块6农业天地
            {"parent":routeId + ",0,0","child":pageData.value[0].cid + ",2,3"},//模块7农村建设
            {"parent":routeId + ",0,0","child":pageData.value[0].cid + ",4,0"},//模块8高端资讯
        ]

        let jsonString = JSON.stringify(getJson);
        getPageAllData(jsonString);

    }else{
        console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
        console.log("错误位置：分类页导航池")
        console.log("后端错误反馈：",navigateData.message)
        console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
    }
} catch (error) {
    console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
    console.log("错误位置：分类页导航渲染阶段")
    console.log("错误：导航池渲染执行接口出错！请检查首页的14的模块的具体执行方法！")
    console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
}


async function getPageAllData(jsonString){
    const mkdata =  await requestDataPromise('/web/getWebsiteAllArticle', {
        method: 'GET',
        query: {
            'id':jsonString
        },
    });

    if(mkdata.code==200){
        console.log(778899)
        console.log(mkdata.data)
        //模块1理论前沿
        if(mkdata.data[0].child.imgnum.length > 0){
            pageData.value[0].data.push(mkdata.data[0].child.imgnum[0]);
        }
        if(mkdata.data[0].child.imgnum.length > 1){
            pageData.value[0].data2.push(mkdata.data[0].child.imgnum[1]);
        }
        if(mkdata.data[0].child.imgnum.length > 2){
            pageData.value[0].data2.push(mkdata.data[0].child.imgnum[2]);
        }
        if(mkdata.data[0].child.imgnum.length > 3){
            pageData.value[0].data2.push(mkdata.data[0].child.imgnum[3]);
        }
        if(mkdata.data[0].child.imgnum.length > 4){
            pageData.value[0].data2.push(mkdata.data[0].child.imgnum[4]);
        }
        pageData.value[0].data3 = mkdata.data[0].child.textnum;
        //模块2典型经验
        pageData.value[1].data = mkdata.data[1].imgnum;
        //模块3农业天地
        pageData.value[2].data = mkdata.data[2].imgnum;
        pageData.value[2].data2 = mkdata.data[2].textnum;
        //模块4美丽乡村
        pageData.value[3].data = mkdata.data[3].imgnum;
        pageData.value[3].data2 = mkdata.data[3].textnum;
        //模块5农民之家
        pageData.value[4].data = mkdata.data[4].imgnum;
        pageData.value[4].data2 = mkdata.data[4].textnum;
        //模块6农业天地 注意，三农资讯网跟其他行星站不一样，你不需要复制我这个
        //因为本来二级分类页有9个模块，但是实际应用中只有8个，所以我把本来是模块7
        //的地方和现有的模块6合并成1个了
        if(mkdata.data[5].imgnum.length > 0){
            pageData.value[5].data.push(mkdata.data[5].imgnum[0]);
        }
        pageData.value[5].data2 = mkdata.data[5].textnum;
        //把模块6的内容放到模块7中一部分
        for (let i = 1; i < mkdata.data[5].imgnum.length && i <= 5; i++) {
            pageData.value[7].data.push(mkdata.data[5].imgnum[i]);
        }
        //模块7农村建设
        pageData.value[6].data = mkdata.data[6].imgnum;
        pageData.value[6].data2 = mkdata.data[6].textnum;
        //模块8高端资讯
        pageData.value[7].data2 = mkdata.data[7].imgnum;

    }else{
        ElMessage.error(mkdata.message)
    }
}


//获得模块数据
// async function getPageData(catid,img_num,text_num,modulesNum,childNavNum,childImgNum,childTextNum){
//     const mkdata =  await requestDataPromise('/web/getWebsiteCatidArticle', {
//         method: 'GET',
//         query: {
//             'catid': catid, //catid
//             'img_num': img_num, //图片数量
//             'text_num': text_num, //文字数量
//             'child_catnum':childNavNum,//子级栏目菜单数量
//             'child_imgnum':childImgNum,//子栏目展示图片新闻数量
//             'child_textnum':childTextNum//子栏目展示文字新闻数量
//         },
//     });
//     if(modulesNum == 1){
//         if(mkdata.data.img.length > 0){
//             pageData.value[0].data.push(mkdata.data.img[0]);
//         }
//         if(mkdata.data.img.length > 1){
//             pageData.value[0].data2.push(mkdata.data.img[1]);
//         }
//         if(mkdata.data.img.length > 2){
//             pageData.value[0].data2.push(mkdata.data.img[2]);
//         }
//         if(mkdata.data.img.length > 3){
//             pageData.value[0].data2.push(mkdata.data.img[3]);
//         }
//         if(mkdata.data.img.length > 4){
//             pageData.value[0].data2.push(mkdata.data.img[4]);
//         }
//         // pageData.value[0].data.push(mkdata.data.img[0]);
//         // pageData.value[0].data2.push(mkdata.data.img[1]);
//         // pageData.value[0].data2.push(mkdata.data.img[2]);
//         // pageData.value[0].data2.push(mkdata.data.img[3]);
//         // pageData.value[0].data2.push(mkdata.data.img[4]);
//         pageData.value[0].data3 = mkdata.data.text;
//     }
//     if(modulesNum == 2){
//         pageData.value[1].data = mkdata.data.img;
//     }
//     if(modulesNum == 3){
//         pageData.value[2].data = mkdata.data.img;
//         pageData.value[2].data2 = mkdata.data.text;
//     }
//     if(modulesNum == 4){
//         pageData.value[3].data = mkdata.data.img;
//         pageData.value[3].data2 = mkdata.data.text;
//     }
//     if(modulesNum == 5){
//         pageData.value[4].data = mkdata.data.img;
//         pageData.value[4].data2 = mkdata.data.text;
//     }
//     if(modulesNum == 6){
//         if(mkdata.data.img.length > 0){
//             pageData.value[5].data.push(mkdata.data.img[0]);
//         }
//         pageData.value[5].data2 = mkdata.data.text;
//         if(mkdata.data.img.length > 1){
//             pageData.value[7].data.push(mkdata.data.img[1]);
//         }
//         if(mkdata.data.img.length > 2){
//             pageData.value[7].data.push(mkdata.data.img[2]);
//         }
//         if(mkdata.data.img.length > 3){
//             pageData.value[7].data.push(mkdata.data.img[3]);
//         }
//         if(mkdata.data.img.length > 4){
//             pageData.value[7].data.push(mkdata.data.img[4]);
//         }
//         if(mkdata.data.img.length > 5){
//             pageData.value[7].data.push(mkdata.data.img[5]);
//         }
//     }
//     if(modulesNum == 7){
//         pageData.value[6].data = mkdata.data.img;
//         pageData.value[6].data2 = mkdata.data.text;
//     }
//     //模块8 向后移动一个位置
//     if(modulesNum == 8){
//         pageData.value[7].data2 = mkdata.data.img;
//     }
// }
//新农村
//模块1 理论前沿
// async function getPageData1() {
//     await getPageData(pageData.value[0].cid,5,8,1,0,0,0);
// }
// //模块2 典型经验
// async function getPageData2() {
//     await getPageData(pageData.value[1].cid,5,0,2,0,0,0);
// }
// //模块3 农业天地
// async function getPageData3() {
//     await getPageData(pageData.value[2].cid,1,6,3,0,0,0);
// }
// //模块4 美丽乡村
// async function getPageData4() {
//     await getPageData(pageData.value[3].cid,1,6,4,0,0,0);
// }
// //模块5 农民之家
// async function getPageData5() {
//     await getPageData(pageData.value[4].cid,1,6,5,0,0,0);
// }
// //模块6 农业天地
// async function getPageData6() {
//     await getPageData(pageData.value[5].cid,6,3,6,0,0,0);
// }
// //模块7 农村建设
// async function getPageData7() {
//     await getPageData(pageData.value[6].cid,2,3,7,0,0,0);
// }
// //模块8 高端资讯
// async function getPageData8() {
//     await getPageData(pageData.value[7].cid,4,0,8,0,0,0);
// }
// 注意，为了保持模块的数量，当前固定为8个
// 所以这里的农业天地，合并了原来是下面的7号模块
// 而原本是7号模块的地方现在变成了8号模块

//3.渲染页面数据 end ---------------------------------------->

//4.设置seo信息 start---------------------------------------->
//4.1 设置seo信息
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: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix , tagPriority: 10 },
            { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix , tagPriority: 10 }
        ]
    });
}else{
    console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
    console.log("错误位置：设置分类页面SEO数据")
    console.log("后端错误反馈：",setData.message)
    console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
}
//4.设置seo信息 end---------------------------------------->
</script>

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