<template>
  <div class="custom-tel-component" @click="makePhoneCall(num)">
    <div class="custom-tel-component-left" v-if="showTel">
      {{ num }}
    </div>
    <a :href="'tel:' + num" class="custom-tel-component-right">
      <van-icon
        name="phone-circle-o"
        style="color: white"
        class="iconfont icon-dianhua1"
      />
    </a>
  </div>
</template>

<script>
export default {
  props: {
    showTel: {
      // 是否显示电话号码
      type: Boolean,
      default: true,
    },
    num: {
      // 电话号码
      type: String | Number,
      default: "",
    },
  },
  methods: {
    makePhoneCall(num) {
      wx.makePhoneCall({
        phoneNumber: num, //此号码仅用于测试 。

        success: function () {
          console.log("拨打电话成功！");
        },

        fail: function () {
          console.log("拨打电话失败！");
        },
      });
    },
  },
};
</script>

<style lang="scss" type="text/scss" scoped>
.custom-tel-component {
  display: flex;
  justify-content: space-between;
  align-items: center;
  .custom-tel-component-left {
    flex: 1;
    font-size: 24rpx;
    line-height: 66rpx;
    color: #333333;
  }
  .custom-tel-component-right {
    width: 50rpx;
    height: 50rpx;
    background-color: rgba(102, 0, 255, 1);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    i {
      color: #fff;
      font-size: 25rpx;
    }
  }
}
</style>
