SongerDetail.vue 10.5 KB
Newer Older
Z
Zachary 已提交
1
<template>
Z
Zachary 已提交
2
  <div class="songer-main">
Z
update  
Zachary 已提交
3 4 5 6 7 8
    <detail-info-card
      :obj="songer"
      :cardType="'songer'"
      @btnClick="playHotSongs"
      @moreClick="toggleShowMoreInfo"
    />
Z
Zachary 已提交
9 10 11 12 13 14

    <div id="index_tab" class="js_tab">
      <div class="mod_part">
        <div class="part__hd">
          <h2 class="part__tit">热门歌曲</h2>

Z
Zachary 已提交
15
          <a class="part__more js_goto_tab">
Z
Zachary 已提交
16 17 18 19
            全部<i class="icon_part_arrow sprite"></i>
          </a>
        </div>

Z
Zachary 已提交
20
        <detail-songlist :songs="hotSongs" :listType="'songer'" />
Z
Zachary 已提交
21 22
      </div>

Z
update  
Zachary 已提交
23
      <div class="mod_part" v-if="albums.length > 0">
Z
Zachary 已提交
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
        <div class="part__hd">
          <h2 class="part__tit">专辑</h2>
        </div>
        <div class="mod_playlist">
          <ul class="playlist__list" id="albumlist">
            <li
              class="playlist__item"
              onmouseover="this.className=(this.className+' playlist__item--hover')"
              onmouseout="this.className=this.className.replace(/ playlist__item--hover/, '')"
              v-for="album in albums"
              :key="album.id"
            >
              <div class="playlist__item_box">
                <div class="playlist__cover mod_cover">
                  <a class="js_album">
                    <img
                      class="playlist__pic"
                      onerror="this.src='//y.gtimg.cn/mediastyle/global/img/album_300.png?max_age=31536000';this.onerror=null;"
                      :src="album.img"
                      :alt="album.name"
                    />
Z
update  
Zachary 已提交
45 46 47 48
                    <i
                      class="mod_cover__icon_play js_play"
                      @click="playAlbum(album.id)"
                    ></i>
Z
Zachary 已提交
49 50 51
                  </a>
                </div>
                <h4 class="playlist__title">
Z
update  
Zachary 已提交
52 53 54 55 56 57 58 59
                  <span class="playlist__title_txt">
                    <a
                      class="js_album"
                      :title="album.name"
                      @click="gotoAlbumDetail(album.id)"
                      >{{ album.name }}</a
                    >
                  </span>
Z
Zachary 已提交
60 61
                </h4>
                <div class="playlist__other">{{ album.publishTime }}</div>
Z
Zachary 已提交
62 63 64
                <a class="btn_operate_menu js_albumlist_more">
                  <span class="icon_txt">更多</span>
                </a>
Z
Zachary 已提交
65
              </div>
Z
Zachary 已提交
66
            </li>
Z
Zachary 已提交
67 68 69 70
          </ul>
        </div>
      </div>

Z
update  
Zachary 已提交
71
      <div class="mod_part" v-if="mvs.length > 0">
Z
Zachary 已提交
72 73
        <div class="part__hd">
          <h2 class="part__tit">MV</h2>
Z
Zachary 已提交
74 75 76
          <a class="part__more js_goto_tab">
            全部<i class="icon_part_arrow sprite"></i>
          </a>
Z
Zachary 已提交
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
        </div>
        <div class="mod_mv">
          <ul class="mv_list__list" id="mvlist">
            <li class="mv_list__item" v-for="mv in mvs" :key="mv.id">
              <div class="mv_list__item_box">
                <a class="mv_list__cover mod_cover js_mv" hidefocus="true">
                  <img
                    class="mv_list__pic"
                    onerror="this.src='//y.gtimg.cn/mediastyle/global/img/mv_300.png?max_age=31536000';this.onerror=null;"
                    :src="mv.img"
                    :alt="mv.name"
                  />
                  <i class="mod_cover__icon_play"></i>
                </a>
                <h3 class="mv_list__title">
                  <a class="js_mv" :title="mv.name">{{ mv.name }}</a>
                </h3>

                <div class="mv_list__info">
                  <span class="mv_list__listen"
                    ><i class="mv_list__listen_icon sprite"></i
                    >{{ mv.playCount }}</span
                  >
                </div>
              </div>
Z
Zachary 已提交
102 103
            </li>
          </ul>
Z
Zachary 已提交
104 105 106
        </div>
      </div>

Z
update  
Zachary 已提交
107
      <div class="mod_part" id="similar" style="" v-if="simiSongers.length > 0">
Z
Zachary 已提交
108 109 110 111 112 113 114 115 116 117 118 119 120 121
        <div class="part__hd">
          <h2 class="part__tit">相似歌手</h2>
        </div>
        <div class="mod_singer_list">
          <ul class="singer_list__list">
            <li
              class="singer_list__item"
              v-for="songer in simiSongers"
              :key="songer.id"
            >
              <div class="singer_list__item_box">
                <a
                  class="singer_list__cover js_singer"
                  hidefocus="true"
