提交 a59a71b5 编写于 作者: Z Zachary

feat: finish home top func

* add router helper file
* imporve code
上级 ac8461b6
...@@ -748,6 +748,7 @@ ...@@ -748,6 +748,7 @@
transition: transform 0.75s cubic-bezier(0, 1, 0.75, 1); transition: transform 0.75s cubic-bezier(0, 1, 0.75, 1);
} }
.mod_cover__icon_play { .mod_cover__icon_play {
cursor: pointer;
position: absolute; position: absolute;
left: 50%; left: 50%;
top: 50%; top: 50%;
......
import Router from "@/router";
export function gotoSongDetail(id) {
if (id && id != 0)
Router.push({
path: "/musicLibrary/songDetail",
query: { id: id }
});
}
export function gotoSongerDetail(id) {
if (id && id != 0)
Router.push({
path: "/musicLibrary/songerDetail",
query: { id: id }
});
}
export function gotoPlaylistDetail(id) {
if (id && id != 0)
Router.push({
path: "/musicLibrary/playlistDetail",
query: { id: id }
});
}
export function gotoAlbumDetail(id) {
if (id && id != 0)
Router.push({
path: "/musicLibrary/albumDetail",
query: { id: id }
});
}
export * from "./storeHelper"; export * from "./storeHelper";
export * from "./apiHelper"; export * from "./apiHelper";
export * from "./routerHelper";
export function isDef(v) { export function isDef(v) {
return v !== undefined && v !== null; return v !== undefined && v !== null;
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<div class="songlist__number">{{ idx + 1 }}</div> <div class="songlist__number">{{ idx + 1 }}</div>
<div class="songlist__songname"> <div class="songlist__songname">
<span class="songlist__songname_txt"> <span class="songlist__songname_txt">
<a :title="song.name" @click="gotoSongDeail(song.id)"> <a :title="song.name" @click="gotoSongDetail(song.id)">
{{ song.name }}<span class="songlist__song_txt"></span> {{ song.name }}<span class="songlist__song_txt"></span>
</a> </a>
</span> </span>
...@@ -59,6 +59,11 @@ ...@@ -59,6 +59,11 @@
<script> <script>
import ModListMenu from "components/common/ModListMenu"; import ModListMenu from "components/common/ModListMenu";
import {
gotoSongDetail,
gotoSongerDetail,
gotoAlbumDetail,
} from "common/utils";
export default { export default {
props: { props: {
songs: { songs: {
...@@ -71,27 +76,9 @@ export default { ...@@ -71,27 +76,9 @@ export default {
}, },
}, },
methods: { methods: {
gotoSongDeail(id) { gotoSongDetail,
if (id && id != 0) gotoSongerDetail,
this.$router.push({ gotoAlbumDetail,
path: "/musicLibrary/songDetail",
query: { id: id },
});
},
gotoSongerDetail(id) {
if (id && id != 0)
this.$router.push({
path: "/musicLibrary/songerDetail",
query: { id: id },
});
},
gotoAlbumDetail(id) {
if (id && id != 0)
this.$router.push({
path: "/musicLibrary/albumDetail",
query: { id: id },
});
},
}, },
components: { components: {
ModListMenu, ModListMenu,
......
...@@ -11,7 +11,10 @@ ...@@ -11,7 +11,10 @@
> >
<div class="toplist__box"> <div class="toplist__box">
<div id="toplist__bg" :class="'toplist__bg' + idx"></div> <div id="toplist__bg" :class="'toplist__bg' + idx"></div>
<i class="mod_cover__icon_play js_play_toplist"></i> <i
class="mod_cover__icon_play js_play_toplist"
@click="playSonglist(toplist)"
></i>
<i class="toplist__line"></i> <i class="toplist__line"></i>
<h3 class="toplist__hd"> <h3 class="toplist__hd">
<a href="javascript:;" class="toplist__tit" <a href="javascript:;" class="toplist__tit"
...@@ -26,16 +29,19 @@ ...@@ -26,16 +29,19 @@
<a <a
href="javascript:;" href="javascript:;"
class="js_song" class="js_song"
:data-id="toplist.tracks[songIdx - 1].id" :data-id="toplist[songIdx - 1].id"
@click="gotoSongDetail(toplist.tracks[songIdx - 1].id)" @click="gotoSongDetail(toplist[songIdx - 1].id)"
> >
{{ parseSongName(toplist.tracks[songIdx - 1].name) }} {{ toplist[songIdx - 1].name }}
</a> </a>
</div> </div>
<div class="toplist__artist"> <div class="toplist__artist">
<a href="javascript:;">{{ <a
parseArtistsName(toplist.tracks[songIdx - 1].ar) @click="
}}</a> gotoSongerDetail(toplist[songIdx - 1].artists[0].id)
"
>{{ toplist[songIdx - 1].artistsText }}</a
>
</div> </div>
</li> </li>
</ul> </ul>
...@@ -47,7 +53,13 @@ ...@@ -47,7 +53,13 @@
</template> </template>
<script> <script>
import { getTopList, toplistTypes } from "api"; import { getPlaylistDetial, getSongDetail, toplistTypes } from "api";
import {
createSongs,
gotoSongDetail,
gotoSongerDetail,
playSonglist,
} from "common/utils";
export default { export default {
data() { data() {
...@@ -62,28 +74,18 @@ export default { ...@@ -62,28 +74,18 @@ export default {
}, },
methods: { methods: {
updateTopList(toplistType) { updateTopList(toplistType) {
getTopList(toplistType).then((res) => { getPlaylistDetial(toplistType).then((res) => {
//console.log(res); let trackIds = res.data.playlist.trackIds.map(({ id }) => id);
this.toplists.push(res.data.playlist); getSongDetail(trackIds).then((res) => {
}); let songs = createSongs(res.data.songs);
}, console.log(songs);
parseSongName(name) { this.toplists.push(songs);
return name; });
},
parseArtistsName(nameList) {
let l = [];
for (let i of nameList) {
l.push(i.name);
}
let name = l.join("/");
return name;
},
gotoSongDetail(id) {
this.$router.push({
path: "/musicLibrary/songDetail",
query: { id: id },
}); });
}, },
gotoSongDetail,
gotoSongerDetail,
playSonglist,
}, },
}; };
</script> </script>
......
...@@ -65,7 +65,12 @@ ...@@ -65,7 +65,12 @@
<script> <script>
import { getPlayList, getPlaylistDetial, getSongDetail } from "api"; import { getPlayList, getPlaylistDetial, getSongDetail } from "api";
import { processCount, createSong, playSonglist } from "common/utils"; import {
processCount,
createSong,
playSonglist,
gotoPlaylistDetail,
} from "common/utils";
export default { export default {
data() { data() {
...@@ -126,12 +131,7 @@ export default { ...@@ -126,12 +131,7 @@ export default {
}); });
}); });
}, },
gotoPlaylistDetail(id) { gotoPlaylistDetail,
this.$router.push({
path: "/musicLibrary/playlistDetail",
query: { id: id },
});
},
}, },
}; };
</script> </script>
......
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
<script> <script>
import TypeSelectSubBar from "components/common/TypeSelectSubBar"; import TypeSelectSubBar from "components/common/TypeSelectSubBar";
import { albumAreas, getTopAlbum } from "api"; import { albumAreas, getTopAlbum } from "api";
import { createAlbums } from "common/utils"; import { createAlbums, gotoAlbumDetail } from "common/utils";
export default { export default {
data() { data() {
...@@ -121,12 +121,7 @@ export default { ...@@ -121,12 +121,7 @@ export default {
console.log(v); console.log(v);
this.page = v; this.page = v;
}, },
gotoAlbumDetail(id) { gotoAlbumDetail,
this.$router.push({
path: "/musicLibrary/albumDetail",
query: { id: id },
});
},
}, },
watch: { watch: {
page(newPage) { page(newPage) {
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
href="javascript:;" href="javascript:;"
class="singer_list_txt__link js_singer" class="singer_list_txt__link js_singer"
:title="item.name" :title="item.name"
@click="gotoSongerDetail({ id: item.id })" @click="gotoSongerDetail(item.id)"
>{{ item.name }}</a >{{ item.name }}</a
> >
</li> </li>
...@@ -67,6 +67,7 @@ ...@@ -67,6 +67,7 @@
<script> <script>
import { getSongers, songerInitials, songerTypes, songerAreas } from "api"; import { getSongers, songerInitials, songerTypes, songerAreas } from "api";
import { gotoSongerDetail } from "common/utils";
import TypeSelectBar from "components/common/TypeSelectBar"; import TypeSelectBar from "components/common/TypeSelectBar";
import TypeSelectSubBar from "components/common/TypeSelectSubBar"; import TypeSelectSubBar from "components/common/TypeSelectSubBar";
...@@ -131,9 +132,7 @@ export default { ...@@ -131,9 +132,7 @@ export default {
this.updateArtists(); this.updateArtists();
} }
}, },
gotoSongerDetail(query) { gotoSongerDetail,
this.$router.push({ path: "/musicLibrary/songerDetail", query: query });
},
}, },
components: { components: {
TypeSelectBar, TypeSelectBar,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册