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

Commit 835092a

Browse files
committed
更新 - ranking-list 样式及数据
1 parent e4be3d9 commit 835092a

File tree

3 files changed

+149
-1
lines changed

3 files changed

+149
-1
lines changed

src/api/config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,9 @@ export const ARTIST_DETAIL_URL = 'https://c.y.qq.com/v8/fcg-bin/fcg_v8_singer_tr
2323
export const LYRIC_URL = '/api/getLyric'
2424

2525
export const RECOMMEND_ITEM_URL = '/api/getRecommendItem'
26+
27+
// 移动端 ranking-list url
28+
export const RANKING_LIST = 'https://c.y.qq.com/v8/fcg-bin/fcg_myqq_toplist.fcg'
29+
30+
// 桌面端 ranking-list url
31+
// export const RANKING_LIST = 'https://c.y.qq.com/v8/fcg-bin/fcg_v8_toplist_opt.fcg'

src/api/the-ranking.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { RANKING_LIST, options } from './config'
2+
import jsonp from 'common/js/jsonp'
3+
4+
// 桌面端 toplist jsonp 配置
5+
6+
/**
7+
* 原移动端 jsonp 方法改为了 ajax 请求(直接使用 jsonp 将导致格式错误),自己意外的以
8+
* 桌面端配置请求移动端 url 返回了正确数据
9+
*/
10+
11+
export function getRankingList () {
12+
const data = {
13+
page: 'index',
14+
format: 'html',
15+
tpl: 'macv4',
16+
v8debug: 1
17+
}
18+
19+
return jsonp(RANKING_LIST, data, {
20+
...options,
21+
prefix: '',
22+
name: 'jsonCallback'
23+
})
24+
}
25+
26+
// 移动端 toplist jsonp 配置
27+
// import { RANKING_LIST, commonParams, options } from './config'
28+
// import jsonp from 'common/js/jsonp'
29+
30+
// export function getRankingList () {
31+
// const data = {
32+
// ...commonParams,
33+
// uin: 0,
34+
// format: 'json',
35+
// platform: 'h5',
36+
// needNewCode: 1,
37+
// _: +new Date()
38+
// }
39+
40+
// return jsonp(RANKING_LIST, data, {
41+
// ...options,
42+
// prefix: '',
43+
// name: 'jsonCallback'
44+
// })
45+
// }
Lines changed: 98 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,110 @@
11
<template>
2-
<div class="ranking">Ranking area</div>
2+
<div class="ranking-list">
3+
<BaseScroll class="list-wrapper">
4+
<ul>
5+
<li
6+
class="ranking-item"
7+
v-for="(list, listIndex) of topList" :key="listIndex"
8+
>
9+
<div class="ranking-icon">
10+
<img v-lazy="list.picUrl" width="100" height="100" alt="ranking-icon">
11+
</div>
12+
13+
<ul class="ranking-info">
14+
<li
15+
class="info-song"
16+
v-for="(song, songIndex) of list.songList"
17+
:key="songIndex"
18+
>
19+
<span class="song-num">{{ songIndex + 1 }}</span>
20+
<span class="song-text">{{ song.songname }} - {{ song.singername }}</span>
21+
</li>
22+
</ul>
23+
24+
</li>
25+
</ul>
26+
</BaseScroll>
27+
</div>
328
</template>
429

530
<script>
31+
import BaseScroll from 'base/base-scroll'
32+
import { getRankingList } from 'api/the-ranking'
33+
import { ERR_OK } from 'api/config'
34+
635
export default {
36+
data () {
37+
return {
38+
topList: []
39+
}
40+
},
741
42+
methods: {
43+
_getRankingList () {
44+
getRankingList().then(res => {
45+
if (res.code === ERR_OK) {
46+
this.topList = res.data.topList
47+
}
48+
})
49+
}
50+
},
51+
52+
created () {
53+
this._getRankingList()
54+
},
55+
56+
components: {
57+
BaseScroll
58+
}
859
}
960
</script>
1061

1162
<style lang="scss" scoped>
63+
@import '~scss/variables';
64+
@import '~scss/mixin';
1265
66+
.ranking-list {
67+
position: fixed;
68+
top: 88px;
69+
bottom: 0;
70+
width: 100%;
71+
font-size: 0;
72+
.list-wrapper {
73+
height: 100%;
74+
width: 100%;
75+
overflow: hidden;
76+
}
77+
.ranking-item {
78+
display: flex;
79+
padding-top: 20px;
80+
margin: 0 20px;
81+
&:last-child {
82+
padding: 20px 0;
83+
}
84+
.ranking-icon {
85+
flex: 0 0 100px;
86+
width: 100px;
87+
height: 100px;
88+
img {
89+
width: 100px; // ios safari 不支持行内设置 img 宽高
90+
height: 100px;
91+
}
92+
}
93+
.ranking-info {
94+
flex: 1;
95+
display: flex;
96+
padding: 0 20px;
97+
flex-direction: column;
98+
justify-content: center;
99+
overflow: hidden;
100+
background-color: $color-highlight-background;
101+
color: $color-text-d;
102+
font-size: $font-size-small;
103+
.info-song {
104+
@include ellipsis();
105+
line-height: 26px;
106+
}
107+
}
108+
}
109+
}
13110
</style>

0 commit comments

Comments
 (0)