<template>
  <!-- 咨询电话 -->
  <u-popup
    v-model="showPopup"
    mode="center"
    border-radius="16"
    closeable
    close-icon-color="#999999"
    close-icon-pos="top-right"
  >
    <view class="phone-popup">
      <view class="phone-title">招生电话</view>

      <view class="phone-card-list">
        <view class="phone-card" @click="makeCall('0790-6764666')">
          <view class="icon-wrapper">
            <u-icon name="phone-fill" color="#ffffff" size="40"></u-icon>
          </view>
          <view class="info-wrapper">
            <text class="phone-number">0790-6764666</text>
            <text class="phone-desc">拨打招生电话1</text>
          </view>
        </view>

        <view class="phone-card" @click="makeCall('0790-6765666')">
          <view class="icon-wrapper">
            <u-icon name="phone-fill" color="#ffffff" size="40"></u-icon>
          </view>
          <view class="info-wrapper">
            <text class="phone-number">0790-6765666</text>
            <text class="phone-desc">拨打招生电话2</text>
          </view>
        </view>
      </view>

      <view class="phone-button">
        <view class="cancel-btn" @click="closePopup">取消</view>
      </view>
    </view>
  </u-popup>
</template>

<script>
export default {
  name: "AdvicePhone",
  props: {
    show: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      showPopup: false,
    };
  },
  watch: {
    show: {
      handler(newVal) {
        this.showPopup = newVal;
      },
      immediate: true,
    },
    showPopup(val) {
      if (val !== this.show) {
        this.$emit("update:show", val);
      }
    },
  },
  methods: {
    makeCall(phoneNumber) {
      uni.makePhoneCall({
        phoneNumber,
      });
    },
    closePopup() {
      this.showPopup = false;
      this.$emit("update:show", false);
    },
  },
};
</script>

<style lang="scss" scoped>
.phone-popup {
  width: 600rpx;
  padding: 60rpx 0;
  border-radius: 16rpx;
  background-image: url("/static/common/images/images_bg_dialog.png");
  background-repeat: no-repeat;
  background-size: 630rpx 100rpx;
  background-position: -20rpx 0;

  .phone-title {
    text-align: center;
    font-family: DouyinSans;
    font-weight: bold;
    font-size: 40rpx;
    color: #477bfb;
    margin-bottom: 40rpx;
  }

  .phone-card-list {
    padding: 0 48rpx;
    margin-bottom: 60rpx;

    .phone-card {
      display: flex;
      align-items: center;
      padding: 30rpx 40rpx;
      margin-bottom: 24rpx;
      background: #ffffff;
      border: 1px solid #f0f0f0;
      box-shadow: 0px 4rpx 12rpx rgba(0, 0, 0, 0.05);
      border-radius: 16rpx;

      &:last-child {
        margin-bottom: 0;
      }

      .icon-wrapper {
        width: 80rpx;
        height: 80rpx;
        background: #5ac799;
        border-radius: 50%;
        display: flex;
        justify-content: center;
        align-items: center;
        margin-right: 30rpx;
        flex-shrink: 0;
      }

      .info-wrapper {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        flex: 1;

        .phone-number {
          font-size: 36rpx;
          font-weight: bold;
          color: #333333;
          letter-spacing: 2rpx;
          margin-bottom: 10rpx;
        }

        .phone-desc {
          font-size: 24rpx;
          color: #999999;
        }
      }
    }
  }

  .phone-button {
    padding: 0 48rpx;

    .cancel-btn {
      width: 100%;
      height: 88rpx;
      line-height: 88rpx;
      text-align: center;
      background: #ffffff;
      border: 1px solid #e5e5e5;
      border-radius: 16rpx;
      font-size: 32rpx;
      color: #333333;
    }
  }
}
</style>
