<template>
  <div class="outband">
    <ActionSheet
      v-model:show="actionSheetVisible"
      close-on-click-action
      teleport="body"
      header-visible
      title="请先接听来电"
      cancel-text=""
      @onClose="onClose"
    >
      <div class="outband-content fsc-c">
        <span class="outband-content_text">接听后，将自动呼叫联系人 </span>
        <span
          v-if="userInfo?.call_platform?.type != 4"
          class="outband-content_tips"
          >（对方看到的是你自己的手机号哦～）</span
        >
        <div class="outband-content_img">
          <div class="outband-content_img_bac">
            <WlPic :src="call_bag_icon" />
          </div>
          <!-- 线索名称 -->
          <div
            class="outband-content_img_name"
            v-if="calleeInfo?.type == 'clue' && calleeInfo?.info?.user_name"
          >
            {{ calleeInfo?.info?.user_name?.substring(0, 1) }}
          </div>
          <!-- 企微好友头像 -->
          <div
            v-else-if="
              calleeInfo?.type == 'customer' && calleeInfo?.info?.avatar
            "
            class="outband-content_img_avatar"
          >
            <WlPic round :src="calleeInfo?.info?.avatar" />
          </div>
          <!-- 空拨 -->
          <div v-else class="outband-content_img_icon ">
            <WlSvgIcon type="userFill" width="60" height="60" color="#fff" />
          </div>
          <div class="outband-content_img_phone">{{ phone }}</div>
        </div>
        <div class="sponsor fcc" v-if="userInfo?.call_platform">
          本功能由
          <div class="sponsor_img">
            <WlPic :src="callOutCompany[userInfo.call_platform?.type]" />
          </div>
          <span>{{ userInfo.call_platform?.name }}</span>
          提供技术支持
        </div>
      </div>
    </ActionSheet>
  </div>
</template>

<script lang="ts">
/*
 * @Author: Lai.xianxu
 * @Date: 2021-09-18 11:18:59
 * @Last Modified by: Liao.xiuli
 * @Last Modified time: 2023-12-18 13:51:00
 */
export default {
  name: 'CallOutTip',
};
</script>

<script setup lang="ts">
import { ref, watchEffect } from 'vue';
import WlPic from '@mobileUI/components/WlPic';
import {
  call_bag_icon,
  aivo_icon,
  aimengyx_icon,
  aliyun_icon,
  rongying_icon
} from '@mobileUI/utils/cdn';
import { ActionSheet } from 'vant';
import WlSvgIcon from "@mobileUI/components/WlSvgIcon";

type Props = {
  phone?: string;
  userInfo?: any;
  calleeInfo?: any;
  modelValue?: boolean;
};
const props = withDefaults(defineProps<Props>(), {
  phone: null,
  userInfo: null,
  calleeInfo: null,
  modelValue: false,
});

const emit = defineEmits<{
  (e: 'update:modelValue', val: boolean);
}>();

const actionSheetVisible = ref(false);
const callOutCompany = ref({
  1: aivo_icon,
  2: aimengyx_icon,
  3: rongying_icon,
  4: aliyun_icon,
});

watchEffect(() => {
  actionSheetVisible.value = props.modelValue;
});

const onClose = () => {
  emit('update:modelValue', false);
};
</script>

<style lang="scss">
// .call-out-wrap[data-weiling-mobile-ui-bc-call-out] {
.outband {
  &-content {
    width: 100%;
    padding: 0 0 j(30) 0;

    &_text {
      color: #0e0e0e;
    }

    &_tips {
      font-size: j(13);
      color: var(--wl-text-color-secondary-2);
      margin-top: j(4);
    }

    &_img {
      position: relative;

      &_bac {
        width: j(300);
        height: j(331);
        margin-top: j(20);
      }

      &_name {
        position: absolute;
        top: j(76);
        left: 50%;
        transform: translateX(-50%);
        font-weight: 500;
        font-size: j(47);
        color: #ffffff;
      }

      &_avatar {
        width: j(86) !important;
        height: j(86) !important;
        border-radius: 50%;
        position: absolute;
        top: j(70);
        left: 50%;
        transform: translateX(-52%);
        overflow: hidden;
      }

      &_icon {
        position: absolute;
        top: j(80);
        left: 50%;
        transform: translateX(-50%);
        font-weight: 500;
        color: #ffffff;
      }

      &_phone {
        position: absolute;
        top: j(160);
        left: 50%;
        transform: translateX(-50%);
        font-weight: 500;
        font-size: j(18);
        letter-spacing: j(1);
        color: #ffffff;
      }
    }

    .sponsor {
      width: 100%;
      font-weight: 400;
      font-size: j(12);
      color: var(--wl-text-color-secondary-1);
      margin-top: j(13);

      .sponsor_img {
        width: j(16);
        height: j(16);
        margin: 0 j(3);
      }

      span {
        margin-right: 3px;
      }
    }
  }
}

.fcc {
  display: flex !important;
  justify-content: center;
  align-items: center;
}

.fsc {
  display: flex !important;
  justify-content: flex-start;
  align-items: center;
}

.fsc-c {
  @extend .fsc;
  flex-direction: column;
}

.ml5 {
  margin-left: j(5);
}
// }
</style>
