<template>
  <div class="page">
    <div class="page-top flex flex-col justify-center items-center">
      <img class="logo" :src="supplierInfo.logo" />
      <div class="mt-2 name">
        <span v-text="supplierInfo.shopName"></span><span>官方授权设备</span>
      </div>
    </div>
    <div class="page-content">
      <div class="title">SN码或机构名称：</div>
      <el-input
        placeholder="请输入设备SN码或机构名称搜索查询"
        v-model="keyword"
        class="input-with-select"
      >
        <el-select
          v-model="type"
          slot="prepend"
          placeholder="请选择"
          class="select-with-input"
        >
          <el-option label="SN码" value="1"></el-option>
          <el-option label="机构名" value="2"></el-option>
        </el-select>
        <i slot="prefix" class="el-input__icon el-icon-search"></i>
      </el-input>
      <div class="button flex justify-center items-center" @click="onSearch">
        查询
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  layout: 'app-ross',
  data() {
    return {
      keyword: '',
      type: '1',
    }
  },
  computed: {
    ...mapGetters(['supplierInfo', 'authUserId', 'routePrefix']),
  },
  methods: {
    onSearch() {
      if (!this.keyword) {
        this.$toast('请输入要查询的内容')
        return
      }
      this.$router.push(
        `${this.routePrefix}/approve/device/list?type=${
          this.type
        }&keyword=${encodeURIComponent(this.keyword)}&id=${
          this.$route.query.id
        }`
      )
    },
  },
}
</script>

<style scoped lang="scss">
.el-input {
  & > ::v-deep {
    .el-input.is-active .el-input__inner,
    .el-input__inner:focus {
      @include themify($themes) {
        border-color: themed('color');
      }
    }
  }
}

.input-with-select {
  ::v-deep {
    .el-input-group__prepend {
      background-color: #fff;
    }
  }
}

// pc 端
@media screen and (min-width: 768px) {
  .el-input {
    ::v-deep {
      .el-select .el-input {
        width: 130px;
      }
    }
  }

  .page {
    position: relative;
    min-height: calc(100vh - 80px - 80px);
    background-color: #fff;
  }
  .page-top {
    height: 420px;
    @include themify($themes) {
      background: themed('pc-banner-device');
    }
    background-size: auto 420px;

    .logo {
      display: block;
      width: 120px;
      height: 120px;
      border-radius: 50%;
      background: #fff;
    }
    .name {
      font-size: 30px;
      color: #fff;
    }
  }
  .page-content {
    width: 518px;
    margin: 0 auto;

    .title {
      font-size: 18px;
      line-height: 24px;
      color: #282828;
      margin: 68px 0 12px;
    }

    .el-input {
      height: 46px;
      font-size: 16px;
      .el-input__icon {
        font-size: 24px;
        line-height: 46px;
        margin-left: 12px;
      }

      ::v-deep {
        & > .el-input__inner {
          height: 46px;
          padding-left: 55px;
          font-size: 18px;
        }
      }
    }

    .button {
      width: 295px;
      height: 50px;
      margin: 0 auto;
      border-radius: 4px;
      margin-top: 90px;
      cursor: pointer;
      @include themify($themes) {
        background-color: themed('color');
        color: #fff;
      }
    }
  }
}

// 移动 端
@media screen and (max-width: 768px) {
  .el-input {
    ::v-deep {
      .select-with-input .el-input {
        width: 22vw;

        .el-input__inner {
          padding-left: 2.4vw;
        }
      }
    }
  }

  .page-top {
    height: 46vw;
    @include themify($themes) {
      background: themed('h5-banner-device');
      background-size: auto 46vw;
    }
    .logo {
      display: block;
      width: 14.8vw;
      height: 14.8vw;
      border-radius: 50%;
      background: #fff;
    }
    .name {
      font-size: 4vw;
      color: #fff;
    }
  }
  .page-content {
    position: relative;
    padding: 0 4.2vw;

    .title {
      font-size: 3.4vw;
      line-height: 4.5vw;
      color: #666;
      margin: 18vw 0 1.6vw;
    }

    .el-input {
      font-size: 3.4vw;
      .el-input__icon {
        font-size: 5.4vw;
      }
    }

    .button {
      height: 12vw;
      margin: 0 auto;
      border-radius: 2px;
      margin-top: 12.8vw;
      font-size: 3.6vw;
      cursor: pointer;
      @include themify($themes) {
        background-color: themed('color');
        color: #fff;
      }
    }
  }
}
</style>
