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

    <div class="detail_layout">
      <div class="detail_layout__main">
Z
Zachary 已提交
7
        <detail-songlist :songs="songs" :listType="'album'" />
Z
Zachary 已提交
8 9 10 11 12 13 14 15
      </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 已提交
16
          <a class="about__more" @click="toggleShowMoreInfo">[更多]</a>
Z
Zachary 已提交
17 18 19
        </div>
      </div>
    </div>
Z
Zachary 已提交
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36

    <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 已提交
37 38 39 40
  </div>
</template>

<script>
Z
update  
Zachary 已提交
41
import DetailInfoCard from "components/common/DetailInfoCard";
Z
Zachary 已提交
42
import DetailSonglist from "components/common/DetailSonglist";
Z
Zachary 已提交
43
import ModListMenu from "components/common/ModListMenu";
Z
Zachary 已提交
44
import { getAlbum } from "api";
Z
update  
Zachary 已提交
45
import { createSong, playSonglist, formatDate } from "common/utils";
Z
Zachary 已提交
46 47 48 49

export default {
  data() {
    return {
Z
Zachary 已提交
50
      moreInfo: false,
Z
Zachary 已提交
51 52
      id: this.$route.query.id,
      album: {},
Z
Zachary 已提交
53
      songs: [],
Z
Zachary 已提交
54 55 56 57 58 59 60 61
    };
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
      getAlbum(this.id).then((res) => {
Z
Zachary 已提交
62
        //console.log(res);
Z
Zachary 已提交
63 64 65 66 67 68
        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 已提交
69
          artistsText: ds.album.artist.name,
Z
Zachary 已提交
70 71 72
          type: ds.album.type,
          version: ds.album.subType,
          company: ds.album.company,
Z
Zachary 已提交
73
          publishTime: formatDate(ds.album.publishTime, "yyyy-MM-dd"),
Z
Zachary 已提交
74 75
        };
        this.album = album;
Z
Zachary 已提交
76
        //console.log(album);
Z
Zachary 已提交
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
        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);
      });
    },
Z
Zachary 已提交
93 94 95
    toggleShowMoreInfo() {
      this.moreInfo = !this.moreInfo;
    },
Z
update  
Zachary 已提交
96 97
    cardClick(v) {
      if (v == "all") {
98
        playSonglist(this.songs);
Z
update  
Zachary 已提交
99 100
      }
    },
Z
Zachary 已提交
101 102
  },
  components: {
Z
update  
Zachary 已提交
103
    DetailInfoCard,
Z
Zachary 已提交
104
    DetailSonglist,
Z
Zachary 已提交
105
    ModListMenu,
Z
Zachary 已提交
106 107 108 109 110 111 112 113 114 115 116
  },
};
</script>

<style scoped>
li,
ul {
  margin: 0;
  margin-right: 0px;
  padding: 0;
}
Z
Zachary 已提交
117 118 119 120
.about__tit {
  font-size: 20px;
  font-weight: 400;
  line-height: 46px;
Z
Zachary 已提交
121
}
Z
Zachary 已提交
122 123
.about__cont {
  max-height: 88px;
Z
Zachary 已提交
124
  overflow: hidden;
Z
Zachary 已提交
125
  font-size: 14.3px;
Z
Zachary 已提交
126
}
Z
Zachary 已提交
127
</style>