<template>
    <div id="newsList">
        <!-- 页面头部 -->
        <HomePageHead></HomePageHead>

        <!-- 导航栏 -->
        <HomePageNavigation></HomePageNavigation>

        <!-- 列表页广告一 -->
        <HomeAdvertising :imgurl="adImg1" v-if="adImg1"></HomeAdvertising>

        <!-- 二级标题-->
        <HomeListSecondaryHeadingZgzp v-if="parent_name != ''" :name="parent_name" :nav="secondNav"
            :pinyin="parent_pinyin">
        </HomeListSecondaryHeadingZgzp>

        <main class="index_main">
            <!-- 三农资讯网-招工招聘-社会招聘 snzx_society -->
            <section class="index_2">

                <!-- 职位搜索 -->
                <div class="recruit_head_box clearfix phone_none">
                    <div class="cruit_head_left">
                        <span class="cruit_head_a cruit_head_only">职位搜索</span>
                    </div>
                    <div class="cruit_head_right clearfix">
                        <span class="cruit_head_right_a" @click="createResume"
                            v-if="job_search == 1 && type_id == 1">创建个人简历</span>
                        <!-- <span class="cruit_head_right_a" @click="createJob"
                            v-if="job_search == 1 && type_id == 3">发布招聘信息</span> -->
                    </div>
                </div>


                <form class="phone_form clearfix pc_none" action=" " method=" ">

                    <div class="phone_form_tip phone_form_tip_1 clearfix">
                        
                        <el-select v-model="industry_category" placeholder="全部" style="width:32%" clearable
                                    @change="hyChange">
                                    <el-option v-for="item in industry_categoryList" :key="item.hyid"
                                        :label="item.hyname" :value="item.hyid" />
                        </el-select>

                        <el-select v-model="position_category" placeholder="全部" style="width:32%" clearable
                                    @change="zwChange">
                                    <el-option v-for="item in position_categoryList" :key="item.zwid"
                                        :label="item.zwname" :value="item.zwid" />
                        </el-select>
                        <el-select v-model="position" placeholder="全部" style="width:32%" clearable
                                    no-data-text="请先选择职位类别" @change="jtzwChange">
                                    <el-option v-for="item in positionList" :key="item.zwid" :label="item.zwname"
                                        :value="item.zwid" />
                        </el-select>
 
                    </div>

                    <div class="phone_form_tip phone_form_tip_2 clearfix">
                       
                        <el-select v-model="province" placeholder="省" style="width:15%" clearable
                                    @change="provinceChange">
                                    <el-option v-for="item in provinceList" :key="item.id" :label="item.name"
                                        :value="item.id" />
                        </el-select>

                        <el-select v-model="city" placeholder="市" style="width:15%" no-data-text="选省"
                            clearable @change="cityChange">
                            <el-option v-for="item in cityList" :key="item.id" :label="item.name"
                                :value="item.id" />
                        </el-select>
                        
                        <el-input v-model="keywords" 
                            style="width: 51%" 
                            placeholder="请输入搜索关键词" clearable>
                        </el-input>

                        <el-button type="" style="width: 13%"  @click="goSearch">搜索</el-button>
                    </div>

                    <div class="phone_form_tip clearfix">
                    </div>

                </form>


                <form class="cruit_form clearfix phone_none" action=" " method=" ">
                    <div class="society_form_tip clearfix">
                        <label class="society_form_label">行业类别：</label>
                        <div class="society_form_right_a_box clearfix">
                            <a class="society_form_right_a"
                                :class="{ society_form_right_a_only: hyid == '' || !hyid || hyid == 0 }" title="全部"
                                @click="hyChange(0)">
                                全部
                            </a>
                            <NuxtLink v-for="(item, index) in industry_categoryList" :key="item">
                                <span class="society_form_right_a"
                                    :class="{ society_form_right_a_only: item.hyid == hyid }" :title="item.hyname"
                                    @click="hyChange(item.hyid)" v-if="index < 20 && hyIndex == 1">{{ item.hyname
                                    }}</span>
                                <span class="society_form_right_a" v-if="hyIndex == 2" @click="hyChange(item.hyid)"
                                    :class="{ society_form_right_a_only: item.hyid == hyid }" :title="item.hyname">
                                    {{ item.hyname }}
                                </span>
                            </NuxtLink>
                            <span class="society_form_right_btn" @click="hyIndex = 2" v-if="hyIndex == 1">展开</span>
                            <span class="society_form_right_btn" @click="hyIndex = 1" v-if="hyIndex == 2">收起</span>
                        </div>
                    </div>
                    <div class="society_form_tip clearfix">
                        <label class="society_form_label">职位类别：</label>
                        <div class="society_form_right_a_box clearfix">
                            <a class="society_form_right_a"
                                :class="{ society_form_right_a_only: zwid == '' || !zwid || zwid == 0 }" title=""
                                @click="zwChange(0)">全部</a>
                            <span v-for="(item, index) in position_categoryList" :key="item">
                                <span class="society_form_right_a" v-if="index < 20 && zwIndex == 1"
                                    @click="zwChange(item.zwid)"
                                    :class="{ society_form_right_a_only: item.zwid == zwid }" :title="item.zwname">
                                    {{ item.zwname }}
                                </span>
                                <span class="society_form_right_a" v-if="zwIndex == 2" @click="zwChange(item.zwid)"
                                    :class="{ society_form_right_a_only: item.zwid == zwid }" :title="item.zwname">
                                    {{ item.zwname }}
                                </span>
                            </span>
                            <span class="society_form_right_btn society_form_right_btn_up" @click="zwIndex = 2"
                                v-if="zwIndex == 1">展开</span>
                            <span class="society_form_right_btn society_form_right_btn_up" @click="zwIndex = 1"
                                v-if="zwIndex == 2">收起</span>
                        </div>
                    </div>
                    <div class="society_form_tip clearfix">
                        <label class="society_form_label">具体职位：</label>
                        <div class="society_form_right_a_box clearfix">
                            <a class="society_form_right_a" @click="jtzwChange(0)"
                                :class="{ society_form_right_a_only: jtzwid == '' || !jtzwid || jtzwid == 0 }"
                                title="">全部</a>
                            <span v-for="(item, index) in positionList" :key="item">
                                <span class="society_form_right_a" v-if="index < 20 && jtzwIndex == 1"
                                    @click="jtzwChange(item.zwid)"
                                    :class="{ society_form_right_a_only: item.zwid == jtzwid }" :title="item.zwname">
                                    {{ item.zwname }}
                                </span>
                                <span class="society_form_right_a" v-if="jtzwIndex == 2" @click="jtzwChange(item.zwid)"
                                    :class="{ society_form_right_a_only: item.zwid == jtzwid }" :title="item.zwname">
                                    {{ item.zwname }}
                                </span>
                            </span>
                            <!-- <span class="society_form_right_btn">展开</span> -->
                            <span class="society_form_right_btn" @click="jtzwIndex = 2" v-if="jtzwIndex == 1">展开</span>
                            <span class="society_form_right_btn" @click="jtzwIndex = 1" v-if="jtzwIndex == 2">收起</span>
                        </div>
                    </div>
                    <div class="cruit_form_tip clearfix">
                        <div class="cruit_form_per">
                            <label class="cruit_form_label">地区选择：</label>
                            <div class="cruit_form_label_right clearfix">
                                <el-select v-model="province" placeholder="请选择省" style="width: 140px" clearable
                                    @change="provinceChange">
                                    <el-option v-for="item in provinceList" :key="item.id" :label="item.name"
                                        :value="item.id" />
                                </el-select>
                                <el-select v-model="city" placeholder="请选择市" style="width: 140px" no-data-text="请先选择省"
                                    clearable>
                                    <el-option v-for="item in cityList" :key="item.id" :label="item.name"
                                        :value="item.id" />
                                </el-select>
                            </div>
                        </div>
                    </div>
                    <div class="cruit_form_tip clearfix">
                        <div class="cruit_form_per">
                            <label class="cruit_form_label">关键词：</label>
                            <div class="cruit_form_label_right clearfix">
                                <el-input v-model="keywords" style="width: 300px" placeholder="请输入搜索关键词" clearable />
                                <el-button type="success" @click="goSearch">搜索</el-button>
                            </div>
                        </div>
                    </div>
                </form>
                <!-- 职位搜索 -->
            </section>
        </main>
        <main class="color_main">
            <main class="index_main">
                <!-- 选项卡头 -->
                <section class="index_3 clearfix">
                    <div class="recruit_head_box clearfix phone_none">
                        <div class="cruit_head_left">
                            <a class="cruit_head_a" :class="{ cruit_head_only: job_search == 1 }"
                                @mouseover="job_search = 1" title="">找工作</a>
                            <!-- <a class="cruit_head_a" :class="{ cruit_head_only: job_search == 2 }"
                                @mouseover="job_search = 2" title="">招人才</a> -->
                        </div>
                        <div class="society_head_right clearfix">
                            <div class="society_head_checkbox_box" v-if="job_search == 1 && type_id == 1">
                                <el-checkbox v-model="allJob" label="" @change="toggleAllJob" />
                            </div>
                            <div class="society_head_right_all_box" v-if="job_search == 1 && type_id == 1">
                                全选
                            </div>
                            <!-- <div class="society_head_checkbox_box" v-if="job_search == 2 && type_id == 3">
                                <el-checkbox v-model="allResume" label="" @change="toggleAllResume" />
                            </div>
                            <div class="society_head_right_all_box" v-if="job_search == 2 && type_id == 3">
                                全选
                            </div> -->
                            <div class="society_head_right_a" title="" v-if="job_search == 1 && type_id == 1"
                                @click="getjob">申请职位</div>
                            <!-- <div class="society_head_right_a" v-if="job_search == 2 && type_id == 3"
                                @click="talkResume">
                                沟通简历</div> -->
                            <!-- resumeBoo = true -->
                        </div>
                    </div>

                    
                    <div class="phone_box_1 pc_none">
                        <div class="phone_box_1_head">
                            <a title="">找工作</a>
                        </div>
                    </div>

                    <!-- 选项卡头 -->
                    <!-- 选项卡 -->
                    <div class=" clearfix">
                        <!-- 找工作 -->
                        <div class=" clearfix" v-show="job_search == 1">
                            <div class="cruit_ul_2 clearfix" v-if="job_vacancy">
                                <div class="cruit_li_2 clearfix" v-for="(item, index) in job_vacancy" :key="item.id">
                                    <div class="society_inp_checkbox_box_li_1 hand" v-if="type_id == 1">
                                        <el-checkbox v-model="selectedJobs" :value="item.id" @change="jobChange" />
                                    </div>
                                    <NuxtLink class="cruit_li_2_a" :href="`/${item.pinyin}/${item.id}.html`" title="">
                                        <div class="cruit_li_2_head_box clearfix">
                                            <div class="cruit_li_2_head clearfix dot1">{{ item.title }}</div>
                                            <div class="cruit_li_2_head_name clearfix dot1">
                                                {{ item.business_name }}
                                            </div>
                                        </div>
                                        <div class="cruit_li_2_foot_title_box clearfix">
                                            <span class="cruit_li_2_foot_title">{{ item.jtzw_name }}</span>
                                        </div>
                                        <div class="cruit_li_2_foot clearfix">
                                            <span class="cruit_li_2_foot_tag cruit_li_2_foot_addres">
                                                {{ item.city_name }}
                                            </span>
                                            <span class="cruit_li_2_foot_tag cruit_li_2_foot_exper"
                                                v-if="item.experience_name || item.education_name">
                                                <span class="cruit_li_2_foot_tag_in">{{ item.experience_name }}</span>
                                                <span class="cruit_li_2_foot_tag_in">{{ item.education_name }}</span>
                                            </span>
                                            <span class="cruit_li_2_foot_tag cruit_li_2_foot_time">
                                                {{ getTime(item.updated_at, 'year', 1) }}
                                            </span>
                                        </div>
                                    </NuxtLink>
                                </div>
                            </div>
                            <div class="pagination pagination_phone_none" v-if="zptotal">
                                <el-pagination size="small" background layout="prev, pager, next" :total="zptotal"
                                    class="mt-4" prev-text="上一页" next-text="下一页" @change="changePage" />
                            </div>

                            
                            <div class="pagination pagination_pc_none" v-if="zptotal">
                                <el-pagination 
                                    pager-count="5"
                                    size="small" 
                                    background 
                                    layout="pager" 
                                    :default-page-size="pageSize"  
                                    :total="zptotal"
                                    class="mt-4"
                                    @current-change="changePage" 
                                />
                            </div>

                            <div class="empty" v-if="job_vacancy == false">
                                <img src="@/public/topic/empty.png" alt="" class="empty_img">
                                <span class="empty_text">当前暂无数据</span>
                            </div>
                        </div>
                        <!-- 找工作 -->
                        <!-- 招人才 -->
                        <!-- <div class=" clearfix" v-show="job_search == 2">
                            <div class="society_ul_3 clearfix" v-if="job_resume">
                                <div class="society_li_3 clearfix" v-for="(item, index) in job_resume" :key="item">
                                    <div class="society_inp_checkbox_box_li_3 hand" v-if="type_id == 3">
                                        <el-checkbox v-model="selectedResume" :value="item.id" @change="jobChange" />
                                    </div>
                                    <NuxtLink class="society_li_3_a" :href="`/${item.pinyin}/${item.id}.html`" title="">
                                        <div class="society_li_3_head_box clearfix">
                                            <div class="society_li_3_head clearfix dot1">
                                                {{ item.name }}
                                            </div>
                                            <div class="society_li_3_head_name clearfix dot1">
                                                {{ item.jtzw_name }}
                                            </div>
                                        </div>
                                        <div class="society_li_3_text_box clearfix">
                                            <div class="society_li_3_text">
                                                {{ item.sexy == 1 ? '男' : '女' }}
                                                <em class="point">·</em>
                                            </div>
                                            <div class="society_li_3_text" v-if="item.experience">
                                                {{ item.experience }}年
                                                <em class="point">·</em>
                                            </div>
                                            <div class="society_li_3_text">
                                                {{ item.origin }}
                                                <em class="point">·</em>
                                            </div>
                                            <div class="society_li_3_text">{{ item.hy_name }}</div>
                                        </div>
                                        <div class="society_li_3_tag_box clearfix">
                                            <span class="society_li_3_tag">{{ item.city_name }}</span>
                                            <span class="society_li_3_tag">
                                                {{ getTime(item.updated_at, 'year', 1) }}
                                            </span>
                                        </div>
                                    </NuxtLink>
                                </div>
                            </div>
                            <div class="pagination" v-if="qztotal">
                                <el-pagination size="small" background layout="prev, pager, next" :total="qztotal"
                                    class="mt-4" prev-text="上一页" next-text="下一页" @change="changePage" />
                            </div>
                            <div class="empty" v-if="job_resume == false">
                                <img src="@/public/topic/empty.png" alt="" class="empty_img">
                                <span class="empty_text">当前暂无数据</span>
                            </div>
                        </div> -->
                        <!-- 招人才 -->
                    </div>
                    <!-- 选项卡 -->
                </section>
                <!-- 招聘职位 -->
                <!-- <div class="cruit_alert_box">投递成功</div> -->
            </main>
            <!-- 弹框 -->
            <section class="cruit_alert_rgb clearfix" v-if="resumeBoo">
                <!-- 请选择要沟通的职位1 -->
                <!-- <div class="cruit_alert_rgb_box">
                    <div class="cruit_alert_rgb_head_box">
                        <div class="cruit_alert_rgb_close hand back100"></div>
                        <div class="cruit_alert_rgb_head">请选择要沟通的职位</div>
                    </div>
                    <form class="cruit_alert_rgb_form clearfix" action=" " method=" ">
                        <div class="cruit_alert_rgb_form_in clearfix">
                            <div class="cruit_alert_rgb_li clearfix" v-for="(item, index) in 17" :key="item.id">
                                <input name="type" type="checkbox" value="" class="cruit_alert_rgb_checkbox hand" />
                                <label
                                    class="cruit_alert_rgb_label dot1">高级PHP工程HP工程HP工程HP工程HP工程HP工程HP工程HP工程HP工程HP工程HP工程HP工程HP工程HP工程HP工程HP工程师</label>
                            </div>
                        </div>
                        <div class="cruit_alert_rgb_foot clearfix">
                            <input class="cruit_alert_rgb_foot_sub hand" name="" type="submit" value="沟通职位">
                        </div>
                    </form>
                </div> -->
                <!-- 请选择要沟通的职位2 -->
                <!-- 请选择要投递的简历1 -->
                <div class="cruit_alert_rgb_box">
                    <div class="cruit_alert_rgb_head_box">
                        <div class="cruit_alert_rgb_close hand back100"></div>
                        <div class="cruit_alert_rgb_head">请选择要沟通的岗位
                            <span class="close" @click="resumeBoo = false">x</span>
                        </div>

                    </div>
                    <form class="cruit_alert_rgb_form clearfix" action=" " method=" ">
                        <div class="cruit_alert_rgb_form_in clearfix">
                            <div class="cruit_alert_rgb_li clearfix" v-for="(item, index) in companyJobList"
                                :key="item.id">
                                <!-- <el-checkbox v-model="company_job" :value="item.id" @change="jobChange" /> -->
                                <el-radio :value="item.id" v-model="company_job" @change="jobChange">
                                    <div class="cruit_alert_rgb_label dot1">
                                        {{ item.title }}
                                    </div>
                                </el-radio>
                            </div>
                        </div>
                        <div class="cruit_alert_rgb_foot clearfix">
                            <div class="cruit_alert_rgb_foot_sub hand" @click="getresume">沟通岗位</div>
                        </div>
                    </form>
                </div>
                <!-- 请选择要投递的简历2 -->
            </section>
        </main>
        <!-- 页面底部 -->
        <HomeFoot1></HomeFoot1>
    </div>
