vue导航栏切换内容

<template>
  <div class="revenue_page">
    <div class="reven_main">
      <div class="reven_nav">
        <div
          :class="{ 'li-activate': navIndex == index }"
          v-for="(item, index) in menuItems"
          :key="item.name"
          @click="clickCategory(item.name, index)"
        >
          <div
            :class="navIndex == index ? 'menu-item-title' : 'not_item-title'"
          >
            {{ item.title }}
          </div>
          <p :class="{ 'navBox-li-line': navIndex == index }"></p>
        </div>
      </div>
      <div class="user-list">
        <div class="content_title">
          <p class="title-text">排行榜{{ activeName }}</p>
        </div>
        <div class="con_list" v-show="boardItems.length > 0">
          <div v-for="(item, index) in boardItems" :key="index">
            <div class="user-list-item">
              <div class="user-list_left">
                <div class="user-list-item-rank">
                  {{ index + 1 }}
                </div>
                <div class="user-list-item-avatar">
                  <img
                    :src="`//qn.jwshq.cn/${
                      item.icon || 'profile_unknown.png'
                    }/50`"
                    class="user_head_img"
                  />
                </div>
                <div class="user-list-item-name">
                  {{
                    item.name && item.name.length > 12
                      ? item.name.substr(0, 12) + "..."
                      : item.name
                  }}
                </div>
              </div>
              <div class="user-list_right">
                <p class="user-award" v-if="item.award">
                  {{ (item.award / 100).toFixed(2) }}元
                </p>
              </div>
            </div>
            <div class="line"></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: 'RevenueRanking',
  data () {
    return {
      active: 'weekly',
      menuItems: [{
        name: 'daily',
        title: '日榜'
      }, {
        name: 'weekly',
        title: '周榜'
      }, {
        name: 'all',
        title: '总榜'
      }],
      navIndex: 1,
      boards: {
        daily: [
          {
            name: '李丽丽',
            award: 814683,
            icon: "Q5XHUom.2592.2592.0.1002",
          },
          {
            name: '李丽丽',
            award: 814683,
            icon: "Q5XHUom.2592.2592.0.1002",
          },
        ],
        weekly: [
          {
            name: '张果果',
            award: 814683,
            icon: "QM86vaF.1080.1080.0.1004"
          },
          {
            name: '张果果',
            award: 814683,
            icon: "Q5XHUom.2592.2592.0.1002",
          },
        ],
        all: [
          {
            name: '王晓小',
            award: 814683,
            icon: "ncnkLkw.960.960.0.1000",
          },
          {
            name: '王晓小',
            award: 814683,
            icon: "Q5XHUom.2592.2592.0.1002",
          },
        ]
      },
    };
  },
  methods: {
    clickCategory (name, index) {
      this.navIndex = index
      this.active = name
    },
  },
  computed: {
    //标题
    activeName () {
      return this.menuItems.find(e => e.name === this.active).title;
    },

    boardItems () {
      //取数据第一种的方法
      // if (this.navIndex == 0) {
      //   return this.boards.daily
      // } else if (this.navIndex == 1) {
      //   return this.boards.weekly
      // } else if (this.navIndex == 2) {
      //   return this.boards.all
      // } else {
      //   return []
      // }
      //取数据第二种的方法
      return this.active in this.boards ? this.boards[this.active] : [];
    }
  }
};
</script>
<style scoped lang="less">
* {
  margin: 0;
  padding: 0;
}

.revenue_page {
  width: 100%;
  overflow: hidden;
}
.reven_main {
  width: 100%;
  height: 64px;
}
.user-list {
  width: 94%;
  margin-left: 3%;
  opacity: 1;
  background: linear-gradient(180deg, #fff1f1, #ffffff 29%);
  border-radius: 12px;
  box-shadow: 0px 6px 10px 2px rgba(206, 63, 0, 0.15);
  position: absolute;
  top: 63px;
  padding-bottom: 44px;
}
.reven_nav {
  width: 60%;
  height: 44px;
  margin-left: 20%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  line-height: 44px;
}
.user-item {
  font-size: 15px;
  font-family: PingFangSC, PingFangSC-Medium;
  font-weight: 500;
  text-align: right;
  color: #ffffff;
  opacity: 0.6;
}
.navBox-li-line {
  width: 100%;
  position: absolute;
  top: 40px;
  height: 3px;
  background: red;
  border-top-left-radius: 100px;
  border-top-right-radius: 100px;
  padding-left: 8px;
  padding-right: 8px;
  margin-left: -8px;
}
.menu-item-title {
  font-size: 15px;
  font-family: PingFangSC, PingFangSC-Medium;
  font-weight: 500;
  text-align: right;
  color: red;
  margin: 0;
}
.not_item-title {
  font-size: 15px;
  font-family: PingFangSC, PingFangSC-Medium;
  font-weight: 500;
  text-align: right;
  // color: #ff;
  opacity: 0.6;
  margin: 0;
}
.li-activate {
  width: auto;
  height: 100%;
  display: inline-block;
  position: relative;
  font-size: 15px;
  font-family: PingFangSC, PingFangSC-Medium;
  font-weight: 500;
  color: #9da0a4;
}
.item_name {
  font-size: 13px;
  text-align: left;
  color: #ffffff;
}
.content_title {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 25px;
}

.title-text {
  font-size: 17px;
  font-family: PingFangSC, PingFangSC-Semibold;
  font-weight: 600;
  text-align: left;
  color: #ff4500;
  padding: 0 9px;
}
.user_head_img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  margin-left: 20px;
}
.con_list {
  margin-top: 14px;
  margin-left: 24px;
  margin-right: 24px;
}
.user-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.hot_icon {
  width: 13px;
  height: 13px;
  margin-right: 2px;
}
.user-award {
  font-size: 14px;
  font-family: PingFangSC, PingFangSC-Medium;
  font-weight: 500;
  text-align: center;
  color: #ff1d28;
}
.user-list_left {
  display: flex;
  align-items: center;
  flex: 2;
}
.user-list_right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex: 1;
}
.user-list-item-rank {
  font-size: 18px;
  font-family: PingFangSC, PingFangSC-Medium;
  font-weight: 500;
  text-align: center;
  color: #333333;
}
.user-list-item-name {
  font-size: 14px;
  font-family: PingFangSC, PingFangSC-Medium;
  font-weight: 500;
  color: #333333;
  margin-left: 10px;
}
.line {
  background: #e5e5e5;
  height: 0.5px;
  width: 100%;
  margin: 14px 0;
}
</style>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值