<template>
  <div class="market">
    <div class="list">
      <div class="title flex" @click="$router.replace(marketUrl[market])">
        <div class="flex">
          <van-image
            width="14"
            height="14"
            round
            fit="cover"
            :src="`/img/user/${marketEn[market]}.png`"
          />
          <div>{{ title[market] }}</div>
        </div>
        <img class="icon" src="/img/deposit/right.png" alt="极度证券">
      </div>
      <div class="ul">
        <div class="li flex" v-for="(item, index) in list" :key="item" @click="$router.push('/product-detail/' + item)">
          <div class="left">
            <div class="number" :class="{active: index < 3}">{{ index+1 }}</div>
            <div v-if="productDataObj[item]">
              <div class="name">{{ productDataObj[item].title }}</div>
              <div class="symbol">{{ item }}</div>
            </div>
          </div>
          <div v-if="productDataObj[item]" class="right" :class="{'down': productDataObj[item].spread < 0}">
            {{ productDataObj[item].spread > 0 ? '+' : ''  }}{{ productDataObj[item].percentage }}%
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: ['market', 'list'],
  inject: ['getproductDataObj'],
  data () {
    return {
    }
  },
  computed: {
    productDataObj() {
      return this.getproductDataObj()
    },
    marketEn() {
      return {
        '13': 'US',
        '15': 'HK',
        '14': 'CN',
        '11': 'CFD',
      }
    },
    marketUrl() {
      return {
        '13': '/market/stock/US',
        '15': '/market/stock/HK',
        '14': '/market/stock/CN',
        '11': '/market/cfd',
      }
    },
    title() {
      return {
        // 'US': '美股热度榜',
        // 'HK': '港股热度榜',
        // 'CN': 'A股热度榜',
        '13': this.$t('exchange.l55'),
        '15': this.$t('exchange.l56'),
        '14': this.$t('exchange.l57'),
        '11': this.$t('exchange.l77'),
      }
    }
  },
  created () {
  },
  methods: {
    toList() {
      var url = {
        '13': ''
      }
    }
  }
}
</script>
<style lang="less" scoped>
.market {
  padding: 24px 18px 30px;
}
.list {
  background-color: #FAFBFC;
  border-radius: 6px;
  padding: 0 11px 11px;
  .title {
    column-gap: 4px;
    height: 40px;
    font-weight: 500;
    color: var(--color-1-);
    justify-content: space-between;
    cursor: pointer;
    .icon {
      width: 8px;
    }
    .van-image {
      margin-right: 3px;
    }
  }
  .li {
    height: 53px;
    border-top: 1px solid #EBEBEB;
    justify-content: space-between;
    cursor: pointer;
  }
  .left {
    display: flex;
    align-items: center;
    font-size: 14px;
    column-gap: 9px;
  }
  .name {
    color: var(--color-1-);
    margin-bottom: 5px;
  }
  .symbol {
    color: #636465;
    font-size: 12px;
  }
  .number {
    font-size: 14px;
    font-weight: 600;
    color: #636465;
    &.active {
      color: var(--color-);
    }
  }
  .right {
    font-size: 14px;
    color: #E22404;
    &.down {
      color: #22B673;
    }
  }
}
</style>