</template>

<script setup>
//1.页面必备依赖 start ---------------------------------------->
import { ElSelect, ElOption, ElInput, ElButton, ElPagination, ElCheckbox, ElRadio, ElMessage } from 'element-plus';
import { ref, onMounted } from 'vue';
import { useRoute } from 'vue-router'

const nuxtApp = useNuxtApp();
const axios = nuxtApp.$axios;


//当前列表名称
const name = ref('')
const selectedJobs = ref([])
const selectedResume = ref([])
const company_job = ref('')
const allJob = ref(false)
const allResume = ref(false)
const cruit_ul_1_a_only_num = ref(0)
const job_search = ref(1)   // 选项卡
const { $webUrl, $CwebUrl, $BwebUrl } = useNuxtApp()


//获取用户信息
let type_id = ref('')
let website_id = ref('')
let getUserInfo = () => {
    axios.get("/user/getUserInfo").then(response => {
        console.log("gettypeid", response.data);
        type_id.value = response.data.type_id
        website_id.value = response.data.website_id
    })
}
onMounted(() => {
    getUserInfo()
})
//1.页面必备依赖 end ---------------------------------------->

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

const hyid = ref(route.query.hyid);
const zwid = ref(route.query.zwid);
const jtzwid = ref(route.query.jtzwid);
const provinceid = ref(route.query.provinceid);
const cityid = ref(route.query.cityid);
const keyword = route.query.keywords;



