<template>
  <u-popup mode="center" round="10" :show="isShow" :closeOnClickOverlay="false">
    <view class="dialog">
      <view class="close" v-if="type === 3">
        <u-icon
          name="close"
          color="#9E9E9E"
          size="24"
          @tap="closeDialog"
        ></u-icon>
      </view>
      <view class="top">
        <image
          src="@/static/images/dialog/insurance-icon1.png"
          mode="widthFix"
          v-if="type === 3"
        ></image>
        <image
          src="@/static/images/dialog/insurance-icon2.png"
          mode="widthFix"
          v-if="type === 2"
        ></image>
      </view>
      <view class="title">保险购买提示</view>
      <view class="text" v-if="type === 3"
        >距离保险期还有{{ day }}天，请及时续保，以免影响接单!</view
      >
      <view class="text" v-if="type === 2"
        >保险已过期，为了您的安全保障，请及时续保，以免影响接单!</view
      >
      <view class="btn">
        <u-button
          text="去续保"
          shape="circle"
          type="primary"
          @click="clickButton()"
        >
        </u-button>
      </view>
    </view>
  </u-popup>
</template>

<script>
export default {
  props: {
    isShow: {
      type: Boolean,
      default: false,
    },
    type: {
      type: Number,
      default: 0, // 2=保险过期提示 3=保险快到期提示
    },
  },

  data() {
    return {
      day: 0,
    };
  },

  onLoad() {},

  methods: {
    initData() {
      const userInfo = this.$store.state.userInfo;
      this.day = userInfo.limitInsureDay;
    },

    closeDialog() {
      this.$emit('close');
    },

    clickButton() {
      this.$emit('handle');
    },
  },
};
</script>

<style lang="scss" scoped>
.dialog {
  width: 640rpx;
  background: #ffffff;
  border-radius: 20rpx;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 70rpx 70rpx;
  box-sizing: border-box;
  .close {
    position: absolute;
    right: 40rpx;
    top: 40rpx;
  }
  .top {
    margin-top: 30rpx;
    image {
      width: 390rpx;
      height: 220rpx;
    }
  }
  .title {
    font-size: 44rpx;
    font-weight: 500;
  }
  .text {
    text-align: center;
    font-size: 32rpx;
    color: $sec-font;
    line-height: 48rpx;
    margin-top: 30rpx;
  }
  .btn {
    width: 100%;
    margin-top: 60rpx;
  }
}
</style>