Z
update  
Zachary 已提交
122 123
                  :title="songer.name"
                  @click="gotoSongerDetail({ id: songer.id })"
Z
Zachary 已提交
124 125 126 127 128 129 130 131 132
                >
                  <img
                    class="singer_list__pic"
                    onerror="this.src='//y.gtimg.cn/mediastyle/global/img/singer_300.png?max_age=31536000';this.onerror=null;"
                    :src="songer.img"
                    :alt="songer.name"
                  />
                </a>
                <h3 class="singer_list__title">
Z
update  
Zachary 已提交
133 134 135 136 137 138
                  <a
                    class="js_singer"
                    :title="songer.name"
                    @click="gotoSongerDetail({ id: songer.id })"
                    >{{ songer.name }}</a
                  >
Z
Zachary 已提交
139 140 141 142 143 144
                </h3>
              </div>
            </li>
          </ul>
        </div>
      </div>
Z
Zachary 已提交
145
    </div>
Z
update  
Zachary 已提交
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163

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

<script>
Z
update  
Zachary 已提交
168
import DetailInfoCard from "components/common/DetailInfoCard";
Z
Zachary 已提交
169
import DetailSonglist from "components/common/DetailSonglist";
Z
Zachary 已提交
170 171 172 173 174 175 176
import {
  getUserDetail,
  getSongerDetail,
  getSongerTop50,
  getSimiSongers,
  getSongerAlbums,
  getSongerMvs,
Z
update  
Zachary 已提交
177
  getAlbum,
Z
Zachary 已提交
178 179 180 181 182 183 184
} from "api";
import {
  createSonger,
  createSimiSonger,
  createUser,
  createSong,
  createAlbum,
Z
Zachary 已提交
185
  createMvs,
Z
Zachary 已提交
186 187
  playSonglist,
} from "common/utils";
Z
Zachary 已提交
188 189 190 191

export default {
  data() {
    return {
Z
update  
Zachary 已提交
192
      moreInfo: false,
Z
Zachary 已提交
193 194
      id: null,
      songer: {},
Z
update  
Zachary 已提交
195
      simiSongers: [],
Z
Zachary 已提交
196 197
      hotSongs: [],
      songs: [],
Z
update  
Zachary 已提交
198 199
      albums: [],
      mvs: [],
Z
Zachary 已提交
200 201 202
    };
  },
  created() {
Z
Zachary 已提交
203
    this.id = this.$route.query.id;
Z
Zachary 已提交
204
    this.init();
Z
Zachary 已提交
205 206
  },
  methods: {
Z
Zachary 已提交
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
    async init() {
      // Get songer detail
      const res1 = await getSongerDetail(this.id);
      this.songer = createSonger(res1.data.data);

      // Get songer top 50
      const res2 = await getSongerTop50(this.id);
      this.hotSongs = res2.data.songs.map((song) => {
        return createSong({
          id: song.id,
          name: song.name,
          artists: song.ar,
          duration: song.dt,
          albumName: song.al.name,
          img: song.al.picUrl,
        });
      });

      // Get simi songer
      const res3 = await getSimiSongers(this.id);
      let simiSongers = res3.data.artists.map((songer) => {
        return createSimiSonger(songer);
      });
      this.simiSongers =
        simiSongers.length > 5 ? simiSongers.slice(0, 5) : simiSongers;

      // Get songer album
      const res4 = await getSongerAlbums({ id: this.id, limit: 5, offset: 0 });
Z
update  
Zachary 已提交
235
      console.log(res4);
Z
Zachary 已提交
236 237 238 239 240 241 242 243 244 245 246 247 248 249
      this.albums = res4.data.hotAlbums.map(
        ({ id, name, publishTime, artists, picUrl }) => {
          return createAlbum({
            id,
            name,
            img: picUrl,
            artists,
            publishTime,
          });
        }
      );

      // Get songer mv
      const res5 = await getSongerMvs(this.id);
Z
Zachary 已提交
250 251 252
      console.log(res5);
      let mvs = createMvs(res5.data.mvs);
      console.log(mvs);
Z
Zachary 已提交
253 254 255 256
      this.mvs = mvs.length > 5 ? mvs.slice(0, 5) : mvs;
    },
    playHotSongs() {
      playSonglist(this.hotSongs);
Z
Zachary 已提交
257
    },
Z
update  
Zachary 已提交
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
    toggleShowMoreInfo() {
      this.moreInfo = !this.moreInfo;
    },
    playAlbum(id) {
      getAlbum(id).then((res) => {
        let songs = res.data.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,
            });
          }
        );
        playSonglist(songs);
      });
    },
    gotoAlbumDetail(id) {
      this.$router.push({
        path: "/musicLibrary/albumDetail",
        query: { id: id },
      });
    },
    gotoSongerDetail(query) {
      this.$router.push({ path: "/musicLibrary/songerDetail", query: query });
    },
Z
Zachary 已提交
288
  },
