preview.vue 4.89 KB
<template>
  <div class="img-bg">
    <div class="preview-content">
      <div class="preview-time">{{ currentTime }}</div>
      <div class="preview-info" v-for="item in previewList" :key="item.id">
        <img class="avatar" src="@/assets/img/guestCustom/logo.png" alt />
        <template v-if="item.attType == 1">
          <div class="preview-text text">{{ item.attContent }}</div>
        </template>
        <template v-else-if="item.attType == 7">
          <div class="preview-activity">
            <img class="applet-logo" src="@/assets/img/guestCustom/applet-logo.png" alt />
            <div class="activity-name">{{item.attContent.marketingName}}</div>
            <img class="activity-logo" src="@/assets/img/guestCustom/activity-logo.png" alt />
            <div class="activity-footer">
              <img src="@/assets/img/guestCustom/applet-footer.png" alt />
            </div>
          </div>
          <!-- <div class="preview-text preview-link">
            {{ item.attContent.url }}
            <img src="@/assets/guestCustom/preview-link.png" alt />
          </div>-->
        </template>
        <template v-else-if="item.attType == 2">
          <el-image style="width: 100px" :src="item.attContent" fit="contain"></el-image>
        </template>
        <template v-else-if="item.attType == 3">
          <!-- <el-image style="width: 100px" :src="item.attContent" fit="contain"></el-image> -->
          <video style="width: 100px" :src="item.attContent"></video>
        </template>
        <template v-else-if="item.attType == 5">
          <div class="preview-text text preview-applet">
            <div class="preview-applet-title">
              <img :src="item.attContent.picUrl" alt />
              <span>{{ item.attContent.title }}</span>
            </div>
            {{ item.attContent.page }}
          </div>
        </template>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Preview',
  props: { eventBus: Object, list: Array },
  data() {
    return {
      previewList: [],
      currentTime: ''
    }
  },
  created() {
    this.$nextTick(() => {
      console.log(1, this.list)
    })
    this.eventBus.$on('update', val => {
      console.log(val)
      this.previewList = val
    })
  },
  mounted() {
    const date = new Date()
    let hours = date.getHours()
    hours = hours < 10 ? `0${hours}` : hours
    let minutes = date.getMinutes()
    minutes = minutes < 10 ? `0${minutes}` : minutes
    this.currentTime = `${date.getFullYear()}年${date.getMonth() + 1}月${date.getDate()}日 ${hours}:${minutes}`
  }
}
</script>

<style lang="scss" scope>
.img-bg {
  position: relative;
  width: 290px;
  height: 566px;
  background-image: url(../../../assets/img/guestCustom/iphone-bg.png);
  background-size: 100%;
  .preview-content {
    position: absolute;
    width: 250px;
    height: 350px;
    overflow-y: auto;
    top: 115px;
    left: 20px;
    // background-color: cornflowerblue;
    .preview-time {
      font-size: 10px;
      color: #999;
      text-align: center;
      margin-bottom: 15px;
    }
    .preview-info {
      display: flex;
      padding: 0 44px 20px 9px;
      .avatar {
        width: 26px;
        height: 26px;
        margin-right: 8px;
      }
      .preview-text {
        position: relative;
        max-width: 169px;
        color: #333;
        background-color: #fff;
        border-radius: 4px;
        word-wrap: break-word;
      }
      .text {
        font-size: 16px;
        padding: 8px 11px;
      }
      .preview-link {
        display: inline-flex;
        word-break: break-all;
        font-size: 14px;
        padding: 8px 8px 8px 11px;
        img {
          width: 34px;
          height: 34px;
          margin-left: 10px;
        }
      }
      .preview-text::before {
        content: '';
        position: absolute;
        left: -10px;
        top: 20%;
        border-width: 5px;
        border-style: dashed solid dashed dashed;
        border-color: transparent #fff transparent transparent;
        // background-color: cornflowerblue;
      }
      .preview-applet {
        img {
          width: 20px;
          height: 20px;
          margin-right: 4px;
        }
        &-title {
          display: flex;
          align-self: center;
          color: #999;
          margin-bottom: 5px;
        }
      }
      .preview-activity {
        width: 160px;
        // height: 184px;
        background-color: #fff;
        border-radius: 4px;
        border: 1px solid #dce1e5;
        padding: 7px 7px 0;
        .activity-name {
          font-size: 12px;
          color: #333;
          margin: 7px 0 4px;
          width: 160px;
          text-overflow: ellipsis;
          overflow: hidden;
          white-space: nowrap;
        }
        .applet-logo {
          width: 95px;
          height: 24px;
        }
        .activity-footer {
          margin-top: 4px;
          border-top: 1px solid #edeff3;
        }
      }
    }
  }
}
</style>