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

    <div class="detail_layout">
Z
Zachary 已提交
11 12
      <div class="detail_layout__main">
        <detail-songlist :songs="songs" :listType="'playlist'" />
13 14 15 16 17 18 19 20
        <!-- comment -->
        <commont-box
          :comments="comments"
          :limit="pageSize"
          :currentPage="commentPage"
          :total="commentCount"
          @current-change="currentChange"
        />
Z
update  
Zachary 已提交
21
      </div>
Z
Zachary 已提交
22

Z
update  
Zachary 已提交
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
      <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
          > -->
41
          <a class="btn_edit js_edit" style="display: none">
Z
Zachary 已提交
42 43
            <i class="icon_txt">编辑</i>
          </a>
Z
update  
Zachary 已提交
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
        </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 已提交
59
import DetailSonglist from "components/common/DetailSonglist";
60 61 62 63 64 65 66
import CommontBox from "components/common/CommontBox";
import {
  getPlayList,
  getPlaylistDetial,
  getSongDetail,
  getCommentsNew,
} from "api";
Z
update  
Zachary 已提交
67 68 69 70 71 72 73 74
import { processCount, createSong, playSonglist } from "common/utils";

export default {
  data() {
    return {
      id: this.$route.query.id,
      playlist: {},
      songs: [],
75 76 77 78
      pageSize: 20,
      commentPage: 1,
      commentCount: 0,
      comments: [],
Z
update  
Zachary 已提交
79 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
    };
  },
  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 已提交
105
          console.log(res.data.songs);
Z
update  
Zachary 已提交
106 107 108 109 110 111 112 113
          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 已提交
114
              albumId: al.id,
Z
update  
Zachary 已提交
115 116 117 118 119
              img: al.picUrl,
            });
          });
          this.songs = songs;
        });
120
        this.getComment();
Z
update  
Zachary 已提交
121 122 123
      });
    },
    cardClick(v) {
124
      if (v == "all") playSonglist(this.songs);
Z
update  
Zachary 已提交
125
    },
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
    getComment() {
      let params = {
        type: 2,
        pageSize: this.pageSize,
        pageNo: this.commentPage,
        id: this.playlist.id,
        sortType: 2,
      };
      getCommentsNew(params).then((res) => {
        this.commentCount =
          res.data.data.totalCount > 5000 ? 5000 : res.data.data.totalCount;
        this.comments = res.data.data.comments;
      });
    },
    currentChange(v) {
      this.commentPage = v;
    },
  },
  watch: {
    commentPage() {
      this.getComment();
    },
Z
update  
Zachary 已提交
148 149 150
  },
  components: {
    DetailInfoCard,
Z
Zachary 已提交
151
    DetailSonglist,
152
    CommontBox,
Z
update  
Zachary 已提交
153 154 155 156 157 158
  },
};
</script>

<style scoped>
</style>