<template>
  <div class="simple-search">
    <input
      type="text"
      :placeholder="placeholder"
      v-model="inputVal"
      @input="(e) => $emit('input', e.target.value)"
      @keyup.enter="$emit('search', inputVal)"
    />
  </div>
</template>

<script>
export default {
  model: {
    prop: 'value',
    event: 'input',
  },
  props: {
    value: {
      type: String,
      default: '',
    },
    placeholder: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      inputVal: '',
    }
  },
}
</script>

<style scoped lang="scss">
@media screen and (min-width: 768px) {
  .simple-search {
    &::before {
      content: '';
      display: block;
      background: url(https://static.caimei365.com/www/authentic/h5/icon-search.png)
        no-repeat center;
      width: 30px;
      height: 30px;
      position: absolute;
      background-size: 26px;
      top: 50%;
      left: 6px;
      transform: translateY(-50%);
      z-index: 9;
    }

    input {
      position: relative;
      display: block;
      width: 560px;
      height: 40px;
      background: rgba(255, 255, 255, 0.39);
      border-radius: 4px;
      outline: none;
      font-size: 16px;
      line-height: 40px;
      border: 0;
      padding-left: 44px;
      box-sizing: border-box;
      color: #fff;

      &::placeholder {
        color: #ddd;
      }
    }
  }
}
@media screen and (max-width: 768px) {
  .simple-search {
    width: 92vw;
    height: 9.6vw;
    box-shadow: 0px 0.4vw 1vw rgba(51, 51, 51, 0.08);
    padding-left: 9.6vw;
    padding-right: 1.6vw;
    left: 50%;
    top: 0;
    background-color: #fff;
    border-radius: 0.4vw;
    &::before {
      content: '';
      display: block;
      background: url(https://static.caimei365.com/www/authentic/h5/icon-search.png)
        no-repeat;
      width: 6.4vw;
      height: 6.4vw;
      position: absolute;
      background-size: 6.4vw;
      left: 1.6vw;
      top: 1.6vw;
    }

    input {
      display: block;
      width: 100%;
      height: 9.6vw;
      line-height: 9.6vw;
      outline: none;
    }
  }
}
</style>