let articleId = 0;//路由id
let pageNum = ref(2);
let total = ref(0);
let zptotal = ref(0);
let qztotal = ref(0);
const page = ref(1)
const pageSize = ref(10);
let hyIndex = ref(1);
let zwIndex = ref(1);
let jtzwIndex = ref(1);

//获得当前的完整路径
const fullPath = route.path;
//拆分，取出来中间这一段，然后提取数字部分
const segments = fullPath.split('/');
const targetSegment = segments[2];
const targetRoute = segments[1];
// console.log('111222', targetRoute);


//const numberPart = targetSegment.match(/\d+$/)?.[0]; 
//let routeId = 20 //排除路径错误可以打开这个
//articleId = numberPart;

//通过导航路径反向查询导航id
const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
    method: 'GET',
    query: {
        'pinyin': targetRoute,
    },
});
// console.log("111222333", getRouteId);

if (getRouteId.code == 200) {
    articleId = 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 ---------->")
}
//获得html前的数字
// const pageUrl = segments[3]; 
// const pageNumber = pageUrl.split('.')[0];
// console.log("当前URL中的页码：")
// console.log(pageNumber)//2
// pageNum.value = parseInt(pageNumber);
pageNum.value = parseInt(route.params.id);
// 创建个人简历
let createResume = () => {
    window.open($BwebUrl + '/#/addJobHunting', '_blank');
}
// 发布招聘信息
let createJob = () => {
    window.open($BwebUrl + '/#/creatJob', '_blank');
}
//1.获得路由id end ---------------------------------------->

