Skip to content
This repository was archived by the owner on May 11, 2021. It is now read-only.

Commit 4712123

Browse files
committed
更新 - 榜单页面
1 parent 0dccefa commit 4712123

File tree

9 files changed

+136
-6
lines changed

9 files changed

+136
-6
lines changed

src/api/config.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ export const LYRIC_URL = '/api/getLyric'
2525
export const RECOMMEND_ITEM_URL = '/api/getRecommendItem'
2626

2727
// 移动端 ranking-list url
28-
export const RANKING_LIST = 'https://c.y.qq.com/v8/fcg-bin/fcg_myqq_toplist.fcg'
28+
export const RANKING_LIST_URL = 'https://c.y.qq.com/v8/fcg-bin/fcg_myqq_toplist.fcg'
2929

3030
// 桌面端 ranking-list url
31-
// export const RANKING_LIST = 'https://c.y.qq.com/v8/fcg-bin/fcg_v8_toplist_opt.fcg'
31+
// export const RANKING_LIST_URL = 'https://c.y.qq.com/v8/fcg-bin/fcg_v8_toplist_opt.fcg'
32+
33+
export const FULL_RANKING_LIST_URL = 'https://c.y.qq.com/v8/fcg-bin/fcg_v8_toplist_cp.fcg'

src/api/the-ranking.js

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import { RANKING_LIST, options } from './config'
1+
import { RANKING_LIST_URL, FULL_RANKING_LIST_URL, options, commonParams } from './config'
22
import jsonp from 'common/js/jsonp'
33

4+
// start
5+
46
// 桌面端 toplist jsonp 配置
57

