<script lang="ts" setup>
import DefaultIcon from '@/images/vip/pay-success.png'

interface Props {
  modelValue: boolean
  zIndex?: number
  primaryButtonText?: string
  defaultButtonText?: string
  desc?: string
  icon?: string
  showIcon?: boolean
}
const props = withDefaults(defineProps<Props>(), {
  modelValue: false,
  zIndex: 999,
  primaryButtonText: '确定',
  defaultButtonText: '取消',
  desc: 'ok了',
  icon: DefaultIcon,
  showIcon: true,
})

const emits = defineEmits(['update:modelValue', 'clickPrimaryButton', 'clickDefaultButton'])
</script>

<template>
  <van-overlay :z-index="zIndex" :show="props.modelValue">
    <div class="wrapper" @click.stop>
      <div class="block">
        <img v-if="props.showIcon" class="icon" :src="props.icon" alt="">
        <div class="title">
          {{ desc }}
        </div>
        <div class="btn-wrap">
          <button class="default" @click="() => emits('clickDefaultButton')">
            {{ defaultButtonText }}
          </button>
          <button class="primary" @click="() => emits('clickPrimaryButton')">
            {{ primaryButtonText }}
          </button>
        </div>
      </div>
    </div>
  </van-overlay>
</template>

<style lang="scss" scoped>
  .wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.block {
  width: 280px;
  height: 175px;
  background: #ffffff;
  border-radius: 24px;
  position: relative;
  box-sizing: border-box;
  padding: 0 24px;
  .icon {
    width: 72px;
    height: 72px;
    position: absolute;
    left: 50%;
    margin-left: -36px;
    top: -27px;
  }
  .title {
    width: 100%;
    text-align: center;
    font-family:
      PingFangSC,
      PingFang SC;
    font-weight: 600;
    font-size: 16px;
    color: #0e2120;
    line-height: 22px;
    margin-top: 61px;
  }
  .btn-wrap {
    margin-top: 32px;
    display: flex;
    align-items: center;
    .default {
      bottom: none;
      width: 110px;
      height: 36px;
      border-radius: 22px;
      border: 1px solid #d5d9d8;
      font-family:
        alir,
        PingFangSC,
        PingFang SC;
      font-weight: 400;
      font-size: 14px;
      color: #768180;
      border-radius: 18px;
      text-align: center;
      font-style: normal;
      margin: 0 8px;
      background: #ffffff;
    }
    .primary {
      border: none;
      width: 110px;
      height: 36px;
      background: #16a39a;
      border-radius: 18px;
      font-family:
        alir,
        PingFangSC,
        PingFang SC;
      font-weight: 400;
      font-size: 14px;
      color: #ffffff;
      line-height: 19px;
      text-align: center;
      font-style: normal;
      margin: 0 8px;
    }
  }
}
</style>
