<template>
  <div>
    <div class="btns flex">
      <div class="btn" :class="{active: market === '1'}" @click="tabChange('1')">
        <!-- 发现 -->
        {{ $t('tab.tab4') }}
        <div class="line"></div>
      </div>
      <div class="btn" :class="{active: market === '2'}" @click="tabChange('2')">
        <!-- 股票 -->
        {{ $t('download.l26') }}
        <div class="line"></div>
      </div>
      <div class="btn" :class="{active: market === '3'}" @click="tabChange('3')">
        <!-- 综合 -->
        {{ $t('market.l10') }}
        <div class="line"></div>
      </div>
      <div class="href flex" @click="$router.push('/my-copy')">
        <div>
          <!-- 专家主页 -->
          {{ $t('follow.l166') }}
        </div>
        <van-icon name="arrow" />
      </div>
    </div>
    <findView v-if="market == '1'" />
    <tradingExperts v-if="market == '2'" :market="market"/>
    <tradingExperts v-if="market == '3'" :market="market"/>
  </div>
</template>
<script>
import findView from "./find";
import tradingExperts from "./tradingExperts";
export default {
  components: {
    findView,
    tradingExperts
  },
  data () {
    return {
      market: '1',
    }
  },
  watch: {
    '$route'() {
      if (this.$route.name == 'follow') {
        if (this.$route.params.market) {
          this.market = this.$route.params.market
        }
      }
    }
  },
  activated () {
    if (this.isLogin) {
      this.$store.dispatch('getFollowList')
      this.$store.dispatch('getExpertInfo')
    }
  },
  created () {
    if (this.$route.params.market) {
      this.market = this.$route.params.market
    }
  },
  methods: {
    tabChange(val) {
      if (this.market == val) {
        return
      }
      this.market = val
      this.$router.replace('/market/follow/' + val)
    },
  }
}
</script>
<style lang="less" scoped>
.btns {
  position: sticky;
  top: 50px;
  z-index: 4;
  height: 52px;
  padding: 0 16px;
  align-items: flex-end;
  white-space: nowrap;
  flex-wrap: nowrap;
  overflow-x: auto;
  background-color: #fff;
  &::-webkit-scrollbar {
    display: none;
  }
  .btn {
    cursor: pointer;
    font-size: 14px;
    color: #888888;
    padding-bottom: 18px;
    position: relative;
    &+.btn {
      margin-left: 24px;
    }
    &.active {
      font-size: 16px;
      font-weight: 600;
      color: #000;
      .line {
        display: block;
      }
    }
  }
  .href {
    position: absolute;
    top: 18px;
    right: 13px;
    color: #4670F6;
    cursor: pointer;
  }
  .line {
    position: absolute;
    left: 50%;
    bottom: 10px;
    transform: translateX(-50%);
    width: 12px;
    height: 2px;
    border-radius: 1px;
    background-color: #000;
    display: none;
  }
}
</style>