<template>
  <div class="content">
    <div class="top" v-if="!isCluePage">
      <div class="left">计划：{{ $route.query.name }}</div>
      <div class="right" v-if="isRepeat">批次合计：{{ batchNum }} / 最新批次时间：{{ batchTimes }}</div>
    </div>
    <div class="middle" v-for="(item, index) in data" :key="index">
      <template v-if="item.isSales == 1">
        <div class="left center_flex" v-if="isReference && !isCluePage">
          <img :src="require('@/assets/img/experimentIcon.png')" class="icon" />
          <div style="margin-top: 7px">
            <span class="title">实验组</span>
            <span>-计划触达</span>
          </div>
        </div>
      </template>
      <template v-else>
        <div class="left center_flex" v-if="isReference && !isCluePage">
          <img :src="require('@/assets/img/referenceIcon.png')" class="icon" />
          <div style="margin-top: 7px">
            <span class="title">参照组</span>
            <span>-计划非触达</span>
          </div>
        </div>
      </template>
      <!--非线索页列表-->
      <div class="right">
        <div class="item-bg bg-purper center_flex min-w-173">
          <div>
            <p>{{ item.isSales == 1 ? '计划触达人数' : '参照组人数' }}<tip :text="item.isSales == 1 ? experText.planMbrText : controText.planMbrText" /></p>
            <p>{{ formatterNum(item.planMbrNum) }}</p>
          </div>
        </div>
        <div class="item-arrow purper center_flex" v-if="item.isSales == 1">
          <p>触达率</p>
          <p>{{ formatterRate(item.touchRate) }}</p>
        </div>
        <div v-else style="width: 96px"></div>
        <div class="item-bg bg-purper center_flex min-w-173" v-if="item.isSales == 1">
          <div>
            <p>实际触达人数<tip :text="experText.touchMbrText" /></p>
            <p>{{ formatterNum(item.touchMbrNum) }}</p>
          </div>
        </div>
        <div class="item-none center_flex  min-w-173" v-else>- -</div>
        <div class="item-arrow green center_flex">
          <p :class="{ active: isReference && item.isSales == 1 && data[0].transformRate < data[1].transformRate }">转化率</p>
          <p :class="{ active: isReference && item.isSales == 1 && data[0].transformRate < data[1].transformRate }">{{ formatterRate(item.transformRate) }}</p>
        </div>
        <div class="item-bg bg-green center_flex min-w-206">
          <div>
            <p style="min-width: 130px">{{ item.isSales == 1 ? '触达顾客转化人数' : '转化人数' }}<tip :text="item.isSales == 1 ? experText.convMbrText : controText.convMbrText" /></p>
            <p style="min-width: 130px">{{ formatterNum(item.convMbrNum) }}</p>
          </div>
        </div>
        <div class="item-bg bg-green min-w-389">
          <div>
            <p>{{ item.isSales == 1 ? '触达顾客订单数' : '转化订单数' }}<tip :text="item.isSales == 1 ? experText.convOrderText : controText.convOrderText" /></p>
            <p>{{ formatterNum(item.convOrderCnt) }}</p>
          </div>
          <div>
            <p>{{ item.isSales == 1 ? '触达顾客转化收益' : '转化收益' }}<tip :text="item.isSales == 1 ? experText.convSalesText : controText.convSalesText" /></p>
            <p>{{ formatterNumAndFixed(item.convSalesAmt) }}</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import formatterNum from '@/mixins/validateNum';
