Like.vue 2.5 KB
Newer Older
Z
Zachary 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
<template>
  <div class="js_box" id="like_box" style="display: block">
    <div class="mod_tab" role="nav">
      <a
        class="mod_tab__item"
        href="javascript:;"
        data-tab="like_song"
        data-stat="y_new.profile.like.tab.song"
        v-for="option in options"
        :key="option"
        :class="option == selected ? 'mod_tab__current' : ''"
        @click="select(option)"
        >{{ option }}</a
      >
    </div>
    <div class="profile_cont">
Z
Zachary 已提交
17 18
      <detail-lists :lists="playlists" :kind="1" v-if="selected == '歌单'" />
      <detail-lists :lists="albums" v-if="selected == '专辑'" />
Z
Zachary 已提交
19 20 21 22 23 24 25
      <show-mvs :mvs="mvs" v-if="selected == '视频'" />
    </div>
  </div>
</template>


<script>
Z
Zachary 已提交
26
import DetailLists from "components/common/DetailLists";
Z
Zachary 已提交
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
import ShowMvs from "components/common/ShowMvs";
import { getUserPlaylists, getCollectedAlbum, getCollectedMvs } from "api";
import { createPlaylists, createAlbums, createMvs } from "common/utils";

export default {
  data() {
    return {
      selected: "歌单",
      options: ["歌单", "专辑", "视频"],
      playlists: [],
      albums: [],
      mvs: [],
    };
  },
  mounted() {
    this.getUserPlaylists();
    this.getCollectedAlbum();
    this.getCollectedMvs();
  },
  methods: {
    select(option) {
      if (option != this.selected) {
        this.selected = option;
      }
    },
    getUserPlaylists() {
      getUserPlaylists(this.userId).then((res) => {
        let lists = createPlaylists(res.data.playlist);
        this.playlists = lists;
      });
    },
    getCollectedAlbum() {
      getCollectedAlbum().then((res) => {
        let d = createAlbums(res.data.data);
        this.albums = d;
      });
    },
    getCollectedMvs() {
      getCollectedMvs().then((res) => {
        console.log(res);
        let d = createMvs(res.data.data);
        console.log(d);
        this.mvs = d;
      });
    },
  },
  computed: {
    userId() {
      return this.$store.state.user.user.userId;
    },
  },
  components: {
Z
Zachary 已提交
79
    DetailLists,
Z
Zachary 已提交
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
    ShowMvs,
  },
};
</script>

<style scoped>
.mod_tab,
.mod_tab__item {
  height: 56px;
  line-height: 56px;
}
.mod_tab {
  position: relative;
  zoom: 1;
  border-bottom: 1px solid #f7f7f7;
  margin-bottom: 30px;
}
.mod_tab {
  margin-bottom: -20px;
  overflow: hidden;
  border-bottom: 0 none;
}
.mod_tab,
.mod_tab__item {
  height: 56px;
  line-height: 56px;
}
.mod_tab__item {
  position: relative;
  float: left;
  font-size: 16px;
  overflow: hidden;
  margin-right: 55px;
}
.mod_tab__current {
  color: #31c27c;
}
</style>