<template>
  <div class="address-book-container">
    <u-card :show-head="false" :show-foot="false" margin="0" border-radius="20">
      <template #body>
        <view class="address-book-content">
          <view class="left">
            <u-image
              width="160rpx"
              height="160rpx"
              :src="baseUrl + '/' + addressBookItem.proPhoto"
            ></u-image>
            <view class="content">
              <h4>{{ addressBookItem.stuName }}</h4>
              <text class="tel">{{ addressBookItem.Phone }}</text>
              <text>单位： {{ addressBookItem.stuUnit }}</text>
            </view>
          </view>
          <u-button
            v-show="buttonTitle"
            size="mini"
            type="primary"
            @tap="tapButton"
            >{{ buttonTitle }}
          </u-button>
        </view>
      </template>
    </u-card>
  </div>
</template>

<script setup lang="ts">
import { src } from "@/utils/example"
import { baseUrl } from "@/utils/request"

const props = defineProps({
  addressBookItem: {
    type: Array,
    default: () => [],
  } as any,
  buttonTitle: String,
})

const emits = defineEmits(["tapButton"])

const tapButton = () => {
  if (props.buttonTitle === "联系TA")
    emits("tapButton", props.addressBookItem.Phone)
  else
    emits(
      "tapButton",
      props.addressBookItem.FCLASS,
      props.addressBookItem.studentId,
      props.addressBookItem.courseId
    )
}
</script>

<style lang="scss" scoped>
.address-book-container {
  margin-bottom: 32rpx;
  height: 200rpx;

  .address-book-content {
    display: flex;
    justify-content: space-between;
    align-items: center;

    .left {
      display: flex;

      .content {
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        margin-left: 20rpx;

        .tel {
          margin: 20rpx 0;
        }
      }
    }

    uni-button {
      margin: 0;
    }
  }
}
</style>