Z
Zachary 已提交
289
  components: {
Z
update  
Zachary 已提交
290
    DetailInfoCard,
Z
Zachary 已提交
291
    DetailSonglist,
Z
Zachary 已提交
292
  },
Z
Zachary 已提交
293
};
Z
Zachary 已提交
294 295 296
</script>

<style scoped>
Z
Zachary 已提交
297 298 299 300 301 302 303 304
blockquote,
body,
button,
dd,
dl,
dt,
fieldset,
form,
Z
Zachary 已提交
305 306 307 308 309 310
h1,
h2,
h3,
h4,
h5,
h6,
Z
Zachary 已提交
311 312 313 314
hr,
html,
input,
lengend,
Z
Zachary 已提交
315
li,
Z
Zachary 已提交
316
ol,
Z
Zachary 已提交
317
p,
Z
Zachary 已提交
318
pre,
Z
Zachary 已提交
319
td,
Z
Zachary 已提交
320
textarea,
Z
Zachary 已提交
321
th,
Z
Zachary 已提交
322
ul {
Z
Zachary 已提交
323
  margin: 0;
Z
Zachary 已提交
324 325
  margin-right: 0px;
  padding: 0;
Z
Zachary 已提交
326
}
Z
Zachary 已提交
327 328
.songer-main {
  z-index: 2;
Z
Zachary 已提交
329
}
Z
Zachary 已提交
330 331 332 333
.songer-main,
.section_inner {
  max-width: 1200px;
  margin: 0 auto;
Z
Zachary 已提交
334 335 336
  position: relative;
}

Z
Zachary 已提交
337 338 339
/*overwrite*/
.data__cont {
  padding-top: 31px;
Z
Zachary 已提交
340
}
Z
Zachary 已提交
341 342
/*overwrite*/
.data__name_txt {
Z
Zachary 已提交
343
  float: left;
Z
Zachary 已提交
344 345 346 347 348 349 350
  font-size: 38px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90%;
  margin-right: 10px;
Z
Zachary 已提交
351
}
Z
Zachary 已提交
352 353 354
/*overwrite*/
.data__actions {
  bottom: 30px;
Z
Zachary 已提交
355
}
Z
Zachary 已提交
356
.data_statistic__item {
Z
Zachary 已提交
357
  display: inline-block;
Z
Zachary 已提交
358 359 360 361 362
  border-right: solid 1px #c9c9c9;
  text-align: center;
  padding-right: 20px;
  margin-right: 20px;
  font-size: 18px;
Z
Zachary 已提交
363
}
Z
Zachary 已提交
364 365
.data_statistic__item--last {
  border-right: 0 none;
Z
Zachary 已提交
366 367
}

Z
Zachary 已提交
368 369 370
.mod_part .mv_list__item,
.mod_part .singer_list__item {
  width: 20%;
Z
Zachary 已提交
371
}
Z
Zachary 已提交
372 373 374
.mod_part .mv_list__item,
.mod_part .playlist__item {
  padding-bottom: 0;
Z
Zachary 已提交
375
}
Z
Zachary 已提交
376 377
.mv_list__list {
  margin-right: -20px;
Z
Zachary 已提交
378 379
  zoom: 1;
}
Z
Zachary 已提交
380
.mv_list__item {
Z
Zachary 已提交
381
  float: left;
Z
Zachary 已提交
382 383 384
  width: 25%;
  padding-bottom: 44px;
  overflow: hidden;
Z
Zachary 已提交
385 386
}

Z
Zachary 已提交
387 388 389 390 391 392 393 394 395
.mod_singer_list {
  overflow: hidden;
  text-align: center;
}
.singer_list__list {
  margin-right: -20px;
  overflow: hidden;
  zoom: 1;
  margin-bottom: -24px;
Z
Zachary 已提交
396 397
}

Z
Zachary 已提交
398
.singer_list__item {
Z
Zachary 已提交
399
  float: left;
Z
Zachary 已提交
400 401 402
  width: 20%;
  margin-bottom: 20px;
  overflow: hidden;
Z
Zachary 已提交
403
}
Z
Zachary 已提交
404 405 406 407 408 409 410
.singer_list__item_box {
  position: relative;
  margin-right: 20px;
  background-color: #fbfbfd;
  min-height: 195px;
  padding: 25px 0;
  overflow: hidden;
Z
Zachary 已提交
411
}
Z
Zachary 已提交
412 413 414 415 416 417 418 419 420 421
.singer_list__title {
  font-size: 16px;
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  zoom: 1;
  *width: 100%;
  margin: 20px 30px 4px;
}
Z
Zachary 已提交
422

Z
Zachary 已提交
423 424
.mod_mv {
  height: 183px;
Z
Zachary 已提交
425
}
Z
update  
Zachary 已提交
426 427 428 429 430

.popup_data_detail {
  top: 128px;
  right: 85px;
}
Z
Zachary 已提交
431 432 433 434 435 436 437
.popup_data_detail__cont {
  max-height: 250px;
  font-size: 14px;
  line-height: 22px;
  margin: 30px 5px 30px 10px;
  overflow-y: auto;
}
Z
Zachary 已提交
438
</style>