PaperDialog.vue 3.39 KB
<template>
  <van-overlay
    :show="show"
    @click="$emit('update:value', false)"
    z-index="99"
    :lock-scroll="false"
  >

    <div class="image-wrapper">
      <div
        class="image-close"
        @click="$emit('update:value', false)"
      >
        <img src="https://img01.glsx.com.cn/weapp/resource/scrm-mobile/psd/close.png">
      </div>
      <template v-if="data.text && data.pushType == 5">
        <div
          class="text-box"
          @click.stop
        >
          <div class="text-title flex">文字喜报</div>
          <div
            class="content"
            v-html="data.text"
            ref="textBox"
          >
          </div>
          <van-button
            block
            round
            color="#3975C6"
            class="btn"
            @click="$emit('update:value', false)"
          >确定</van-button>
        </div>
      </template>
      <template v-else>
        <div
          class="image-box"
          @click.stop
        >
          <img :src="data.fileUrl" />
        </div>
        <div
          class="image-tips flex"
          @click.stop
        >
          <img src="https://img01.glsx.com.cn/weapp/resource/scrm-mobile/psd/longtap.png">
          长按图片保存
        </div>
      </template>
    </div>
  </van-overlay>
</template>

<script type='text/ecmascript-6'>
export default {
  name: 'PaperDialog',
  props: {
    value: Boolean,
    data: Object
  },
  data () {
    return {
      show: false
    }
  },
  watch: {
    value (n) {
      this.show = n
      if (n && this.data.pushType == 5) this.$nextTick(() => {
        this.$refs.textBox.scrollTop = 0
      })
    }
  },
  mounted () {
  },
  methods: {
  }
}
</script>

<style scoped lang='scss'>
.image-wrapper {
  user-select: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  .image-close {
    position: absolute;
    width: 28px;
    height: 28px;
    right: 0;
    top: -44px;
  }
  .image-box {
    width: 279px;
    height: 400px;
    // max-height: 454px;
    background: #ffffff;
    border-radius: 6px 6px 0 0;
    padding: 16px;
    box-sizing: border-box;
    overflow-y: scroll;
    img {
      height: auto;
      // object-fit: contain;
    }
  }
  .image-tips {
    width: 279px;
    height: 45px;
    background: #f7f8fa;
    border-radius: 0 0 6px 6px;
    justify-content: center;
    font-weight: 500;
    font-size: 16px;
    color: #3975c6;
    transform: translateY(-1px);
    img {
      margin-right: 6px;
      width: 20px;
      height: 20px;
    }
  }
  .text-box {
    background-color: #fff;
    width: 279px;
    max-height: 457px;
    background: #ffffff;
    border-radius: 6px;
    box-sizing: border-box;
    padding-bottom: 20px;
    .text-title {
      font-weight: 500;
      font-size: 16px;
      color: #282829;
      height: 52px;
      justify-content: center;
      border-bottom: 1px solid rgba(195, 195, 195, 0.3);
    }
    .content {
      user-select: text;
      padding: 16px;
      box-sizing: border-box;
      max-height: 320px;
      overflow-y: scroll;
      font-size: 14px;
      line-height: 24px;
      color: #666666ff;
      word-break: break-all;
      white-space: pre-wrap;
    }
    .btn {
      width: 247px !important;
      margin: 24px auto 0;
      height: 40px;
      background: #3975c6;
      border-radius: 21px;
      font-weight: 600;
      font-size: 16px;
      letter-spacing: 1px;
    }
  }
}
</style>