index.vue 2.29 KB
<template>
  <uni-popup ref="tips" type="center" :is-mask-click="false" :animation="false">
    <view class="tips-wrapper">
      <view class="tips-content">
        <view class="tips-title"
          >{{ title }}
          <view class="icon-close" @click="close">×</view>
        </view>
        <view class="tips-text">{{ content }}</view>
      </view>
      <view class="tips-footer">
        <view class="tips-btn close" @click="close()">{{ cancelBtnText }}</view>
        <view class="tips-btn preview" @click="confirm()">{{
          confirmBtnText
        }}</view>
      </view>
    </view>
  </uni-popup>
</template>
<script>
export default {
  name: "MessageBox",
  data() {
    return {};
  },
  props: {
    title: {
      type: String,
      default: "提示",
    },
    content: {
      type: String,
      default: "提示",
    },
    confirmBtnText: {
      type: String,
      default: "确定",
    },
    cancelBtnText: {
      type: String,
      default: "取消",
    },
  },
  mounted() {
    this.$refs.tips.open("center");
  },
  methods: {
    close() {
      this.$refs.tips.close();
      this.$emit("cancel");
    },
    confirm() {
      this.$refs.tips.close();
      this.$emit("confirm");
    },
  },
};
</script>
<style scoped lang="scss">
.tips-wrapper {
  width: 704rpx;
  height: 372rpx;
  background: #ffffff;
  border-radius: 20rpx;
  .tips-content {
    padding: 48rpx;
    border-bottom: 1px solid #e8e8e8;
    .tips-title {
      position: relative;
      width: 100%;
      font-weight: 500;
      font-size: 32rpx;
      color: #292d33;
      text-align: center;
      .icon-close {
        position: absolute;
        right: 0;
        top: -24rpx;
        width: 160rpx;
        font-size: 50rpx;
        text-align: right;
        padding-right: 20rpx;
        line-height: 96rpx;
      }
    }
  }
  .tips-text {
    font-size: 30rpx;
    color: #5a5e66;
    letter-spacing: 1rpx;
    text-align: center;
    line-height: 40rpx;
    margin-top: 48rpx;
  }
  .tips-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100rpx;

    .close {
      color: #6c6c70;
    }
    .preview {
      color: #2c66f7;
    }
  }
  .tips-btn {
    width: 50%;
    text-align: center;
    font-size: 32rpx;
    text-align: center;
    line-height: 44rpx;
  }
}
</style>