Songers.vue 3.6 KB
Newer Older
Z
Zachary 已提交
1
<template>
Z
Zachary 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
  <div class="mod_slide_box" style="position: relative">
    <div class="main" v-loading="loading">
      <type-select-bar>
        <type-select-sub-bar
          :selectId="initial"
          :items="initials"
          @selectId="initialClick"
        />
        <type-select-sub-bar
          :selectId="type"
          :items="types"
          @selectId="typeClick"
        />
        <type-select-sub-bar
          :selectId="area"
          :items="areas"
          @selectId="areaClick"
        />
      </type-select-bar>
Z
Zachary 已提交
21

Z
Zachary 已提交
22 23 24 25 26 27 28 29 30 31
      <ul class="singer_list_txt" v-loading="loading">
        <li
          class="singer_list_txt__item"
          v-for="item in artists"
          :key="item.id"
        >
          <a
            href="javascript:;"
            class="singer_list_txt__link js_singer"
            :title="item.name"
Z
update  
Zachary 已提交
32
            @click="gotoSongerDetail({ id: item.id })"
Z
Zachary 已提交
33 34 35 36
            >{{ item.name }}</a
          >
        </li>
      </ul>
Z
Zachary 已提交
37
    </div>
Z
Zachary 已提交
38 39 40 41 42 43 44 45 46 47 48 49

    <div class="mod_slide_action">
      <div class="slide_action slide_action--left">
        <a
          href="javascript:;"
          class="slide_action__btn slide_action__btn--left js_jump"
          data-p="prev"
          tabindex="-1"
          @click="prevPage()"
        >
          <i class="icon_txt">上一页</i
          ><i class="slide_action__arrow slide_action__arrow--left sprite"></i>
Z
Zachary 已提交
50
        </a>
Z
Zachary 已提交
51 52 53 54 55 56 57 58 59 60 61 62 63
      </div>
      <div class="slide_action slide_action--right">
        <a
          href="javascript:;"
          class="slide_action__btn slide_action__btn--right js_jump"
          data-p="next"
          tabindex="-1"
          @click="nextPage()"
        >
          <i class="icon_txt">下一页</i
          ><i class="slide_action__arrow slide_action__arrow--right sprite"></i>
        </a>
      </div>
Z
Zachary 已提交
64 65
    </div>
  </div>
Z
Zachary 已提交
66 67 68
</template>

<script>
Z
Zachary 已提交
69 70
import { getSongers, songerInitials, songerTypes, songerAreas } from "api";

Z
Zachary 已提交
71 72
import TypeSelectBar from "components/common/TypeSelectBar";
import TypeSelectSubBar from "components/common/TypeSelectSubBar";
Z
Zachary 已提交
73

Z
Zachary 已提交
74
export default {
Z
Zachary 已提交
75
  name: "Songers",
Z
Zachary 已提交
76 77
  data() {
    return {
Z
Zachary 已提交
78
      loading: true,
Z
Zachary 已提交
79 80
      page: 1,
      more: true,
Z
Zachary 已提交
81 82 83
      initial: songerInitials.DEFAULT.dataId,
      area: songerTypes.DEFAULT.dataId,
      type: songerAreas.DEFAULT.dataId,
Z
Zachary 已提交
84 85
      initials: songerInitials,
      types: songerTypes,
Z
Zachary 已提交
86
      areas: songerAreas,
Z
Zachary 已提交
87
      artists: [],
Z
Zachary 已提交
88 89
    };
  },
Z
Zachary 已提交
90
  mounted() {
Z
Zachary 已提交
91
    this.updateArtists();
Z
Zachary 已提交
92 93 94
  },
  methods: {
    updateArtists() {
Z
Zachary 已提交
95 96 97 98 99 100 101 102
      getSongers(this.initial, this.type, this.area, this.page)
        .then((res) => {
          console.log(res);
          this.artists = res.data.artists;
          this.more = res.data.more;
          this.loading = false;
        })
        .catch((err) => console.log("updateArtists Error:", err));
Z
Zachary 已提交
103 104
    },
    initialClick(id) {
Z
Zachary 已提交
105
      if (id != this.initial) {
Z
Zachary 已提交
106 107 108 109 110
        this.initial = id;
        this.updateArtists();
      }
    },
    typeClick(id) {
Z
Zachary 已提交
111
      if (id != this.type) {
Z
Zachary 已提交
112 113 114 115 116
        this.type = id;
        this.updateArtists();
      }
    },
    areaClick(id) {
Z
Zachary 已提交
117
      if (id != this.area) {
Z
Zachary 已提交
118 119 120 121 122 123 124 125 126 127 128
        this.area = id;
        this.updateArtists();
      }
    },
    nextPage() {
      if (this.more == true) {
        this.page++;
        this.updateArtists();
      }
    },
    prevPage() {
Z
Zachary 已提交
129
      if (this.page > 1) {
Z
Zachary 已提交
130 131 132 133
        this.page--;
        this.updateArtists();
      }
    },
Z
Zachary 已提交
134 135 136
    gotoSongerDetail(query) {
      this.$router.push({ path: "/musicLibrary/songerDetail", query: query });
    },
Z
Zachary 已提交
137 138 139
  },
  components: {
    TypeSelectBar,
Z
Zachary 已提交
140 141 142
    TypeSelectSubBar,
  },
};
Z
Zachary 已提交
143 144 145
</script>

<style scoped>
Z
Zachary 已提交
146 147 148
.main {
  z-index: 2;
}
Z
Zachary 已提交
149

Z
Zachary 已提交
150 151 152 153 154 155
.main,
.section_inner {
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
}
Z
Zachary 已提交
156
</style>