index.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <div class="custom-tel-component" @click="makePhoneCall(num)">
  3. <div class="custom-tel-component-left" v-if="showTel">
  4. {{ num }}
  5. </div>
  6. <a :href="'tel:' + num" class="custom-tel-component-right">
  7. <van-icon
  8. name="phone-circle-o"
  9. style="color: white"
  10. class="iconfont icon-dianhua1"
  11. />
  12. </a>
  13. </div>
  14. </template>
  15. <script>
  16. export default {
  17. props: {
  18. showTel: {
  19. // 是否显示电话号码
  20. type: Boolean,
  21. default: true,
  22. },
  23. num: {
  24. // 电话号码
  25. type: String | Number,
  26. default: "",
  27. },
  28. },
  29. methods: {
  30. makePhoneCall(num) {
  31. wx.makePhoneCall({
  32. phoneNumber: num, //此号码仅用于测试 。
  33. success: function () {
  34. console.log("拨打电话成功!");
  35. },
  36. fail: function () {
  37. console.log("拨打电话失败!");
  38. },
  39. });
  40. },
  41. },
  42. };
  43. </script>
  44. <style lang="scss" type="text/scss" scoped>
  45. .custom-tel-component {
  46. display: flex;
  47. justify-content: space-between;
  48. align-items: center;
  49. .custom-tel-component-left {
  50. flex: 1;
  51. font-size: 24rpx;
  52. line-height: 66rpx;
  53. color: #333333;
  54. }
  55. .custom-tel-component-right {
  56. width: 50rpx;
  57. height: 50rpx;
  58. background-color: rgba(102, 0, 255, 1);
  59. border-radius: 50%;
  60. display: flex;
  61. justify-content: center;
  62. align-items: center;
  63. i {
  64. color: #fff;
  65. font-size: 25rpx;
  66. }
  67. }
  68. }
  69. </style>