68
/**
@@ -16,7 +18,7 @@ export function getRankingList () {
1618
v8debug: 1
1719
}
1820

19-
return jsonp(RANKING_LIST, data, {
21+
return jsonp(RANKING_LIST_URL, data, {
2022
...options,
2123
prefix: '',
2224
name: 'jsonCallback'
@@ -43,3 +45,28 @@ export function getRankingList () {
4345
// name: 'jsonCallback'
4446
// })
4547
// }
48+
49+
// end
50+
51+
export function getFullRankingList (id) {
52+
const data = {
53+
...commonParams,
54+
tpl: 3,
55+
page: 'detail',
56+
// data: 歌单更新日期,
57+
topid: id,
58+
type: 'top',
59+
song_begin: 0,
60+
song_num: 30,
61+
loginUin: 0,
62+
hostUin: 0,
63+
platform: 'yqq',
64+
needNewCode: 0
65+
}
66+
67+
return jsonp(FULL_RANKING_LIST_URL, data, {
68+
...options,
69+
prefix: '',
70+
name: 'MusicJsonCallbacktoplist'
71+
})
72+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<template>
2+
<transition name="slide">
3+
<PartsMusicList
4+
:bgImage="selectedTopList.picUrl"
5+
:title="selectedTopList.topTitle"
6+
:songs="songList"
7+
/>
8+
</transition>
9+
</template>
10+
11+
<script>
12+
import PartsMusicList from 'components/parts-music-list/parts-music-list'
13+
import { getFullRankingList } from 'api/the-ranking'
14+
import { mapGetters } from 'vuex'
15+
import { ERR_OK } from 'api/config'
16+
import { createSong } from 'common/js/normalize-song'
17+
18+
export default {
19+
data () {
20+
return {
21+
songList: [] // 格式化后的歌曲容器
22+
}
23+
},
24+
25+
methods: {
26+
_getFullRankingList (id) {
27+
if (!this.selectedTopList.id) {
28+
this.$router.push({ path: '/ranking' })
29+
return
30+
}
31+
getFullRankingList(id).then(res => {
32+
if (res.code === ERR_OK) {
33+
this.songList = this._normalizeSong(res.songlist)
34+
} else {
35+
throw new Error('Check ERR_OK failed.')
36+
}
37+
})
38+
},
39+
40+
_normalizeSong (list) {
41+
let ret = []
42+
list.forEach(musicData => {
43+
if (musicData.data.songmid && musicData.data.albumid) {
44+
ret.push(createSong(musicData.data))
45+
}
46+
})
47+
return ret
48+
}
49+
},
50+
51+
created () {
52+
this._getFullRankingList(this.selectedTopList.id)
53+
},
54+
55+
computed: {
56+
...mapGetters([
57+
'selectedTopList'
58+
])
59+
},
60+
61+
components: {
62+
PartsMusicList
63+
}
64+
}
65+
</script>
66+
67+
<style lang="scss" scoped>
68+
.slide-enter, .slide-leave-to {
69+
transform: translateX(100%);
70+
}
71+
.slide-enter-active, .slide-leave-active {
72+
transition: all .3s ease;
73+
}
74+
</style>

src/components/the-ranking/ranking.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<li
66
class="ranking-item"
77
v-for="(list, listIndex) of topList" :key="listIndex"
8+
@click="selectList(list)"
89
>
910
<div class="ranking-icon">
1011
<img v-lazy="list.picUrl" width="100" height="100" alt="ranking-icon">
@@ -35,6 +36,7 @@ import BaseLoading from 'base/base-loading/base-loading'
3536
import { getRankingList } from 'api/the-ranking'
3637
import { ERR_OK } from 'api/config'
3738
import { playlistMixin } from 'common/js/mixin'
39+
import { mapMutations } from 'vuex'
3840
3941
export default {
4042
mixins: [playlistMixin],
@@ -45,13 +47,22 @@ export default {
4547
},
4648
4749
methods: {
50+
selectList (list) {
51+
this.selectedTopList(list)
52+
this.$router.push({ path: `/ranking/${list.id}` })
53+
},
54+
4855
handlePlaylist (playlist) {
4956
const bottom = this.playlist.length > 0 ? '60px' : ''
5057
5158
this.$refs.list.style.bottom = bottom
5259
this.$refs.scroll.refresh()
5360
},
5461
62+
...mapMutations({
63+
selectedTopList: 'SET_SELECTED_TOPLIST'
64+
}),
65+
5566
_getRankingList () {
5667
getRankingList().then(res => {
5768
if (res.code === ERR_OK) {

src/router/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import RecommendItem from 'components/parts-recom-item/parts-recom-item'
55
import Artist from 'components/the-artist/artist'
66
import ArtistItem from 'components/parts-artist-item/parts-artist-item'
77
import Ranking from 'components/the-ranking/ranking'
8+
import RankingItem from 'components/parts-ranking-item/parts-ranking-item'
89
import Search from 'components/the-search/search'
910

1011
Vue.use(Router)
@@ -37,7 +38,13 @@ export default new Router({
3738
},
3839
{
3940
path: '/ranking',
40-
component: Ranking
41+
component: Ranking,
42+
children: [
43+
{
44+
path: ':id',
45+
component: RankingItem
46+
}
47+
]
4148
},
4249
{
4350
path: '/search',

src/store/getters.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ export const currentSong = state => { // 经试验,修改 playlist 不会导
1717
}
1818

1919
export const recommendItem = state => state.recommendItem
20+
21+
export const selectedTopList = state => state.selectedTopList

src/store/mutation-types.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ export const SET_PLAY_MODE = 'SET_PLAY_MODE'
1414
export const SET_CURRENT_INDEX = 'SET_CURRENT_INDEX'
1515

1616
export const SET_RECOMMEND_ITEM = 'SET_RECOMMEND_ITEM'
17+
18+
export const SET_SELECTED_TOPLIST = 'SET_SELECTED_TOPLIST'

src/store/mutations.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ const mutations = {
3131

3232
[types.SET_RECOMMEND_ITEM] (state, recommendItem) {
3333
state.recommendItem = recommendItem
34+
},
35+
36+
[types.SET_SELECTED_TOPLIST] (state, selectedTopList) {
37+
state.selectedTopList = selectedTopList
3438
}
3539
}
3640

src/store/state.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ const state = { // 只保留最基础的数据,由基础数据可计算得到
88
sequenceList: [], // 播放列表的播放顺序列表
99
mode: playMode.sequence, // 语义化值,而不是直接写属性值
1010
currentIndex: -1, // 当前播放歌曲的索引,驱动歌曲的播放行为
11-
recommendItem: []
11+
recommendItem: [], // 用户点击的推荐歌单项
12+
selectedTopList: [] // 用户点击的排行榜
1213
}
1314

1415
export default state

0 commit comments

Comments
 (0)