//2.页面数据 start ---------------------------------------->
// 2.1.1 获取省份
const province = ref('')  //省
const city = ref('')  //市
const provinceList = ref([])  //省列表
const cityList = ref([])  //市列表
const getArea = await requestDataPromise('/web/selectWebsiteArea', {
    method: 'GET',
    query: {},
});
if (getArea.code == 200) {
    provinceList.value = getArea.data;
}


// 2.1.2 
// 获取省份和城市
const provinceChange = (val) => {
    provinceid.value = val;
    city.value = '';
    console.log('获取到的省份id', val);
    getCity(val)
}
const getCity = async (value) => {
    const getCity = await requestDataPromise('/web/selectWebsiteArea', {
        method: 'GET',
        query: {
            'pid': value,
        },
    });
    if (getCity.code == 200) {
        cityList.value = getCity.data;
    }
}
// 带参数跳转 省份和城市的回显问题
if (provinceid.value) {
    for (let i = 0; i < provinceList.value.length; i++) {
        if (provinceList.value[i].id == provinceid.value) {
            province.value = provinceList.value[i].id;
        }
    }
    const getCity = await requestDataPromise('/web/selectWebsiteArea', {
        method: 'GET',
        query: {
            'pid': provinceid.value,
        },
    });
    if (getCity.code == 200) {
        cityList.value = getCity.data;
    }
    if (cityid.value) {
        for (let i = 0; i < cityList.value.length; i++) {
            if (cityList.value[i].id == cityid.value) {
                city.value = cityList.value[i].id;
            }
        }
    }
}


