<!--
 * @Descripttion: 当前组件信息
 * @version: 1.0.0
 * @Author: 无尘
 * @Date: 2019-10-22 15:12:41
 * @LastEditors: 无尘
 * @LastEditTime: 2019-11-13 11:25:39
 -->

<!--
<notice-preview ref="noticePreview" v-model="previewVisible"></notice-preview>

import noticePreview from '@/components/app/notice-preview.vue';
components: {
  noticePreview
}

previewVisible: false,
-->
<template>
  <div class="qr-dialog-content" style="opacity: 1;" v-show="value">
    <div class="qr-mask" @click.stop="closeDialog"></div>
    <div class="qr-dialog border-box">
      <div class="qr-dialog-body border-box">
        <h2 class="font-20 color-222 text-left">{{ noticeData.title }}</h2>
        <div class="notice-date m-t-10 flex flex-space-between">
          <div class="notice-date-left font-10 color-88949C">{{ noticeData.announcementId ? noticeData.sendTime : new Date().getTime() | formatTimeYmdHms }}</div>
          <div class="notice-date-right font-10 color-4d7fd0">
            <!-- <span>未读 {{ noticeData.announcementId ? noticeData.sendCount - noticeData.readCount : 0 }}</span
            ><span class="p-lr-5 color-a5afb8">|</span><span>已读 {{ noticeData.announcementId ? noticeData.readCount : 0 }}</span> -->
          </div>
        </div>
        <div class="notice-body border-box color-222" v-htmlContent="noticeData.content"></div>
      </div>
    </div>
    <!-- 关闭 -->
    <div class="qr-dialog__hd">
      <i class="el-icon-plus" @click.stop="closeDialog"></i>
    </div>
  </div>
</template>
<script>
export default {
  name: 'notice-preview',
  props: {
    value: {
      type: Boolean,
      default() {
        return false;
      }
    },
    noticePreviewData: {
      type: Object,
      default() {
        return {
          announcementId: '',
          sendTime: '',
          sendCount: 0,
          readCount: 0,
          adminCheck: false,
          stroreCheck: false,
          adminStructor: [],
          storeStructor: [],
          receiveType: '0',
          labelId: '',
          title: '',
          img: '',
          content: '',
          sendType: '0',
          attachment: [],
          pageTop: false
        };
      }
    }
  },
  directives: {
    htmlContent: {
      // 指令的定义
      bind: function(el, param) {
        el.innerHTML = param.value;
      },
      update: function(el, param) {
        el.innerHTML = param.value;
      }
    }
  },
  data() {
    return {
      noticeData: {
        announcementId: '',
        sendCount: 0,
        readCount: 0,
        title: '',
        content: ''
      }
    };
  },
  methods: {
    /**
     *  关闭预览窗口
     */
    closeDialog() {
      const that = this;
      that.$emit('input', false);
    }
  },
  watch: {
    noticePreviewData(newData, oldData) {
      const that = this;
      that.noticeData = newData;
    }
  },
  mounted() {
    const that = this;
    that.noticeData = that.noticePreviewData;
  }
};
</script>
<style type="text/scss" lang="scss" scoped>
.font-10 {
  font-size: 10px;
}
.color-222 {
  color: #222222;
}
.color-88949C {
  color: #88949c;
}
.color-4d7fd0 {
  color: #4d7fd0;
}
.color-a5afb8 {
  color: #a5afb8;
}
.p-lr-5 {
  padding: 0 5px;
}
.qr-mask {
  position: fixed;
  z-index: 1000;
  top: 0;
  right: 0;
  left: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  cursor: pointer;
}

.qr-dialog {
  position: fixed;
  z-index: 5000;
  width: 220px;
  height: 440px;
  padding: 58px 12px 30px 12px;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
  background-color: #fff;
  text-align: center;
  border-radius: 3px;
  overflow: hidden;
  background: url('../../assets/iPhone_preview.png') no-repeat;
  .qr-dialog-body {
    position: relative;
    width: 100%;
    height: 100%;
    padding: 15px 8px;
    text-align: left;
    // background: #ccc;
    overflow-y: auto;
    .notice-body {
      padding: 20px 0;
      font-size: 12px;
      white-space: pre-wrap;
      word-break: break-all;
      ::v-deep video {
        width: 100%;
        height: auto;
      }
      ::v-deep img {
        width: 100%;
        height: auto;
      }
      ::v-deep p {
        iframe {
          width: 100%;
          height: auto;
        }
      }
    }
  }

  .qr-dialog__bd {
    padding: 0 1.6em 0.8em;
    min-height: 40px;
    font-size: 15px;
    line-height: 1.3;
    word-wrap: break-word;
    word-break: break-all;
    color: #808080;

    #qrcode {
      display: -webkit-flex;
      display: flex;
      justify-content: center;
      align-items: center;
    }

    .qr-dialog__p {
      padding: 20px 0;
      font-size: 14px;
      color: #606266;
    }
  }
}
.qr-dialog__hd {
  position: fixed;
  width: 45px;
  height: 45px;
  border: 1px solid rgba(255, 255, 255, 1);
  border-radius: 50%;
  bottom: 15%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
  z-index: 5001;
  i {
    position: absolute;
    top: 0;
    right: 0;
    display: block;
    width: 45px;
    height: 45px;
    line-height: 45px;
    text-align: center;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    -webkit-transform: rotate(45deg);
    transform: rotate(45deg);
  }
}
</style>
