<template>
  <div class="find">
    <div class="header" @click="$router.push('/my-trade')" v-if="isLogin">
      <div class="box">
        <div class="left">
          <div class="flex">
            <img class="icon" src="/img/copy/market/icon1.png" alt="">
            <div class="lab">
              <!-- 跟单总收益(USD) -->
              {{ $t('follow.l1') }}(USD)
            </div>
          </div>
          <div class="amount">+ 237.68</div>
        </div>
        <div class="right">
          <div>
            <!-- 我的跟单 -->
            {{ $t('follow.l3') }}<van-icon name="arrow" />
          </div>
          <!-- 今日 -->
          <div class="today">
            + 12.37 <span class="lab1">{{ $t('follow.l2') }}</span>
          </div>
        </div>
      </div>
    </div>
    <followList v-if="followList.length" />
    <userList :list="stockList" market="stock" v-if="stockList.length" />
    <userList :list="cfdList" market="cfd" v-if="cfdList.length" />
    <swipeList />
    <applyBox v-if="expertInfo.status != 1" />
  </div>
</template>
<script>
import { mapGetters } from "vuex";
import followList from "./components/followList.vue";
import userList from "./components/userList.vue";
import swipeList from "./components/swipeList.vue";
import applyBox from "./components/applyBox.vue";
import { getExpertList } from "@/api/copy";
export default {
  components: {
    followList,
    userList,
    swipeList,
    applyBox
  },
  data () {
    return {
      stockList: [],
      cfdList: [],
      pageNum: 1,
      pageSize: 10,
      market: ['HK', 'US', 'CN'],
      market1: ['1', '2', '3', '4', '5'],
    }
  },
  computed: {
    ...mapGetters(['followList', 'expertInfo']),
  },
  created () {
    this.getExpertList(this.market, 'stockList')
    this.getExpertList(this.market1 , 'cfdList')
  },
  methods: {
    getExpertList(market, key) {
      getExpertList({
        pageNum: this.pageNum,
        pageSize: this.pageSize,
        productGroupList: JSON.stringify(market)
      }).then(res => {
        this[key] = res.list || []
      }).catch(() => {})
    },
  }
}
</script>
<style lang="less" scoped>
.find {
  padding-bottom: 20px;
}
.header {
  cursor: pointer;
  padding: 0 16px 10px;
  .box {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    column-gap: 12px;
    border-radius: 8px;
    border: 1px solid #F6F6F6;
    padding: 15px 9px;
  }
  .left {
    flex: 1;
    min-width: 0px;
  }
  .icon {
    width: 12px;
    margin-left: 2px;
  }
  .lab {
    flex: 1;
    min-width: 0px;
    padding-left: 6px;
    color: #B6B6B6;
  }
  .amount {
    font-size: 26px;
    margin-top: 14px;
  }
  .right {
    color: #B6B6B6;
    font-size: 12px;
    padding-top: 1px;
    text-align: right;
  }
  .today {
    margin-top: 26px;
  }
}
</style>