// 2.2.1 行业和职位
const keywords = ref('')  //关键词
const industry_categoryList = ref([])  //行业类别列表
const position_categoryList = ref([])  //职位类别列表
const positionList = ref([])  //具体职位列表

const getData = async () => {
    const getData = await requestDataPromise('/web/getWebsiteJobSelect', {
        method: 'GET',
        query: {},
    });
    if (getData.code == 200) {
        // console.log("获取到的分类数据：", getData.data);
        industry_categoryList.value = getData.data.hy; //行业
        position_categoryList.value = getData.data.zw; //职位
        if (zwid.value == 0 || zwid.value == '' || zwid.value == undefined || zwid.value == null) {
            positionList.value = getData.data.jtzw; //具体职位
        }

    }
}
getData()

const job_vacancy = ref('') // 招聘岗位
const job_resume = ref('') // 简历
if (keyword) {
    keywords.value = keyword
}
const getJob = async () => {
    const getJob = await requestDataPromise('/web/getWebsiteJobList', {
        method: 'GET',
        query: {
            'catid': articleId,
            'city_id': provinceid.value,
            'hy_id': hyid.value,
            'zw_id': zwid.value,
            'jtzw_id': jtzwid.value,
            'page': page.value,
            'pageSize': pageSize.value,
            'keyword': keywords.value,
        },
    });
    if (getJob.code == 200) {
        // console.log("获取到的岗位和简历：", getJob.data);
        job_vacancy.value = getJob.data.JobRecruiting; // 招聘岗位
        job_resume.value = getJob.data.JobHunting; // 简历
        zptotal.value = getJob.data.recruit_count;
        qztotal.value = getJob.data.hunt_count;
    }
}
getJob()

