SearchBox.vue 1.71 KB
<template>
  <div class="search-box flex">
    <van-search
      v-model="keyword"
      placeholder="输入客户姓名搜索"
      @search="onSearch"
    />
    <van-dropdown-menu active-color="#5850ff">
      <van-dropdown-item
        v-model="value"
        :options="option"
        @change="change"
      />
      <div class="arrow y-center">
        <div class="sprite-icon icon-down"></div>
      </div>
    </van-dropdown-menu>
  </div>
</template>

<script type='text/ecmascript-6'>
export default {
  name: 'SearchBox',
  props: ['keyword'],
  data () {
    return {
      value: 0,
      option: [
        { text: '优惠券', value: 0 },
        { text: '精品礼券', value: 1 }
      ]
    }
  },
  mounted () {
  },
  methods: {
    change (e) {
      this.$emit('change', e)
    },
    onSearch (e) {
      this.$emit('search', e)
    }
  }
}
</script>

<style  lang='scss'>
.search-box {
  height: 50px;
  background: #fff;
  box-shadow: 0px 1px 0px 0px #e9e9e9;
  padding-right: 16px;
  position: relative;

  .van-search {
    width: 263px;
    padding: 4.5px 8px;
    height: 100%;
    background: #fff;
    .van-search__content {
      background-color: #fff;
      border: 1px solid #cdd1d4;
      border-radius: 16px;
    }
  }
  .van-dropdown-menu {
    margin-left: auto;
    .arrow {
      right: 8px;
      z-index: 998;
    }
    .van-dropdown-menu__bar--opened ~ .arrow .sprite-icon {
      transform: rotate(-180deg);
      transition: all 0.25s;
    }
    .van-dropdown-menu__bar {
      background-color: #fff;
      box-shadow: none;
      .van-dropdown-menu__title {
        color: #545454 !important;
        font-size: 16px;

        &::after {
          display: none;
        }
      }
    }
  }
}
</style>