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

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

      <div class="detail_layout__other">
        <div class="mod_about" id="album_desc" style="display: ">
          <h3 class="about__tit">简介</h3>
          <div class="about__cont">
            <p>{{ album.desc }}</p>
          </div>
Z
Zachary 已提交
29
          <a class="about__more" @click="toggleShowMoreInfo">[更多]</a>
Z
Zachary 已提交
30 31 32
        </div>
      </div>
    </div>
Z
Zachary 已提交
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49

    <div
      class="popup_data_detail"
      id="popup_data_detail"
      style="z-index: 2147483647"
      :style="{ display: moreInfo ? '' : 'none' }"
      v-if="album.desc"
    >
      <div class="popup_data_detail__cont">
        <h3 class="popup_data_detail__tit">歌手简介</h3>
        <p v-for="(line, idx) in album.desc.split('\n')" :key="idx">
          {{ line }}
        </p>
        <p></p>
      </div>
      <i class="popup_data_detail__arrow"></i>
    </div>
Z
Zachary 已提交
50 51 52 53
  </div>
</template>

<script>
Z
update  
Zachary 已提交
54
import DetailInfoCard from "components/common/DetailInfoCard";
Z
Zachary 已提交
55
import DetailSonglist from "components/common/DetailSonglist";
56 57
import CommontBox from "components/common/CommontBox";
import { getAlbum, getCommentsNew } from "api";
Z
update  
Zachary 已提交
58
import { createSong, playSonglist, formatDate } from "common/utils";
Z
Zachary 已提交
59 60 61 62

export default {
  data() {
    return {
Z
Zachary 已提交
63
      moreInfo: false,
Z
Zachary 已提交
64 65
      id: this.$route.query.id,
      album: {},
Z
Zachary 已提交
66
      songs: [],
67 68 69 70
      pageSize: 20,
      commentPage: 1,
      commentCount: 0,
      comments: [],
Z
Zachary 已提交
71 72 73 74 75 76 77 78
    };
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
      getAlbum(this.id).then((res) => {
Z
Zachary 已提交
79
        //console.log(res);
Z
Zachary 已提交
80 81 82 83 84 85
        let ds = res.data;
        let album = {
          id: ds.album.id,
          name: ds.album.name,
          img: ds.album.picUrl,
          desc: ds.album.description,
Z
update  
Zachary 已提交
86
          artistsText: ds.album.artist.name,
Z
Zachary 已提交
87 88 89
          type: ds.album.type,
          version: ds.album.subType,
          company: ds.album.company,
Z
Zachary 已提交
90
          publishTime: formatDate(ds.album.publishTime, "yyyy-MM-dd"),
Z
Zachary 已提交
91 92
        };
        this.album = album;
Z
Zachary 已提交
93
        //console.log(album);
Z
Zachary 已提交
94 95 96 97 98 99 100 101 102 103 104 105 106 107
        this.songs = ds.songs.map(
          ({ id, name, ar, dt, al, mv, publishTime }) => {
            return createSong({
              id,
              name,
              artists: ar,
              duration: dt,
              albumName: al.name,
              mvId: mv,
              img: al.picUrl,
            });
          }
        );
        console.log(this.songs);
108
        this.getComment();
Z
Zachary 已提交
109 110
      });
    },
Z
Zachary 已提交
111 112 113
    toggleShowMoreInfo() {
      this.moreInfo = !this.moreInfo;
    },
Z
update  
Zachary 已提交
114 115
    cardClick(v) {
      if (v == "all") {
116
        playSonglist(this.songs);
Z
update  
Zachary 已提交
117 118
      }
    },
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
    getComment() {
      let params = {
        type: 3,
        pageSize: this.pageSize,
        pageNo: this.commentPage,
        id: this.album.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
Zachary 已提交
141 142
  },
  components: {
Z
update  
Zachary 已提交
143
    DetailInfoCard,
Z
Zachary 已提交
144
    DetailSonglist,
145
    CommontBox,
Z
Zachary 已提交
146 147 148 149 150 151 152 153 154 155 156
  },
};
</script>

<style scoped>
li,
ul {
  margin: 0;
  margin-right: 0px;
  padding: 0;
}
Z
Zachary 已提交
157 158 159 160
.about__tit {
  font-size: 20px;
  font-weight: 400;
  line-height: 46px;
Z
Zachary 已提交
161
}
Z
Zachary 已提交
162 163
.about__cont {
  max-height: 88px;
Z
Zachary 已提交
164
  overflow: hidden;
Z
Zachary 已提交
165
  font-size: 14.3px;
Z
Zachary 已提交
166
}
Z
Zachary 已提交
167
</style>