修复http post请求封装的bug

pull/96/head
lyswhut 2019-09-02 01:36:03 +08:00
parent a2f7547cdb
commit 507d495f3f
4 changed files with 17 additions and 12 deletions

View File

@ -72,7 +72,6 @@ const mutations = {
state.list.limit = result.limit state.list.limit = result.limit
state.list.page = result.page state.list.page = result.page
state.list.key = key state.list.key = key
console.log(result)
}, },
setListDetail(state, { result, key }) { setListDetail(state, { result, key }) {
state.listDetail.list = result.list state.listDetail.list = result.list

View File

@ -48,8 +48,14 @@ export default {
return `http://www2.kugou.kugou.com/yueku/v9/special/single/${id}-5-9999.html` return `http://www2.kugou.kugou.com/yueku/v9/special/single/${id}-5-9999.html`
}, },
getTagInfo(tagId) { /**
* 格式化播放数量
* @param {*} num
*/
formatPlayCount(num) {
if (num > 100000000) return parseInt(num / 10000000) / 10 + '亿'
if (num > 10000) return parseInt(num / 1000) / 10 + '万'
return num
}, },
filterInfoHotTag(rawData) { filterInfoHotTag(rawData) {
const result = [] const result = []
@ -112,19 +118,18 @@ export default {
} }
) )
return this._requestObj_listRecommend.promise.then(({ body }) => { 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.special_list)
return this.filterList(body.data)
}) })
}, },
filterList(rawData) { filterList(rawData) {
return rawData.map(item => ({ return rawData.map(item => ({
play_count: item.total_play_count, play_count: item.total_play_count || this.formatPlayCount(item.play_count),
id: item.specialid, id: item.specialid,
author: item.nickname, author: item.nickname,
name: item.specialname, name: item.specialname,
time: item.publish_time, time: item.publish_time || item.publishtime,
img: item.img, img: item.img || item.imgurl,
grade: item.grade, grade: item.grade,
desc: item.intro, desc: item.intro,
})) }))
@ -227,8 +232,8 @@ export default {
) )
if (!tagId) tasks.push(this.getSongListRecommend()) // 如果是所有类别,则顺便获取推荐列表 if (!tagId) tasks.push(this.getSongListRecommend()) // 如果是所有类别,则顺便获取推荐列表
return Promise.all(tasks).then(([list, info, recommendList]) => { return Promise.all(tasks).then(([list, info, recommendList]) => {
console.log(recommendList)
if (recommendList) list.unshift(...recommendList) if (recommendList) list.unshift(...recommendList)
console.log(info)
return { return {
list, list,
...info, ...info,

View File

@ -229,7 +229,9 @@ const fatchData = (url, method, options, callback) => {
method, method,
headers: Object.assign({}, headers, options.headers || {}), headers: Object.assign({}, headers, options.headers || {}),
Origin: options.origin, Origin: options.origin,
data: options.data, body: options.body,
form: options.form,
formData: options.formData,
timeout: options.timeout || 10000, timeout: options.timeout || 10000,
json: options.format === undefined || options.format === 'json', json: options.format === undefined || options.format === 'json',
}, (err, resp, body) => { }, (err, resp, body) => {

View File

@ -41,7 +41,6 @@ export default {
watch: { watch: {
sortId(n, o) { sortId(n, o) {
this.setSongList({ sortId: n }) this.setSongList({ sortId: n })
console.log(n)
if (o === undefined && this.listPage !== 1) return if (o === undefined && this.listPage !== 1) return
this.getList(1).then(() => { this.getList(1).then(() => {
this.listPage = this.listData.listPage this.listPage = this.listData.listPage