修复歌单接口bug,完善歌单页面

This commit is contained in:
lyswhut
2019-09-02 00:57:57 +08:00
parent d48308d913
commit a2f7547cdb
9 changed files with 86 additions and 106 deletions
+5 -7
View File
@@ -13,13 +13,11 @@ export default {
sortList: [
{
name: '最热',
tabId: 'bdhot',
id: '最热',
id: '1',
},
{
name: '最新',
tabId: 'bdnew',
id: '最新',
id: '0',
},
],
aesPassEncod(jsonData) {
@@ -91,7 +89,7 @@ export default {
},
getListUrl(sortType, tagName, page) {
return this.createUrl({
channelname: tagName,
channelname: tagName || '全部',
from: 'qianqianmini',
offset: (page - 1) * this.limit_list,
order_type: sortType,
@@ -116,8 +114,8 @@ export default {
return this._requestObj_tags.promise.then(({ body }) => {
if (body.error_code !== this.successCode) return this.getTags()
return {
hotTag: this.filterInfoHotTag(body.data.hot),
tags: this.filterTagInfo(body.data.tags),
hotTag: this.filterInfoHotTag(body.result.hot),
tags: this.filterTagInfo(body.result.tags),
}
})
},
+29 -36
View File
@@ -2,37 +2,34 @@ import { httpFatch } from '../../request'
import { formatPlayTime, sizeFormate } from '../../index'
export default {
_requestObj_tagInfo: null,
_requestObj_tags: null,
_requestObj_listInfo: null,
_requestObj_list: null,
_requestObj_listRecommend: null,
_requestObj_listDetail: null,
currentTagInfo: {
id: null,
info: null,
id: undefined,
info: undefined,
},
sortList: [
{
name: '推荐',
tabId: 'kgrecommend',
id: '5',
},
{
name: '最热',
tabId: 'kghot',
id: '6',
},
{
name: '最新',
tabId: 'kgnew',
id: '7',
},
{
name: '热藏',
tabId: 'kghotcollect',
id: '3',
},
{
name: '飙升',
tabId: 'kgup',
id: '8',
},
],
@@ -44,7 +41,7 @@ export default {
? `http://www2.kugou.kugou.com/yueku/v9/special/getSpecial?is_smarty=1&cdn=cdn&t=5&c=${tagId}`
: `http://www2.kugou.kugou.com/yueku/v9/special/getSpecial?is_smarty=1&`
},
getSongListUrl(sortId, tagId, page) {
getSongListUrl(sortId, tagId = '', page) {
return `http://www2.kugou.kugou.com/yueku/v9/special/index/getData/getData.html&cdn=cdn&t=${sortId}&c=${tagId}?is_ajax=1&p=${page}`
},
getSongListDetailUrl(id) {
@@ -52,26 +49,13 @@ export default {
},
getTagInfo(tagId) {
if (this._requestObj_tagInfo) this._requestObj_tagInfo.cancelHttp()
this._requestObj_tagInfo = httpFatch(this.getInfoUrl(tagId))
return this._requestObj_tagInfo.promise.then(({ body }) => {
if (body.status !== 1) return this.getTagInfo(tagId)
return {
hotTag: this.filterInfoHotTag(body.data.hotTag),
tags: this.filterTagInfo(body.data.tagids),
tagInfo: {
limit: body.data.params.pagesize,
page: body.data.params.p,
total: body.data.params.total,
},
}
})
},
filterInfoHotTag(rawData) {
const result = []
if (rawData.status !== 1) return result
for (let index = 0; index < Object.keys(rawData.data).lengt; index++) {
let tag = rawData.data[index.toString()]
for (const key of Object.keys(rawData.data)) {
let tag = rawData.data[key]
result.push({
id: tag.id,
name: tag.special_name,
@@ -92,6 +76,7 @@ export default {
})),
})
}
return result
},
getSongList(sortId, tagId, page) {
@@ -101,12 +86,12 @@ export default {
)
return this._requestObj_list.promise.then(({ body }) => {
if (body.status !== 1) return this.getSongList(sortId, tagId, page)
return this.filterList(body.data)
return this.filterList(body.special_db)
})
},
getSongListRecommend() {
if (this._requestObj_listRecommend) this._requestObj_listRecommend.cancelHttp()
this._requestObj_listRecommendRecommend = httpFatch(
this._requestObj_listRecommend = httpFatch(
'http://everydayrec.service.kugou.com/guess_special_recommend',
{
method: 'post',
@@ -127,7 +112,8 @@ export default {
}
)
return this._requestObj_listRecommend.promise.then(({ body }) => {
if (body.status !== 1) return this.getSongListRecommend()
// if (body.status !== 1) return this.getSongListRecommend()
if (body.status !== 1) return []
return this.filterList(body.data)
})
},
@@ -215,11 +201,14 @@ export default {
// 获取列表信息
getListInfo(tagId) {
return this.getTagInfo(tagId).then(info => {
if (this._requestObj_listInfo) this._requestObj_listInfo.cancelHttp()
this._requestObj_listInfo = httpFatch(this.getInfoUrl(tagId))
return this._requestObj_listInfo.promise.then(({ body }) => {
if (body.status !== 1) return this.getListInfo(tagId)
return {
limit: info.tagInfo.limit,
page: info.tagInfo.page,
total: info.tagInfo.total,
limit: body.data.params.pagesize,
page: body.data.params.p,
total: body.data.params.total,
}
})
},
@@ -237,8 +226,9 @@ export default {
})
)
if (!tagId) tasks.push(this.getSongListRecommend()) // 如果是所有类别,则顺便获取推荐列表
Promise.all(tasks).then(([list, info, recommendList]) => {
return Promise.all(tasks).then(([list, info, recommendList]) => {
if (recommendList) list.unshift(...recommendList)
console.log(info)
return {
list,
...info,
@@ -248,10 +238,13 @@ export default {
// 获取标签
getTags() {
return this.getTagInfo().then(info => {
if (this._requestObj_tags) this._requestObj_tags.cancelHttp()
this._requestObj_tags = httpFatch(this.getInfoUrl())
return this._requestObj_tags.promise.then(({ body }) => {
if (body.status !== 1) return this.getTags()
return {
hotTag: info.hotTag,
tags: info.tags,
hotTag: this.filterInfoHotTag(body.data.hotTag),
tags: this.filterTagInfo(body.data.tagids),
}
})
},
+15 -17
View File
@@ -13,43 +13,41 @@ export default {
sortList: [
{
name: '最热',
tabId: 'kwhot',
id: 'hot',
},
{
name: '最新',
tabId: 'kwnew',
id: 'new',
},
],
tagsUrl: 'http://wapi.kuwo.cn/api/pc/classify/playlist/getTagList?cmd=rcm_keyword_playlist&user=0&prod=kwplayer_pc_9.0.5.0&vipver=9.0.5.0&source=kwplayer_pc_9.0.5.0&loginUid=0&loginSid=0&appUid=76039576',
hotTagUrl: 'http://wapi.kuwo.cn/api/pc/classify/playlist/getRcmTagList?loginUid=0&loginSid=0&appUid=76039576',
getListUrl({ sortType, id, page }) {
getListUrl({ sortId, id, page }) {
return id
? `http://wapi.kuwo.cn/api/pc/classify/playlist/getTagPlayList?loginUid=0&loginSid=0&appUid=76039576&id=${id}&pn=${page}&rn=${this.limit}`
: `http://wapi.kuwo.cn/api/pc/classify/playlist/getRcmPlayList?loginUid=0&loginSid=0&appUid=76039576&pn=${page}&rn=${this.limit}&order=${sortType}`
? `http://wapi.kuwo.cn/api/pc/classify/playlist/getTagPlayList?loginUid=0&loginSid=0&appUid=76039576&id=${id}&pn=${page}&rn=${this.limit_list}`
: `http://wapi.kuwo.cn/api/pc/classify/playlist/getRcmPlayList?loginUid=0&loginSid=0&appUid=76039576&pn=${page}&rn=${this.limit_list}&order=${sortId}`
},
getListDetailUrl(id, page) {
return `http://nplserver.kuwo.cn/pl.svc?op=getlistinfo&pid=${id}&pn=${page - 1}&rn=${this.limit}&encode=utf8&keyset=pl2012&identity=kuwo&pcmp4=1&vipver=MUSIC_9.0.5.0_W1&newver=1`
return `http://nplserver.kuwo.cn/pl.svc?op=getlistinfo&pid=${id}&pn=${page - 1}&rn=${this.limit_song}&encode=utf8&keyset=pl2012&identity=kuwo&pcmp4=1&vipver=MUSIC_9.0.5.0_W1&newver=1`
},
// 获取标签
getTags() {
getTag() {
if (this._requestObj_tags) this._requestObj_tags.cancelHttp()
this._requestObj_tags = httpFatch(this.tagsUrl)
return this._requestObj_tags.promise.then(({ body }) => {
if (body.code !== this.successCode) return this.getTags()
return this.filterTagInfo(body.data.tags)
if (body.code !== this.successCode) return this.getTag()
return this.filterTagInfo(body.data)
})
},
// 获取标签
getHotTags() {
getHotTag() {
if (this._requestObj_hotTags) this._requestObj_hotTags.cancelHttp()
this._requestObj_hotTags = httpFatch(this.hotTagUrl)
return this._requestObj_hotTags.promise.then(({ body }) => {
if (body.code !== this.successCode) return this.getHotTags()
return this.filterInfoHotTag(body.data.data)
if (body.code !== this.successCode) return this.getHotTag()
return this.filterInfoHotTag(body.data[0].data)
})
},
filterInfoHotTag(rawList) {
@@ -73,11 +71,9 @@ export default {
// 获取列表数据
getList(sortId, tagId, page) {
if (this._requestObj_list) this._requestObj_list.cancelHttp()
this._requestObj_list = httpFatch(
this.getListUrl({ sortId, id: tagId, page })
)
this._requestObj_list = httpFatch(this.getListUrl({ sortId, id: tagId, page }))
return this._requestObj_list.promise.then(({ body }) => {
if (body.code !== this.successCode) return this.getList({ sortId, id: tagId, page })
if (body.code !== this.successCode) return this.getListUrl({ sortId, id: tagId, page })
return {
list: this.filterList(body.data.data),
total: body.data.total,
@@ -167,7 +163,9 @@ export default {
}
})
},
getTags() {
return Promise.all([this.getTag(), this.getHotTag()]).then(([tags, hotTag]) => ({ tags, hotTag }))
},
}
// getList