let hyChange = (val) => {
    console.log('hyChange', val)
    hyid.value = val;
    getJob()
}
let zwChange = async (val) => {
    console.log('zwChange', val)
    zwid.value = val;
    const getPosition = await requestDataPromise('/web/getPositionList', {
        method: 'GET',
        query: {
            'zwpid': val,
        },
    })
    console.log("11112222", getPosition);

    if (getPosition.code == 200) {
        positionList.value = getPosition.data; //具体职位 
    } else {
        positionList.value = []; //具体职位
        jtzwid.value = 0; //职位id
    }
    getJob()
}
let jtzwChange = (val) => {
    console.log('jtzwChange', val)
    jtzwid.value = val;
    getJob()
}

// 搜索
const goSearch = async () => {
    const getJob = await requestDataPromise('/web/getWebsiteJobList', {
        method: 'GET',
        query: {
            'catid': articleId,
            'city_id': provinceid.value,
            'hy_id': hyid.value,
            'zw_id': zwid.value,
            'jtzw_id': jtzwid.value,
            'page': page.value,
            'pageSize': pageSize.value,
            'keyword': keywords.value,
        },
    });
    console.log("111获取到的岗位和简历：", getJob.data);

    if (getJob.code == 200) {
        job_vacancy.value = getJob.data.JobRecruiting; // 招聘岗位
        job_resume.value = getJob.data.JobHunting; // 简历
        zptotal.value = getJob.data.recruit_count;
        qztotal.value = getJob.data.hunt_count;
    }
}

//2.2change事件
let jobChange = (val) => {
    console.log('jobChange', val)
    console.log('jobChange111', selectedJobs.value)
    console.log('jobChange111', selectedResume.value)
    console.log('jobChange11122', company_job.value) //企业会员的职位
    if (selectedJobs.value.length == job_vacancy.value.length) {
        allJob.value = true;
    } else {
        allJob.value = false;
    }
    if (selectedResume.value.length == job_resume.value.length) {
        allResume.value = true;
    } else {
        allResume.value = false;
    }
}
let toggleAllJob = () => {
    if (allJob.value) {
        selectedJobs.value = job_vacancy.value.map(item => item.id);
    } else {
        selectedJobs.value = [];
    }
}

let toggleAllResume = () => {
    if (allResume.value) {
        selectedResume.value = job_resume.value.map(item => item.id);
    } else {
        selectedResume.value = [];
    }
}


//分页事件
let changePage = (value) => {
    console.log("当前页码", value);
    navigateTo(`/${targetSegment}/${value}.html`)
}

