<template>
  <div>
    <van-sticky class="sticky">
      <div class="header">
        <div class="back">
          <backIcon/>
        </div>
        牛股情报
        <div class="right">
          <van-popover
          v-model="showPopover"
          placement="bottom-end"
          trigger="click"
        >
          <div class="popover-body">
            <div class="item flex">
              <img class="icon" src="/img/bull/home/icon1.png" alt="极度证券">
              <div>申请情报作者</div>
            </div>
            <div class="item flex">
              <img class="icon" src="/img/bull/home/icon2.png" alt="极度证券">
              <div>情报管理</div>
            </div>
            <div class="item flex">
              <img class="icon" src="/img/bull/home/icon3.png" alt="极度证券">
              <div>已购情报</div>
            </div>
            <div class="item flex">
              <img class="icon" src="/img/bull/home/icon4.png" alt="极度证券">
              <div>阅读记录</div>
            </div>
          </div>
          <template #reference>
            <div>申请</div>
          </template>
        </van-popover>
        </div>
      </div>
      <div class="tab-list flex">
        <div class="tab" :class="{active: type == 1}" @click="changeType(1)">
          情报首页
          <div class="line"></div>
        </div>
        <div class="tab" :class="{active: type == 2}" @click="changeType(2)">
          作者专栏
          <div class="line"></div>
        </div>
        <div class="tab" :class="{active: type == 3}" @click="changeType(3)">
          我的关注
          <div class="line"></div>
        </div>
      </div>
    </van-sticky>
    <infoView v-if="type == 1" />
    <authorView v-if="type == 2" />
    <followView v-if="type == 3" />
  </div>
</template>
<script>
import infoView from "./info/index.vue";
import authorView from "./author/index.vue";
import followView from "./follow/index.vue";
export default {
  components: {
    infoView,
    authorView,
    followView
  },
  data () {
    return {
      type: '1',
      showPopover: false
    }
  },
  created () {
    this.type = this.$route.params.type
  },
  methods: {
    changeType(type) {
      if (this.type == type) {
        return
      }
      this.type = type
      this.$router.replace('/bull-information/' + type)
    }
  }
}
</script>
<style lang="less" scoped>
.sticky {
  background-color: var(--bg-);
}
.header {
  position: relative;
  text-align: center;
  padding-top: 15px;
  padding-bottom: 17px;
  font-size: 18px;
  font-weight: 600;
  background-color: var(--bg-);
  .back {
    position: absolute;
    left: 9px;
    top: 11px;
  }
  .right {
    position: absolute;
    right: 12px;
    top: 16px;
    color: var(--color-);
    font-size: 16px;
    font-weight: 400;
  }
}
.tab-list {
  background-color: #fff;
  justify-content: center;
  column-gap: 47px;
  box-shadow: 0px 1px 0px 0px rgba(230,230,230,0.5);
  .tab {
    cursor: pointer;
    position: relative;
    line-height: 50px;
    font-size: 16px;
    color: var(--color-1-);
    &.active {
      font-size: 18px;
      font-weight: 600;
      color: var(--color-);
      .line {
        background-color: var(--color-);
      }
    }
    .line {
      position: absolute;
      left: 0;
      right: 0;
      bottom: 0;
      height: 2px;
      background-color: transparent;
      border-radius: 2px;
    }
  }
}

.popover-body {
  .item {
    cursor: pointer;
    height: 42px;
    padding-left: 16px;
    color: #2C2C2C;
    font-size: 14px;
    width: 141px;
    line-height: 1;
    &+.item {
      border-top: 1px solid #E9E9E9;
    }
  }
  .icon {
    width: 22px;
    margin-right: 4px;
  }
}
</style>