import tip from '@/components/tip';
export default {
  name: 'market-list',
  components: { tip },
  props: {
    // 是否是线索页面
    isCluePage: {
      type: Boolean,
      default: false
    },
    // 是否重复营销
    isRepeat: {
      type: Boolean,
      default: true
    },
    // 是否勾选参照组
    isReference: {
      type: Boolean,
      default: true
    },
    // 数据
    data: {
      type: Array,
      default: () => []
    },
    batchTimes: String,
    batchNum: Number | String
  },
  data() {
    return {
      // 实验组tip
      experText: {
        planMbrText: '当前智能营销在计划创建时，按照条件圈选的顾客人数。如果当前计划中，通过不同触达方式或不同时间，计划触达同一个顾客，会进行去重统计，仅计算为1个人。',
        touchMbrText: '当前智能营销通过指定触达方式，实际触达到的顾客数。如果当前计划中，通过不同触达方式或不同时间，实际触达了同一个顾客，会进行去重统计，仅计算为1个人。',
        convMbrText: '当前智能营销实际触达顾客中，在收益有效期内消费的顾客人数。无论顾客消费了几次，会进行去重统计，仅计算为1个人。',
        convOrderText: '当前智能营销实际触达顾客中，在收益有效期内消费的顾客订单数。',
        convSalesText: '当前智能营销实际触达顾客中，在收益有效期内消费的顾客订单金额。'
      },
      // 参照组tip
      controText: {
        planMbrText: '当前智能营销计划选择顾客范围中，未进行营销触达的顾客人数。用于与实验组进行对比，评估营销/未营销所带来的转化效果差异。',
        convMbrText: '当前智能营销计划选择顾客范围中，未进行营销触达的顾客人数，在收益有效期内产生消费的顾客人数。收益有效期按照实验组首次进行营销触达时间加收益分析天数统计。',
        convOrderText: '当前智能营销计划选择顾客范围中，未进行营销触达的顾客，在收益有效期内产生消费的订单数量。收益有效期按照实验组首次进行营销触达时间加收益分析天数统计。',
        convSalesText: '当前智能营销计划选择顾客范围里，未进行营销触达的顾客，在收益有效期内产生消费的订单金额。收益有效期按照实验组首次进行营销触达时间加收益分析天数统计。'
      }
    };
  },
  mixins: [formatterNum]
};
</script>
<style lang="scss" scoped>
.content {
  font-family: PingFangSC-Medium, PingFang SC;
  margin-left: 8px;
  margin-right: 13px;
  .top {
    color: #303133;
    height: 50px;
    background: #f5f7fa;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 10px 0;
    .left {
      font-size: 16px;
      font-weight: 600;
      line-height: 22px;
      padding-left: 27px;
    }
    .right {
      font-family: PingFangSC-Regular, PingFang SC;
      font-size: 14px;
      font-weight: 400;
      line-height: 20px;
      padding-right: 16px;
    }
  }
  .middle {
    height: 100px;
    display: flex;
    align-items: center;
    &:nth-of-type(3) {
      margin: 20px 0 3px;
    }
    .left {
      min-width: 173px;
      height: 100%;
      box-sizing: border-box;
      span {
        font-size: 14px;
        font-weight: 400;
        color: #606266;
        line-height: 20px;
        white-space: nowrap;
      }
      .title {
        font-weight: 600;
        color: #303133;
        margin-right: 4px;
      }
      .icon {
        width: 40px;
        height: 40px;
        border-radius: 4px;
        margin-right: 15px;
      }
    }
    .right {
      display: flex;
      align-items: center;
      justify-content: space-around;
      flex: 1;
      height: 100px;
      .item-bg {
        flex: 1;
        height: 100%;
        border-radius: 6px;
        box-sizing: border-box;
        &.bg-green {
          background: #e3fff8;
        }
        &.bg-purper {
          background: #f0f5ff;
        }
        p {
          &:nth-child(1) {
            font-size: 14px;
            font-family: PingFangSC-Regular, PingFang SC;
            color: #606266;
            line-height: 20px;
            padding-top: 4px;
            margin-bottom: 6px;
          }
          &:nth-child(2) {
            font-size: 24px;
            font-family: DINAlternate-Bold, DINAlternate;
            font-weight: bold;
            color: #303133;
            line-height: 28px;
          }
          .active {
            color: #f5222d;
            margin-left: 4px;
          }
        }
      }
      .item-arrow {
        width: 96px;
        height: 71px;
        align-items: flex-start;
        padding-left: 18px;
        box-sizing: border-box;
        &.purper {
          background: url('~@/assets/img/arrow_purper.png');
        }
        &.green {
          background: url('~@/assets/img/arrow_green.png');
        }
        p {
          width: 47px;
          font-size: 12px;
          line-height: 20px;
          color: #606266;
          font-family: PingFangSC-Regular, PingFang SC;
          &:nth-child(2) {
            font-family: DINAlternate-Bold, DINAlternate;
            font-weight: bold;
            color: #303133;
          }
        }
      }
      .item-none {
        flex: 1;
        height: 100px;
        font-family: PingFangSC-Regular, PingFang SC;
        color: #606266;
        line-height: 20px;
      }
    }
    .center_flex {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
    }
    .active {
      color: #f5222d !important;
    }
    .min-w-173 {
      min-width: 173px;
    }
    .min-w-206 {
      min-width: 206px;
    }
    .min-w-389 {
      min-width: 389px;
      margin-left: 5px;
      display: flex;
      align-items: center;
      padding: 0 42px 0 47px;
      box-sizing: border-box;
      div {
        flex: 1;
        text-align: left;
      }
    }
  }
}
</style>
