<template>
  <div class="hot-group">
    <div class="top-search">
      <input type="text" class="search-wrap" v-model="searchTxt" @input="searchUser($event, sessionList)" @blur="handleBlur" v-focus v-if="searchShow">
      <div class="search-tips search-wrap" @click="searchShow=true" v-else>
        <i class="el-icon-search"></i>{{$t('public.searchHotGroup')}}
      </div>
      <span @click="$router.go(-1)">{{$t('public.cancel')}}</span>
    </div>
    <template v-if="isSearch">
      <session-item
        v-for="(item, index) in searchList"
        :key="index"
        :item="item"
        class="current">
      </session-item>
    </template>
    <div class="hot-list">
      <hot-group :searchTxt="searchTxt"></hot-group>
    </div>
  </div>
</template>

<script>
import Vue from 'vue'
import { Button } from 'element-ui'
import { mapState } from 'vuex'
import { searchUserMixin } from '@/mixins'
import sessionItem from '@/components/panel/sessionItem'
import hotGroup from '@/components/hotGroup/hotGroup'

Vue.component(Button.name, Button)

export default {
  name: 'searchH5',
  mixins: [searchUserMixin],
  components: {
    sessionItem,
    hotGroup
  },
  data () {
    return {
      searchShow: false,
      searchTxt: ''
    }
  },
  computed: {
    ...mapState({
      sessionList: state => state.chat.sessionList
    })
  },
  methods: {
    handleBlur (e) {
      let val = e.target.value
      if (!val) {
        this.searchShow = false
      }
    }
  },
  created () {}
}
</script>

<style lang="scss" scoped>
.top-search{
  height: px2rem(88);
  background-color: #f2f2f2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #eeeeee;
  padding: 0 px2rem(30);
  .search-wrap{
    background-color: #ffffff;
    border-radius: 4px;
    border: 1px solid #eeeeee;
    width: px2rem(582);
    height: px2rem(60);
    line-height: px2rem(60);
    box-sizing: border-box;
    font-size: px2rem(28);
  }
  input{
    padding-left: px2rem(10);
    font-size: px2rem(28);
    color: #666666;
  }
  span{
    font-size: px2rem(30);
    color: #259af2;
  }
}
.search-tips{
  color: #8e8e93;
  i{
    display: inline-block;
    vertical-align: middle;
    margin: 0 px2rem(6) 0 px2rem(27);
    font-size: px2rem(26);
  }
}
// .avatar-wrap{
//   position: relative;
//   .icon-auth {
//     position: absolute;
//     bottom: 0;
//     right: 0;
//     width: 14px;
//     height: 13px;
//     background: url("../../../assets/icon-chat-auth.png");
//   }
// }
// .el-button{
//   padding: px2rem(15) px2rem(27);
//   font-size: px2rem(30);
//   margin-top: px2rem(9);
// }
</style>