//申请职位
let getjob = () => {
    if (selectedJobs.value.length == 0) {
        ElMessage({
            message: '请选择要申请的职位',
            type: 'warning',
        });
    } else {
        console.log("获取到的11111_sel：", selectedJobs.value);
        console.log("获取到的1111_website_id：", website_id.value);
        axios.post('/web/getWebsiteJobApply', {
            'website_id': website_id.value,
            'recruit_id': selectedJobs.value,
        }).then(response => {
            console.log("获取到的申请结果：", response.data);
            if (response.code == 200) {
                ElMessage({
                    message: '投递成功',
                    type: 'success',
                });
            } else {
                ElMessage({
                    message: response.message,
                    type: 'error',
                });
            }
            allJob.value = false;
            selectedJobs.value = [];
        })
    }

}
//沟通简历
let talkResume = () => {
    if (selectedResume.value.length == 0) {
        ElMessage({
            message: '请选择要沟通的简历',
            type: 'warning',
        });
        return false;
    } else {
        resumeBoo.value = true;
    }
    // resumeBoo.value = true;

}
//获取当前企业会员的职位
const companyJobList = ref([])
let companyJOb = async () => {
    const companyJOb = await requestDataPromise('/web/getWebsiteJobRecruiting', {
        method: 'POST',
        body: {
            'pageSize': pageSize.value,
            'website_id': website_id.value,
        }
    })
    // console.log("获取到的企业会员的职位11：", companyJOb.data);
    if (companyJOb.code == 200) {
        // console.log("获取到的企业会员的职位：", companyJOb.data);
        companyJobList.value = companyJOb.data
    }
}
companyJOb()

// 沟通简历
let resumeBoo = ref(false)
let getresume = async () => {
    const resumelist = await requestDataPromise('/web/getWebsiteJobResume', {
        method: 'POST',
        body: {
            'website_id': website_id.value,
            'recruit_id': company_job.value,
            'hunt_id': selectedResume.value,
        },
    });

    // console.log("沟通简历00", resumelist);
    // console.log("沟通简历11", website_id.value);
    // console.log("沟通简历22", company_job.value);
    // console.log("沟通简历33", selectedResume.value);
    if (resumelist.code == 200) {
        ElMessage({
            message: '投递成功',
            type: 'sussess',
        });
        resumeBoo.value = false;
    } else {
        ElMessage({
            message: resumelist.message,
            type: 'error',
        });
        resumeBoo.value = false;
    }
    company_job.value = '';
    selectedResume.value = [];
    job_search.value = 2
}



// //2.3获得页面名称
// let getPageName = async () => {
//     const pageName = await requestDataPromise('/web/getOneWebsiteCategory', {
//         method: 'GET',
//         query: {
//             'catid': articleId
//         },
//     });
//     console.log('11122233344',pageName);

//     if (pageName.code == 200) {
//         name.value = pageName.data.alias
//     } else {
//         console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
//         console.log("错误位置：设置页面标题")
//         console.log("后端错误反馈：", pageName.message)
//         console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
//     }
// }
// //获得列表
// getPageName();
//2.页面数据 end ---------------------------------------->


//3.二级栏目 start ---------------------------------------->
//3.1通过id获取一级栏目
const parent_name = ref([]);
const parent_id = ref([]);
const parent_pinyin = ref("");
let getParentNav = async () => {
    const listData = await requestDataPromise('/web/getOneWebsiteCategory', {
        method: 'GET',
        query: {
            'catid': articleId
        },
    });
    // console.log("1112223334455", listData.data);

    if (listData.code == 200) {
        // console.log(111999)
        console.log(listData.data);
        parent_name.value = listData.data.alias;
        parent_id.value = listData.data.category_id;
        parent_pinyin.value = listData.data.aLIas_pinyin;
    } else {
        console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
        console.log("错误位置：获取新闻列表")
        console.log("后端错误反馈：", listData.message)
        console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
    }
    getSecondNav();
}
//获得父级栏目详情
getParentNav();

