<script setup lang="ts">
    import HeaderCom from '../layout/header.vue'
    import FooterInfo from '../components/FooterInfo/index.vue'
    import { useRouter } from 'vue-router'
    import $bus from '@/utils/bus'

    const route = useRoute()
    const router = useRouter()
    // 判断是否是个人中心页面 如果是则隐藏页脚
    const isMyInfoPage = () => {
        if (route.path.indexOf('myuser') === -1) {
            return true
        } else {
            return false
        }
    }

    // 搜索查询绑定值
    const keywordIptValue = ref('')

    // 输入框下方历史搜索记录
    const searchHistoryList = ref([
        { name: '220E履带挖掘机' },
        { name: '3443挖掘机' },
        { name: '塔式起重机' },
        { name: '轮式牵引铲运机' }
    ])

    // 搜索按钮
    const searchKeywordBtn = (e) => {
        if (route.path == '/equipList') {
            $bus.emit('search', keywordIptValue.value)
        } else {
            router.push({
                name: 'equipList',
                state: { keyWord: keywordIptValue.value }
            })
        }
    }

    // 点击下方搜索记录时
    const handleHistory = (hisValue: any) => {
        keywordIptValue.value = hisValue
    }
    //页面刷新回显模糊搜索词
    $bus.on('callBackText', (val) => {
        nextTick(() => {
            keywordIptValue.value = val
        })
    })
</script>

<template>
    <HeaderCom />

    <div class="container">
        <RouterView />
    </div>
    <FooterInfo v-if="isMyInfoPage()" />
</template>

<style scoped lang="scss">
    .container {
        width: 1200px;
        margin: 0 auto;
        overflow: hidden;
        background: #ffffff;
        border-radius: 30px;
        padding: 20px 30px;
        box-sizing: border-box;
    }
</style>
