<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 === 0 ? '单次触发' : '条件触发' }}
          </div>
        </div>
        <div class="li" v-for="(item, index) in getStepTwoValue()" :key="index">
          <div class="icon"></div>
          <div class="text" v-html="item">
          </div>
        </div>
      </div>
    </div>
    <div class="card">
      <div class="title">展示内容</div>
      <div class="phone-box">
        <div class="card-content">
          <div class="img" :style="`background-image:url(${data.stepThree.imgParams.url});`"></div>
          <div class="title" :style="data.stepThree.titleParams.style">{{ data.stepThree.titleParams.textValue || '请输入' }}</div>
          <div class="desc" :style="data.stepThree.describeParams.style">{{ data.stepThree.describeParams.textValue || '请输入' }}</div>
          <div class="btn" :style="data.stepThree.btnParams.style">{{ data.stepThree.btnParams.textValue || '请输入' }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    data: { type: Object }
  },
  mounted() {
    this.getStepTwoValue()
  },
  methods: {
    getPersonalMap(item) {
      return item.personalMap.find(i => i.value === item.personal)
    },
    // 获取位置值
    getStepTwoValue() {
      const arr = []
      const data = this.data.stepTwo
      if (!data.index) {
        this.data.stepTwo.list[0].form.triggerList.forEach(item => {
          if (item.startValue === 'start') {
            arr.push('当用户做过启动App后出现弹窗')
          } else {
            const d = item.personalMap.find(i => i.value === 'trigger').children.find(i => i.value === item.triggerValue)
            arr.push(`当用户做过指定App页<span style="font-weight:bold">${d.label}</span>出现弹窗 `)
          }
        })
      } else {
        this.data.stepTwo.list2[0].form.triggerList.forEach(item => {
          arr.push(`当用户做过 <span style="font-weight:bold">${item.list.find(i => i.value === item.triggerValue).label}</span> 对目标用户进行触达`)
        })
      }
      return arr
    }
  }
}
</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;
    .content {
      height: 500px;
      position: relative;
      .phone-box {
        margin: 0 auto;
        width: 236px;
        height: 474px;
        background: url(https://webapp-pub.ezijing.com/x-training-new/phone-sms.png);
        background-size: 100% 100%;
        position: relative;
        .text {
          padding: 9px;
          box-sizing: border-box;
          background: #e9e9eb;
          border-radius: 10px;
          width: 148px;
          position: absolute;
          top: 110px;
          left: 25px;
          font-size: 9px;
          color: #333333;
        }
      }
    }
    .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;
          min-width: 6px;
          height: 6px;
          min-height: 6px;
          background: rgba(73, 187, 162, 0.39);
          border-radius: 50%;
        }
        .text {
          font-size: 16px;
          color: #666666;
          margin-left: 10px;
        }
      }
    }
  }
}
.phone-box{
  margin: 0 auto;
  width: 236px;
  height: 474px;
  background: url(https://webapp-pub.ezijing.com/x-training-new/phone-app.png);
  background-size: 100% 100%;
  position: relative;
  .card-content{
    width: 164px;
    position: absolute;
    top: 50%;
    left:50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 1);
    border-radius: 6px;
    .img{
      height: 87px;
      background-size:100% 100%;
    }
    .title{
      padding: 15px 0 5px;
      font-size: 14px;
      font-weight: bold;
      line-height: 20px;
      color: #333333;
      text-align: center;
    }
    .desc{
      width: 137px;
      font-size: 12px;
      line-height: 20px;
      color: #6D6D71;
      margin: 0 auto;
    }
    .btn{
      width: 137px;
      background: #49BBA2;
      border-radius: 4px;
      text-align: center;
      line-height: 20px;
      font-size: 12px;
      margin: 22px auto 12px;
      color:#fff;
    }
  }
}
</style>