// 3.2获取二级栏目
const secondNav = ref([]);
let getSecondNav = async () => {
    const listData = await requestDataPromise('/web/getWebsiteModelCategory', {
        method: 'GET',
        query: {
            'placeid': 1,
            'pid': parent_id.value,
            'num': 8,
        },
    });
    console.log('listData', listData);

    if (listData.code == 200) {
        secondNav.value = listData.data;
    } else {
        console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
        console.log("错误位置：获取新闻列表")
        console.log("后端错误反馈：", listData.message)
        console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
    }
}
//3.二级栏目 end ---------------------------------------->

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

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 + "_" + seoName + "_" + seoSuffix,
        meta: [
            { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
            { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
            { name: 'viewport', content: 'width=device-width,initial-scale=1,user-scalable=no',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---------------------------------------->


//5.广告 start---------------------------------------->
let adImg1 = ref({});
let adImg2 = ref({});

onMounted(async () => {

    //从客户端获取行政职能部门 加快打开速度
    const { $webUrl, $CwebUrl } = useNuxtApp();
    //广告1
    let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nmgw_search_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=nmgw_list_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---------------------------------------->
</script>

<style lang="less" scoped>
@import url('@/assets/css/zgzpsearch.less');

.empty {
    width: 100%;
    height: 150px;
    line-height: 150px;
    text-align: center;
}

.empty_img {
    vertical-align: -30px;
    margin-right: 20px;
}

.empty_text {
    font-size: 26px;
    color: #999;
}
</style>


<style lang="less" scoped>

     @media screen and (min-width:801px){/*pc*/
         
            .pagination_pc_none{display:none;}
            .pc_none{display:none;}
    }
    @media screen and (max-width:800px){/*ipad_phone*/
        
            .index_main{width:100%;margin-top:0px;}
            .index_3{margin-top:0px;}
            .color_main{margin-bottom:30px;}    

				.phone_box_1 {
					width: 92%;
					margin: 0px auto 0px;
					.phone_box_1_head {

						height: 50px;
						line-height: 50px;
						background: #fff;
						border-bottom: 1px solid #E6E6E6;
						width: 100%;
						a {
							float: left;
							height: 50px;
							line-height: 50px;
							margin: 0;
							position: relative;
							color: #489d97;
							font-size: 18px;
							font-weight: bold;
							box-sizing: border-box;
							position: relative;
							padding-left: 8px;
						}
						a::before {
							content: '';
							display: block;
							position: absolute;
							left: 0px;
							top: 18px;
							background: linear-gradient(to top, #0998A9, #6ADDD6);
							width: 3px;
							height: 15px;
						}
					}   
				}
				 
				
        .phone_form{
            width:92%; 
            margin: 5px auto 0px;
            padding-bottom:8px;
             
        }

        .phone_form_tip{ 
        }

        .phone_form_tip_1 :deep(.el-select){
            margin:0px;
          
        }
        .phone_form_tip_1 :deep(.el-select:nth-of-type(2)){
            margin:0px 2%;
            box-sizing:border-box;
        }

        :deep(.el-select__wrapper){
             margin:5px 0px; padding:4px 4px 4px 8px;  
             font-size:12px;box-sizing:border-box;
             
        }

        .phone_form_tip_2 :deep(.el-select){
             margin-right:2%; 
        }
        
        :deep(.el-input){
          font-size:12px;
        }
        :deep(.el-button){
              border:solid 1px #ddd;
           color:#fff;float:right;margin:5px 0px 0px 0px;
           font-size:12px;
        }
        .phone_form{
            width:92%; 
            margin: 5px auto 0px;
            padding-bottom:8px;
             
        }

        .phone_form_tip{ 
        }

        .phone_form_tip_1 :deep(.el-select){
            margin:0px;
          
        }
        .phone_form_tip_1 :deep(.el-select:nth-of-type(2)){
            margin:0px 2%;
            box-sizing:border-box;
        }

        :deep(.el-select__wrapper){
             margin:5px 0px; padding:4px 4px 4px 8px;  
             font-size:12px;box-sizing:border-box;
             
        }

        .phone_form_tip_2 :deep(.el-select){
             margin-right:2%; 
        }
        
        :deep(.el-input){
          font-size:12px;
        }
        :deep(.el-button){
              border:solid 1px #ddd;
           color:#fff;float:right;margin:5px 0px 0px 0px;
           font-size:12px;
        }

        .phone_form_tip_1:deep(.el-select__placeholder.is-transparent){color:#000;}

        .cruit_ul_2{margin-top:11px;min-height:512px;}
        .cruit_li_2{
            width:92%;float:none!important;margin:0px auto 11px!important;  
                   
        }

        .cruit_li_2_head_box{margin-top:10px;}
         
        .cruit_li_2_foot_title{margin-top:10px;}
        .cruit_li_2_foot{margin-top:10px;margin-left:0px;}
        .cruit_li_2_a{padding-bottom:5px;}
        .cruit_li_2_foot_tag{
             background-size: 16px 70%;
             padding-left:18px;margin-bottom:5px;font-size:12px;
             margin-right:13px;

        }
        .cruit_li_2_foot_tag:nth-last-of-type(1){margin-right:0px;}


        .cruit_li_2_foot_tag_in{font-size:12px;}
        .cruit_li_2_foot_tag_in:nth-of-type(2){padding-left:16px;}
        .cruit_li_2_foot_tag_in:nth-of-type(2)::after {
                left: 8px;
            }    


        .cruit_li_2_head{font-size:18px;margin-left:0px;}
        .cruit_li_2_head_name{margin-right:0px;}
        .cruit_li_2_foot_title{font-size:12px;margin-left:0px;}

        :deep(.pagination .el-pagination.is-background .el-pager li){ margin:0px 4px;}


        .pagination{width:100%;margin-bottom:0px;}
        .pagination_phone_none{display:none;}

            .phone_none{display:none;}
    }
</style>
