<template>
  <div class="pop">
    <div class="header flex">
      <div class="left">
        <!-- K线指标设置 -->
        {{ $t('product.l138') }}
      </div>
      <div class="right flex" @click="reset">
        <van-icon name="replay" />
        <div>
          <!-- 恢复默认 -->
          {{ $t('product.l139') }}
        </div>
      </div>
    </div>
    <div class="box">
      <div class="cell">
        <div class="label">
          <!-- 主图 -->
          {{ $t('product.l140') }}
        </div>
        <div class="left flex">
          <div class="btn" :class="{active: mainImage == 'MA'}" @click="switchMainImage(mainImage == 'MA' ? 'null' : 'MA')">
            MA
          </div>
          <div class="btn" :class="{active: mainImage == 'BOLL'}" @click="switchMainImage(mainImage == 'BOLL' ? 'null' : 'BOLL')">
            BOLL
          </div>
        </div>
        <div class="right" :class="{active: mainImage == 'null'}" @click="switchMainImage('null')">
          <!-- 隐藏 -->
          {{ $t('product.l141') }}
        </div>
      </div>
      <div class="cell">
        <div class="label">
          <!-- 副图 -->
          {{ $t('product.l142') }}
        </div>
        <div class="left flex">
          <div class="btn" v-for="(val, item) in indicatorObj" :key="item" :class="{active: indicator == item}" @click="switchIndicator(indicator == item ? 'null' : item)">
            {{ item }}
          </div>
        </div>
        <div class="right" @click="switchIndicator('null')">
          <!-- 隐藏 -->
          {{ $t('product.l141') }}
        </div>
      </div>
    </div>
    <div class="header flex">
      <div class="left">
        <!-- K线样式设置 -->
        {{ $t('product.l143') }}
      </div>
    </div>
    <div class="box">
      <div class="cell">
        <div class="label">
          <!-- 样式 -->
          {{ $t('product.l144') }}
        </div>
        <div class="left flex">
          <div class="btn1" :class="{active: candleType == 'candle_solid'}" @click="switchCandleType('candle_solid')">
            <!-- 实心 -->
            {{ $t('product.l145') }}
          </div>
          <div class="btn1" :class="{active: candleType == 'candle_stroke'}" @click="switchCandleType('candle_stroke')">
            <!-- 空心 -->
            {{ $t('product.l146') }}
          </div>
        </div>
      </div>
      <div class="cell">
        <div class="label">
          <!-- 颜色 -->
          {{ $t('product.l147') }}
        </div>
        <div class="left flex">
          <div class="btn1" :class="{active: kLineColorSign == '0'}" @click="switchKLineColorSign('0')">
            <!-- 红涨绿跌 -->
            {{ $t('product.l148') }}
          </div>
          <div class="btn1" :class="{active: kLineColorSign == '1'}" @click="switchKLineColorSign('1')">
            <!-- 绿涨红跌 -->
            {{ $t('product.l149') }}
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: ['mainImage', 'candleType', 'kLineColorSign', 'indicator'],
  data () {
    return {
      indicatorObj: {
        MACD: false,
        KDJ: false,
        RSI: false,
        WR: false,
        // EMA: false,
        // BRAR: false,
      },
    }
  },
  methods: {
    reset() {
      this.switchCandleType('candle_solid')
      this.switchKLineColorSign('0')
      this.switchMainImage('MA')
      this.switchIndicator('MACD')
    },
    switchCandleType(key) {
      this.$emit('cancel')
      if (this.candleType == key) {
        return
      }
      this.$emit('switchCandleType', key)
    },
    switchKLineColorSign(key) {
      this.$emit('cancel')
      if (this.kLineColorSign == key) {
        return
      }
      this.$emit('switchKLineColorSign', key)
    },
    switchMainImage(key) {
      this.$emit('switchMainImage', key)
      this.$emit('cancel')
    },
    switchIndicator(key) {
      this.$emit('switchIndicator', key)
      this.$emit('cancel')
    }
  }
}
</script>
<style lang="less" scoped>
.pop {
  padding-bottom: 10px;
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
.header {
  height: 57px;
  border-bottom: 1px solid #F6F6F6;
  justify-content: space-between;
  padding-left: 10px;
  padding-right: 14px;
  column-gap: 16px;
  .left {
    flex: 1;
    min-width: 50%;
    font-size: 16px;
  }
  .right {
    padding-bottom: 2px;
    font-size: 14px;
    column-gap: 6px;
    word-break: break-all;
    .van-icon {
      transform: rotate(45deg);
    }
  }
}
.box {
  padding: 25px 20px 20px 10px;
}
.cell {
  display: flex;
  align-items: flex-start;
  &+.cell {
    margin-top: 22px;
  }
  .label {
    width: 48px;
    word-break: break-all;
    padding-right: 3px;
    line-height: 22px;
  }
  .left {
    flex: 1;
    min-width: 0px;
    flex-wrap: wrap;
    column-gap: 10px;
    row-gap: 14px;
  }
  .right {
    color: #888888;
    cursor: pointer;
    line-height: 22px;
    padding-left: 2px;
    &.active {
      color: #000;
    }
  }
  .btn {
    cursor: pointer;
    width: 54px;
    text-align: center;
    border-radius: 2px;
    border: 1px solid #F6F6F6;
    line-height: 20px;
    color: #888888;
    &.active {
      color: #000000;
      border-color: #000;
    }
  }
  .btn1 {
    cursor: pointer;
    padding: 0 2px;
    min-width: 68px;
    text-align: center;
    border-radius: 2px;
    border: 1px solid #F6F6F6;
    line-height: 20px;
    color: #888888;
    &.active {
      color: #000000;
      border-color: #000;
    }
  }
}
</style>