SongerDetail.vue 12.9 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 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55

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

          <a
            href="//y.qq.com/n/yqq/singer/001xvjTU1ICL8Z.html#tab=song&amp;"
            class="part__more js_goto_tab"
          >
            全部<i class="icon_part_arrow sprite"></i>
          </a>
        </div>

        <div class="mod_songlist">
          <ul class="songlist__header">
            <li class="songlist__edit songlist__edit--check sprite">
              <input type="checkbox" class="songlist__checkbox" />
            </li>
            <li class="songlist__header_name">歌曲</li>
            <li class="songlist__header_album">专辑</li>
            <li class="songlist__header_time">时长</li>
          </ul>

          <ul class="songlist__list">
            <li v-for="(song, idx) in hotSongs" :key="song.id">
              <div
                class="songlist__item"
                :class="(idx + 1) % 2 == 0 ? 'songlist__item--even' : ''"
              >
                <div class="songlist__edit songlist__edit--check sprite">
                  <input type="checkbox" class="songlist__checkbox" />
                </div>
                <div class="songlist__number">{{ idx + 1 }}</div>
                <div class="songlist__songname">
                  <!-- <i
                    class="songlist__icon songlist__icon_exclusive sprite"
                    title="独家"
                  ></i> -->

                  <span class="songlist__songname_txt">
                    <a class="js_song" :title="song.name">
                      {{ song.name }}
                      <span class="songlist__song_txt"></span>
                    </a>
                  </span>

Z
Zachary 已提交
56 57
                  <!-- mod list menu -->
                  <mod-list-menu :song="song" />
Z
Zachary 已提交
58 59 60 61 62 63 64
                </div>
                <div class="songlist__album">
                  <a :title="song.albumName">{{ song.albumName }}</a>
                </div>
                <div class="songlist__time">{{ song.durationText }}</div>
                <div class="songlist__other"></div>
              </div>
Z
Zachary 已提交
65
            </li>
Z
Zachary 已提交
66 67 68 69
          </ul>
        </div>
      </div>

Z
update  
Zachary 已提交
70
      <div class="mod_part" v-if="albums.length > 0">
Z
Zachary 已提交
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
        <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 已提交
92 93 94 95
                    <i
                      class="mod_cover__icon_play js_play"
                      @click="playAlbum(album.id)"
                    ></i>
Z
Zachary 已提交
96 97 98
                  </a>
                </div>
                <h4 class="playlist__title">
Z
update  
Zachary 已提交
99 100 101 102 103 104 105 106
                  <span class="playlist__title_txt">
                    <a
                      class="js_album"
                      :title="album.name"
                      @click="gotoAlbumDetail(album.id)"
                      >{{ album.name }}</a
                    >
                  </span>
Z
Zachary 已提交
107 108 109 110 111 112 113 114
                </h4>
                <div class="playlist__other">{{ album.publishTime }}</div>
                <a
                  href="javascript:;"
                  class="btn_operate_menu js_albumlist_more"
                  ><span class="icon_txt">更多</span></a
                >
              </div>
Z
Zachary 已提交
115
            </li>
Z
Zachary 已提交
116 117 118 119
          </ul>
        </div>
      </div>

Z
update  
Zachary 已提交
120
      <div class="mod_part" v-if="mvs.length > 0">
Z
Zachary 已提交
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
        <div class="part__hd">
          <h2 class="part__tit">MV</h2>

          <a class="part__more js_goto_tab"
            >全部<i class="icon_part_arrow sprite"></i
          ></a>
        </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 已提交
152 153
            </li>
          </ul>
Z
Zachary 已提交
154 155 156
        </div>
      </div>

Z
update  
Zachary 已提交
157
      <div class="mod_part" id="similar" style="" v-if="simiSongers.length > 0">
Z
Zachary 已提交
158 159 160 161 162 163 164 165 166 167 168 169 170 171
        <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 已提交
172 173
                  :title="songer.name"
                  @click="gotoSongerDetail({ id: songer.id })"
Z
Zachary 已提交
174 175 176 177 178 179 180 181 182
                >
                  <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 已提交
