BaseDialog.vue 1.81 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
<template>
  <div class="base-dialog">
    <van-overlay :show="BaseDialogShow">
      <div class="wrapper" @click.stop>
        <div class="content">
          <van-icon
            v-if="BaseDialogShowClose"
            class="close-icon"
            name="close"
            size="30"
leiqingsong's avatar
leiqingsong committed
11
            @click="onClose"
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
          />
          <p v-if="BaseDialogTitle" class="title">{{ BaseDialogTitle }}</p>
          <slot name="content" />
          <div class="content-submit-btn">
            <van-button round @click="onBtn">{{ BaseDialogBtn }}</van-button>
          </div>
        </div>
      </div>
    </van-overlay>
  </div>
</template>

<script>
export default {
  name: "BaseDialog",
  props: {
    BaseDialogShowClose: {
      type: Boolean,
      default: false
    },
    BaseDialogShow: {
      type: Boolean,
      default: false
    },
    BaseDialogTitle: {
      type: String,
      default: ""
    },
    BaseDialogBtn: {
      type: String,
      default: "确定"
    }
  },
  methods: {
    onBtn() {
      this.$emit("onClick");
leiqingsong's avatar
leiqingsong committed
48 49 50
    },
    onClose() {
      this.$emit("onClose");
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
    }
  }
};
</script>

<style lang="scss" scoped>
.wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}
.content {
  position: relative;
  box-sizing: border-box;
  position: relative;
  width: 315px;
  height: 293px;
  background: #ffffff;
  border-radius: 4px;
  p {
    margin: 0;
  }
  .title {
    margin: 29px 0;
    text-align: center;
    font-size: 20px;
    color: #333333;
  }
  .close-icon {
    position: absolute;
    top: 0;
    right: 0;
  }
  .content-submit-btn {
    position: absolute;
    bottom: 31px;
    width: 100%;
    text-align: center;

    .van-button {
      width: 160px;
      color: #ffffff;
      font-size: 16px;
      background-color: #88c678;
    }
  }
}
</style>