indexSearch_en.vue 2.41 KB
<template>
  <el-dialog
    v-model="show" class="searchpp" width="80vw" append-to-body title="SEARCH"
    top="80px"
    destroy-on-close :show-close="true" :close-on-click-modal="true" :modal="false"
  >
    <div class="searchBody">
      <div class="searchline">
        <el-input v-model="query.name" placeholder="请输入关键词搜索" @change="search" />
        <el-button :icon="Search" @click="search">search</el-button>
      </div>
      <h2>近期热门</h2>
      <el-row class="newsimgcover" :gutter="20">
        <el-col v-for="(n,index) in hottest" v-show="index<4" :key="index" :span="6">
          <div class="item shadow" @click="goDetail(n)">
            <div class="imgbox"><img :src="fillImgUrl_webSite(n.picUrl)"></div>
            <h3 class="esp">{{ n.name }}</h3>
          </div>
        </el-col>
      </el-row>

    </div>
  </el-dialog>
</template>

<script setup>
import { onMounted, ref } from 'vue'
import { Search } from '@element-plus/icons-vue'
const router = useRouter()
import { getHottest } from '@/apiPc/webSite'
import { useRouter } from 'vue-router'

const show = ref(false)
const query = ref({})
const hottest = ref([])
const open = (params) => {
  show.value = true
  getHotList()
}
defineExpose({
  open
})

function getHotList() {
  getHottest().then(res => {
    hottest.value = res.data
  })
}

function search() {
  show.value = false
  router.push({
    path: `/search`,
    query: {
      name: query.value.name
    }
  })
}
const goDetail = (n) => {
  show.value = false
  if (n.isOut == '1') {
    window.open(n.jumpUrl)
  } else {
    router.push({
      path: `/news/detail/${n.noteId}`
    })
  }
}
</script>

<style scoped lang="scss">
h2 {
  font-size: 24px;
  margin: 30px 0 15px;
}

.hotword {
  margin: 0;
  font-size: 18px;
  color: #7B7F83;

  span {
    margin-right: 20px;
    cursor: pointer;

    &:hover {
      text-decoration: underline;
    }
  }
}

.searchBody {
  padding: 0 0 60px
}

.searchline {
  display: flex;
  height: 60px;
  margin: 30px 0;
  background: #F8F8F8;

  .el-input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 18px;
  }

  .el-button {
    width: 130px;
    font-size: 20px;
    border: none;
    height: 60px;
    color: #fff;
    background: linear-gradient(-90deg, #8623FC, #453DEA);;
    border-radius: 0px 5px 5px 0px;
  }

  :deep(.el-input__wrapper) {
    background-color: transparent;
    box-shadow: none;
  }
}
</style>