183 184 185 186 187 188
                  <a
                    class="js_singer"
                    :title="songer.name"
                    @click="gotoSongerDetail({ id: songer.id })"
                    >{{ songer.name }}</a
                  >
Z
Zachary 已提交
189 190 191 192 193 194
                </h3>
              </div>
            </li>
          </ul>
        </div>
      </div>
Z
Zachary 已提交
195
    </div>
Z
update  
Zachary 已提交
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214

    <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 已提交
215
  </div>
Z
Zachary 已提交
216 217 218
</template>

<script>
Z
update  
Zachary 已提交
219
import DetailInfoCard from "components/common/DetailInfoCard";
Z
Zachary 已提交
220
import ModListMenu from "components/common/ModListMenu";
Z
Zachary 已提交
221 222 223 224 225 226 227
import {
  getUserDetail,
  getSongerDetail,
  getSongerTop50,
  getSimiSongers,
  getSongerAlbums,
  getSongerMvs,
Z
update  
Zachary 已提交
228
  getAlbum,
Z
Zachary 已提交
229 230 231 232 233 234 235 236 237 238
} from "api";
import {
  createSonger,
  createSimiSonger,
  createUser,
  createSong,
  createAlbum,
  createMv,
  playSonglist,
} from "common/utils";
Z
Zachary 已提交
239 240 241 242

export default {
  data() {
    return {
Z
update  
Zachary 已提交
243
      moreInfo: false,
Z
Zachary 已提交
244 245
      id: null,
      songer: {},
Z
update  
Zachary 已提交
246
      simiSongers: [],
Z
Zachary 已提交
247 248
      hotSongs: [],
      songs: [],
Z
update  
Zachary 已提交
249 250
      albums: [],
      mvs: [],
Z
Zachary 已提交
251 252 253
    };
  },
  created() {
Z
Zachary 已提交
254
    this.id = this.$route.query.id;
Z
Zachary 已提交
255
    this.init();
Z
Zachary 已提交
256 257
  },
  methods: {
Z
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
    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 已提交
286
      console.log(res4);
Z
Zachary 已提交
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316
      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);
      let mvs = res5.data.mvs.map(
        ({ id, name, imgurl, duration, playCount, publishTime }) => {
          return createMv({
            id,
            name,
            img: imgurl,
            duration,
            playCount,
            publishTime,
          });
        }
      );
      this.mvs = mvs.length > 5 ? mvs.slice(0, 5) : mvs;
    },
    playHotSongs() {
      playSonglist(this.hotSongs);
Z
Zachary 已提交
317
    },
Z
update  
Zachary 已提交
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347
    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 已提交
348
  },
Z
Zachary 已提交
349
  components: {
Z
update  
Zachary 已提交
350
    DetailInfoCard,
Z
Zachary 已提交
351 352
    ModListMenu,
  },
Z
Zachary 已提交
353
};
Z
Zachary 已提交
354 355 356
</script>

<style scoped>
Z
Zachary 已提交
357 358 359 360 361 362 363 364
blockquote,
body,
button,
dd,
dl,
dt,
fieldset,
form,
Z
Zachary 已提交
365 366 367 368 369 370
h1,
h2,
h3,
h4,
h5,
h6,
Z
Zachary 已提交
371 372 373 374
hr,
html,
input,
lengend,
Z
Zachary 已提交
375
li,
Z
Zachary 已提交
376
ol,
Z
Zachary 已提交
377
p,
Z
Zachary 已提交
378
pre,
Z
Zachary 已提交
379
td,
Z
Zachary 已提交
380
textarea,
Z
Zachary 已提交
381
th,
Z
Zachary 已提交
382
ul {
Z
Zachary 已提交
383
  margin: 0;
Z
Zachary 已提交
384 385
  margin-right: 0px;
  padding: 0;
Z
Zachary 已提交
386
}
Z
Zachary 已提交
387 388
.songer-main {
  z-index: 2;
Z
Zachary 已提交
389
}
Z
Zachary 已提交
390 391 392 393
.songer-main,
.section_inner {
  max-width: 1200px;
  margin: 0 auto;
Z
Zachary 已提交
394 395 396
  position: relative;
}

