PlaylistDetail.vue 3.0 KB
Newer Older
Z
update  
Zachary 已提交
1
<template>
Z
Zachary 已提交
2
  <div class="main">
Z
Zachary 已提交
3
    <detail-info-card :obj="playlist" :cardType="'pl'" @btnClick="cardClick" />
Z
update  
Zachary 已提交
4 5

    <div class="detail_layout">
Z
Zachary 已提交
6 7
      <div class="detail_layout__main">
        <detail-songlist :songs="songs" :listType="'playlist'" />
Z
update  
Zachary 已提交
8
      </div>
Z
Zachary 已提交
9

Z
update  
Zachary 已提交
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
      <div class="detail_layout__other">
        <div class="mod_about js_box" id="album_desc" style="display: ">
          <h3 class="about__tit">简介</h3>
          <div class="about__cont">
            <p>
              {{ playlist.desc }}
            </p>
          </div>
          <!-- <a
            href="javascript:;"
            class="about__more"
            data-stat="y_new.gedan.moreinfo"
            data-left="0"
            data-top="-187"
            data-target="popup_data_detail"
            style="display: "
            >[更多]</a
          > -->
28
          <a class="btn_edit js_edit" style="display: none">
Z
Zachary 已提交
29 30
            <i class="icon_txt">编辑</i>
          </a>
Z
update  
Zachary 已提交
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
        </div>

        <div class="other_part" id="similaralbum" style="display: none">
          <h3 class="other_part__tit">相似歌单</h3>
          <div class="mod_playlist">
            <ul class="playlist__list"></ul>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import DetailInfoCard from "components/common/DetailInfoCard";
Z
Zachary 已提交
46
import DetailSonglist from "components/common/DetailSonglist";
Z
update  
Zachary 已提交
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 79 80 81
import { getPlayList, getPlaylistDetial, getSongDetail } from "api";
import { processCount, createSong, playSonglist } from "common/utils";

export default {
  data() {
    return {
      id: this.$route.query.id,
      playlist: {},
      songs: [],
    };
  },
  created() {
    this.init();
  },
  methods: {
    init() {
      getPlaylistDetial(this.id).then((res) => {
        console.log(res);
        let d = res.data.playlist;
        this.playlist = {
          id: d.id,
          name: d.name,
          img: d.coverImgUrl,
          desc: d.description,
          creator: d.creator.nickname,
          creatorId: d.creator.userId,
          tags: d.creator.expertTags,
          playCount: processCount(d.playCount),
          subscribedCount: processCount(d.subscribedCount),
          shareCount: processCount(d.shareCount),
        };
        console.log(this.playlist);

        let trackIds = res.data.playlist.trackIds.map(({ id }) => id);
        let songDetails = getSongDetail(trackIds.slice(0, 500)).then((res) => {
Z
Zachary 已提交
82
          console.log(res.data.songs);
Z
update  
Zachary 已提交
83 84 85 86 87 88 89 90
          let songs = res.data.songs.map(({ id, name, al, ar, mv, dt }) => {
            return createSong({
              id,
              name,
              artists: ar,
              duration: dt,
              mvId: mv,
              albumName: al.name,
Z
Zachary 已提交
91
              albumId: al.id,
Z
update  
Zachary 已提交
92 93 94 95 96 97 98 99
              img: al.picUrl,
            });
          });
          this.songs = songs;
        });
      });
    },
    cardClick(v) {
100
      if (v == "all") playSonglist(this.songs);
Z
update  
Zachary 已提交
101 102 103 104
    },
  },
  components: {
    DetailInfoCard,
Z
Zachary 已提交
105
    DetailSonglist,
Z
update  
Zachary 已提交
106 107 108 109 110 111
  },
};
</script>

<style scoped>
</style>