<template>
  <div class="search-item" v-if="resultName">
    <div class="avatar-img">
      <img :src="avatarImg" />
    </div>
    <div class="result-info">
      <div class="info-name">
        <span class="text-[32rpx] font-medium">
          {{ resultName }}
        </span>
        <div class="info-tag" v-if="resultType">
          <span class="text-[24rpx] font-medium">{{ resultType }}</span>
        </div>
      </div>
      <div class="info-detail" v-if="resultDetail">
        <span class="text-[28rpx] font-regular">
          {{ resultDetail }}
        </span>
      </div>
    </div>
  </div>
</template>
<script setup>
import zu4992 from '@/static/image/chatList/zu4992@2x.png'
import zu4991 from '@/static/image/chatList/zu4991@2x.png'
import zu4989 from '@/static/image/chatList/zu4989@2x.png'
import {
  ref,
  watch,
  computed,
  onMounted,
  onUnmounted,
  reactive,
  getCurrentInstance,
} from 'vue'
const { proxy } = getCurrentInstance()
const props = defineProps({
  searchItem: Object | Number,
  searchResultKey: String,
})
const avatarImg = computed(() => {
  let srcT = ''
  switch (props.searchItem?.group_type) {
    case 0:
      srcT = zu5296
      break
    case 1:
      srcT = zu4992
      break
    case 2:
      srcT = zu4991
      break
    case 3:
      srcT = zu4989
      break
    default:
      srcT = zu4992
  }
  return srcT
})
const resultName = computed(() => {
  let data_key = ''
  switch (props.searchResultKey) {
    case 'user_infos':
      data_key = props.searchItem?.nickname
      break
    case 'group_member_infos':
      data_key = props.searchItem?.group_name
      break
    case 'general_infos':
      data_key = props.searchItem?.receiver_name
      break
    default:
      data_key = ''
  }
  return data_key
})
const resultType = computed(() => {
  let result_type = ''
  switch (props.searchItem?.group_type) {
    case 0:
      result_type = ''
      break
    case 1:
      result_type = ''
      break
    case 2:
      result_type = proxy.$t('index.mine.department')
      break
    case 3:
      result_type = proxy.$t('index.mine.project')
      break
    case 4:
      result_type = ''
      break
    default:
      result_type = ''
  }
  return result_type
})
const resultDetail = computed(() => {
  let data_key = ''
  switch (props.searchResultKey) {
    case 'user_infos':
      data_key = ''
      break
    case 'group_member_infos':
      data_key = ''
      break
    case 'general_infos':
      data_key = props.searchItem?.count + proxy.$t('search.chat.count')
      break
    default:
      data_key = ''
  }
  return data_key
})
</script>
<style lang="scss" scoped>
.search-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;

  .avatar-img {
    width: 96rpx;
    height: 96rpx;
    margin: 0 20rpx 0 0;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .result-info {
    .info-name {
      display: flex;
      flex-direction: row;
      align-items: center;
      justify-content: flex-start;
      span {
        color: $theme-text;
        line-height: 44rpx;
      }
      .info-tag {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        padding: 2rpx 14rpx;
        border: 2rpx solid #000;
        border-radius: 6rpx;
        span {
          line-height: 34rpx;
        }
      }
    }
    .info-detail {
      span {
        color: $theme-hint-text;
        line-height: 40rpx;
      }
    }
  }
}
</style>
