<template>
  <div class="four-box">
    <div class="card" v-for="(item, index) in data.stepOne" :key="index">
      <div class="title">{{ item.cardTitle }}</div>
      <div class="ul-list">
        <div class="li" v-for="(cItem, cIndex) in item.form.personAttribute" :key="cIndex + 'c'">
          <div class="icon"></div>
          <div class="text">
            {{ getPersonalMap(cItem).label }}&nbsp;&nbsp;{{
              cItem.equalMap.find(i => i.value === cItem.equal).label
            }}&nbsp;&nbsp;{{ getPersonalMap(cItem).children.find(i => i.value === cItem.range).label }}
          </div>
        </div>
      </div>
    </div>
    <div class="card">
      <div class="title">营销方案</div>
      <div class="ul-list">
        <div class="li">
          <div class="icon"></div>
          <div class="text">计划类型：{{ data.stepTwo.index ? '条件触发' : '单次触发' }}</div>
        </div>
        <template v-if="data.stepTwo.index">
          <div class="li" v-for="(item, index) in data.stepTwo.list[0].form.triggerList" :key="index">
            <div class="icon"></div>
            <div class="text">当用户做过
            <span style="font-weight: bold;">{{ item.list.find(i => i.value === item.triggerValue).label }}</span>
            对目标用户进行触达</div>
          </div>
        </template>
        <template v-else>
          <div class="li">
            <div class="icon"></div>
            <div class="text">触发时间：<span style="font-weight: bold;">{{ data.stepTwo.date }} {{ data.stepTwo.time }}</span></div>
          </div>
        </template>
      </div>
    </div>
    <div class="card">
      <div class="title">展示内容</div>
      <div class="content">
        <div style="width: 966.4px;height: 453.88px; position: absolute;top: 38px;left: 50%;transform: translateX(-50%);">
          <div class="bg"></div>
          <div class="card-dom">
            <div class="title" :style="`${getPosition(data.stepThree.titleParams.position)}${data.stepThree.titleParams.style}`">{{ data.stepThree.titleParams.textValue }}</div>
            <div class="describe" :style="`${getPosition(data.stepThree.describeParams.position)}${data.stepThree.describeParams.style}`">{{ data.stepThree.describeParams.textValue }}</div>
            <div class="btn" :style="`${getPosition(data.stepThree.btnParams.position)}${data.stepThree.btnParams.style}`">{{ data.stepThree.btnParams.textValue }}</div>
            <div class="img" :style="`background: url(${data.stepThree.imgParams.url});background-size:cover;${getPosition(data.stepThree.imgParams.position)}`"></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    data: { type: Object }
  },
  mounted() {
    console.log(this.data, 'data')
  },
  methods: {
    getPersonalMap(item) {
      return item.personalMap.find(i => i.value === item.personal)
    },
    // 获取位置值
    getPosition(item) {
      if (item) {
        if (item.left && item.top) {
          return `left: ${item.left}px;top: ${item.top}px;`
        } else {
          return item.left !== undefined ? `left: ${item.left}px;` : item.top !== undefined ? `top: ${item.top}px;` : ''
        }
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.four-box {
  margin-bottom: 20px;
  .card {
    background: rgba(250, 250, 250, 0.39);
    border: 1px solid #e8e8e8;
    border-radius: 16px;
    margin-bottom: 20px;
    padding: 20px;
    position: relative;
    .content {
      height: 500px;
      position: relative;
      .bg {
        // position: absolute;
        // top: 38px;
        // left: 50%;
        // transform: translateX(-50%);
        width: 966.4px;
        height: 453.88px;
        background: url(https://webapp-pub.ezijing.com/x-training-new/dn-bg.png);
        background-size: 100% 100%;
      }
      .card-dom {
        width: 431px;
        height: 238px;
        margin: 0 auto;
        background: rgba(255, 255, 255, 0.39);
        box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.12);
        position: absolute;
        top: 155px;
        left: 235px;
        z-index: 2;
        .title {
          width: 140px;
          position: absolute;
          top: 50px;
          left: 30px;
          font-size: 20px;
          font-weight: bold;
          color: #232325;
          cursor: pointer;
        }
        .describe {
          width: 140px;
          position: absolute;
          top: 80px;
          left: 30px;
          font-size: 14px;
          color: #999999;
          cursor: pointer;
        }
        .btn {
          position: absolute;
          top: 170px;
          left: 30px;
          padding: 5px 20px;
          font-size: 12px;
          background: rgba(73, 187, 162, 1);
          border-radius: 13px;
          color: #fff;
          cursor: pointer;
        }
        .img {
          width: 220px;
          height: 190px;
          position: absolute;
          top: 30px;
          left: 200px;
        }
      }
    }
    .title {
      font-size: 18px;
      font-weight: bold;
      line-height: 100%;
      color: #333333;
    }
    .ul-list {
      padding-top: 20px;
      .li {
        display: flex;
        align-items: center;
        margin-bottom: 15px;
        .icon {
          width: 6px;
          height: 6px;
          background: rgba(73, 187, 162, 0.39);
          border-radius: 50%;
        }
        .text {
          font-size: 16px;
          line-height: 100%;
          color: #666666;
          margin-left: 10px;
        }
      }
    }
  }
}
</style>
