RecommendedBar.vue 3.9 KB
Newer Older
Z
Zachary 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
<template>
  <h1 class="list">歌单推荐</h1>
  <div>
    <a
      class="playlist"
      href='javascript:;'
      v-for="item in playlistType" :key="item.key"
      @click="onclick(item.key)">{{item.title}}</a>

  </div>

  <div class='target-list' v-loading="listLoading">
    <ul>
        <li class="playlist__i" v-for="item in playList" :key='item.name'>
            <a class="js_playlist" href="" onclick="" >
            <img
              class="playlist__pic"
              :src="item.coverImgUrl"
              onerror="this.src='//y.gtimg.cn/mediastyle/global/img/playlist_300.png?max_age=31536000';"
              :alt="item.name" >
            </a>
            <h4 class="">
              <span class=""><a href="" >{{item.name}}</a></span>
            </h4>
            <div class="">
26
              播放量:{{processCount(item.playCount)}}
Z
Zachary 已提交
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
            </div>
        </li>
    </ul>
  <!--  <div >
      <a href="" class="arrow-btn arrow-btn-left"><i class="el-icon-arrow el-icon-arrow-left"></i></a> 
      <a href="" class="arrow-btn arrow-btn-right"><i class="el-icon-arrow el-icon-arrow-right"></i></a>
    </div> -->
  </div>
  <div class="mod_slide_switch js_switch" data-stat="y_new.index.playlist.pager">
    <a href="javascript:;" tabindex="-1" class="js_jump slide_switch__item slide_switch__item--current" data-p="0">
      <i class="slide_switch__bg"></i>
      <i class="icon_txt">1</i>
    </a>
    <a href="javascript:;" tabindex="-1" class="js_jump slide_switch__item" data-p="1">
      <i class="slide_switch__bg"></i>
      <i class="icon_txt">2</i>
    </a>
  </div>
</template>

<script>
import { getPlayList } from "api";
49
import { processCount } from "common/utils";
Z
Zachary 已提交
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80

export default {
  data() {
    return {
      listLoading: true,
      playlistType: [
        {title: '为你推荐', key: '全部'},
        {title: 'R&B/Soul', key: 'R&B/Soul'},
        {title: '网络歌曲', key: '网络歌曲'},
        {title: 'ACG', key: 'ACG'},
        {title: '怀旧', key: '怀旧'},
        {title: '流行', key: '流行'},
      ],
      playList: [],
      }
  },
  mounted() {
    this.updatePlayList('全部');
  },
  methods: {
    updatePlayList(key) {
      let limit = 10;
      getPlayList(limit, 1, key).then(res => {
          console.log(res)
          this.playList = res.data.playlists
          this.listLoading = false;
          }).catch(err => console.log(err));
    },
    onclick(key) {
      this.updatePlayList(key);
    },
81 82 83 84
    processCount(count){
      return processCount(count)
    },
  }
Z
Zachary 已提交
85 86 87 88 89 90 91
}
</script>

<style>
  /* play list */
  .list{
    letter-spacing:20px;
92
    text-align: center;
Z
Zachary 已提交
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 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 152
  }
  .playlist{
    display: inline-block;
    font-size: 18px;
    margin: 0 30px;
    text-decoration:none
  }
  .playlist:hover {
    color: #31c27c;
  }
  .target-list{
    margin-right: -20px;
    overflow: hidden;
    margin-bottom: 20px;
    position: relative;
  }
  .playlist__i{
    display: inline-block;
    width: 18%;
    padding-bottom: 44px;
    overflow: hidden;
    font-size: 14px;
    vertical-align: top;
    color: #000;
    margin-right: 20px;
  }
  .playlist__pic {
    width:100%;height:100%;
  }


  /* 切换小圆点 */
  .mod_slide_switch {
      width: 100%;
      text-align: center;
      font-size: 0;
  }
  .slide_switch__item {
      display: inline-block;
      width: 28px;
      height: 12px;
      padding: 0 0 26px;
      margin: 0 1px;
      background: 0 0;
  }
  .slide_switch__bg {
      display: block;
      width: 8px;
      height: 8px;
      filter: progid:DXImageTransform.Microsoft.gradient(enabled='true', startColorstr='#19000000', endColorstr='#19000000');
      background-color: rgba(0,0,0,.1);
      border-radius: 12px;
      margin: 0 auto;
  }
  .slide_switch__item--current .slide_switch__bg, .slide_switch__item:hover .slide_switch__bg {
      filter: progid:DXImageTransform.Microsoft.gradient(enabled='true', startColorstr='#4C000000', endColorstr='#4C000000');
      background-color: rgba(0,0,0,.3);
  }

</style>