Z
Zachary 已提交
397 398 399
/*overwrite*/
.data__cont {
  padding-top: 31px;
Z
Zachary 已提交
400
}
Z
Zachary 已提交
401 402
/*overwrite*/
.data__name_txt {
Z
Zachary 已提交
403
  float: left;
Z
Zachary 已提交
404 405 406 407 408 409 410
  font-size: 38px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90%;
  margin-right: 10px;
Z
Zachary 已提交
411
}
Z
Zachary 已提交
412 413 414
/*overwrite*/
.data__actions {
  bottom: 30px;
Z
Zachary 已提交
415
}
Z
Zachary 已提交
416 417
.songlist__header {
  background-color: #fbfbfd;
Z
Zachary 已提交
418
}
Z
Zachary 已提交
419 420 421 422 423
.songlist__header,
.songlist__item {
  position: relative;
  padding-left: 46px;
  padding-right: 95px;
Z
Zachary 已提交
424
}
Z
Zachary 已提交
425 426 427 428
/*overwrite*/
.songlist__songname {
  line-height: 50px;
  height: 50px;
Z
Zachary 已提交
429 430 431 432
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
Z
Zachary 已提交
433 434 435 436 437
/*overwrite*/
.songlist__album,
.songlist__artist,
.songlist__header_album,
.songlist__header_author {
Z
Zachary 已提交
438
  float: left;
Z
Zachary 已提交
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
  padding-left: 15px;
  width: 25.5%;
  box-sizing: border-box;
}
/*overwrite*/
.songlist__album,
.songlist__artist,
.songlist__number,
.songlist__other,
.songlist__time {
  line-height: 50px;
  height: 50px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
Z
Zachary 已提交
455
}
Z
Zachary 已提交
456
.data_statistic__item {
Z
Zachary 已提交
457
  display: inline-block;
Z
Zachary 已提交
458 459 460 461 462
  border-right: solid 1px #c9c9c9;
  text-align: center;
  padding-right: 20px;
  margin-right: 20px;
  font-size: 18px;
Z
Zachary 已提交
463
}
Z
Zachary 已提交
464 465
.data_statistic__item--last {
  border-right: 0 none;
Z
Zachary 已提交
466 467
}

Z
Zachary 已提交
468 469 470
.mod_part .mv_list__item,
.mod_part .singer_list__item {
  width: 20%;
Z
Zachary 已提交
471
}
Z
Zachary 已提交
472 473 474
.mod_part .mv_list__item,
.mod_part .playlist__item {
  padding-bottom: 0;
Z
Zachary 已提交
475
}
Z
Zachary 已提交
476 477
.mv_list__list {
  margin-right: -20px;
Z
Zachary 已提交
478 479
  zoom: 1;
}
Z
Zachary 已提交
480
.mv_list__item {
Z
Zachary 已提交
481
  float: left;
Z
Zachary 已提交
482 483 484
  width: 25%;
  padding-bottom: 44px;
  overflow: hidden;
Z
Zachary 已提交
485 486
}

Z
Zachary 已提交
487 488 489 490 491 492 493 494 495
.mod_singer_list {
  overflow: hidden;
  text-align: center;
}
.singer_list__list {
  margin-right: -20px;
  overflow: hidden;
  zoom: 1;
  margin-bottom: -24px;
Z
Zachary 已提交
496 497
}

Z
Zachary 已提交
498
.singer_list__item {
Z
Zachary 已提交
499
  float: left;
Z
Zachary 已提交
500 501 502
  width: 20%;
  margin-bottom: 20px;
  overflow: hidden;
Z
Zachary 已提交
503
}
Z
Zachary 已提交
504 505 506 507 508 509 510
.singer_list__item_box {
  position: relative;
  margin-right: 20px;
  background-color: #fbfbfd;
  min-height: 195px;
  padding: 25px 0;
  overflow: hidden;
Z
Zachary 已提交
511 512
}

Z
Zachary 已提交
513 514
.mod_mv {
  height: 183px;
Z
Zachary 已提交
515
}
Z
update  
Zachary 已提交
516 517 518 519 520

.popup_data_detail {
  top: 128px;
  right: 85px;
}
Z
Zachary 已提交
521
</style>