tx源热门评论图片显示
This commit is contained in:
parent
0be5c3154a
commit
2e33d6c4cb
@ -128,36 +128,43 @@ export default {
|
|||||||
if (this._requestObj2) this._requestObj2.cancelHttp()
|
if (this._requestObj2) this._requestObj2.cancelHttp()
|
||||||
|
|
||||||
const songId = await this.getSongId(mInfo)
|
const songId = await this.getSongId(mInfo)
|
||||||
|
// const _requestObj2 = httpFetch('http://c.y.qq.com/base/fcgi-bin/fcg_global_comment_h5.fcg', {
|
||||||
const _requestObj2 = httpFetch('http://c.y.qq.com/base/fcgi-bin/fcg_global_comment_h5.fcg', {
|
// method: 'POST',
|
||||||
method: 'POST',
|
// headers: {
|
||||||
|
// 'User-Agent': 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)',
|
||||||
|
// },
|
||||||
|
// form: {
|
||||||
|
// uin: '0',
|
||||||
|
// format: 'json',
|
||||||
|
// cid: '205360772',
|
||||||
|
// reqtype: '2',
|
||||||
|
// biztype: '1',
|
||||||
|
// topid: songId,
|
||||||
|
// cmd: '9',
|
||||||
|
// needmusiccrit: '1',
|
||||||
|
// pagenum: page - 1,
|
||||||
|
// pagesize: limit,
|
||||||
|
// },
|
||||||
|
// })
|
||||||
|
const _requestObj2 = httpFetch(`https://u.y.qq.com/cgi-bin/musicu.fcg?data={"comm":{"cv":4747474,"ct":24,"format":"json","inCharset":"utf-8","outCharset":"utf-8","notice":0,"platform":"yqq.json","needNewCode":1,"uin":0,"g_tk_new_20200303":2101046530,"g_tk":2101046530},"req_1":{"module":"music.globalComment.CommentRead","method":"GetHotCommentList","param":{"BizType":1,"BizId":"${songId}","LastCommentSeqNo":"","PageSize":${limit},"PageNum":${page - 1},"HotType":1,"WithAirborne":0,"PicEnable":1}}}`, {
|
||||||
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'User-Agent': 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)',
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.0.0',
|
||||||
},
|
origin: 'https://y.qq.com',
|
||||||
form: {
|
referer: 'https://y.qq.com/',
|
||||||
uin: '0',
|
|
||||||
format: 'json',
|
|
||||||
cid: '205360772',
|
|
||||||
reqtype: '2',
|
|
||||||
biztype: '1',
|
|
||||||
topid: songId,
|
|
||||||
cmd: '9',
|
|
||||||
needmusiccrit: '1',
|
|
||||||
pagenum: page - 1,
|
|
||||||
pagesize: limit,
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
const { body, statusCode } = await _requestObj2.promise
|
const { body, statusCode } = await _requestObj2.promise
|
||||||
if (statusCode != 200 || body.code !== 0) throw new Error('获取热门评论失败')
|
// console.log('body', body)
|
||||||
// console.log(body, statusCode)
|
if (statusCode != 200 || body.code !== 0 || body.req_1.code !== 0) throw new Error('获取热门评论失败')
|
||||||
const comment = body.comment
|
const comment = body.req_1.data.CommentList
|
||||||
return {
|
return {
|
||||||
source: 'tx',
|
source: 'tx',
|
||||||
comments: this.filterComment(comment.commentlist),
|
comments: this.filterHotComment(comment.Comments),
|
||||||
total: comment.commenttotal,
|
total: comment.Total,
|
||||||
page,
|
page,
|
||||||
limit,
|
limit,
|
||||||
maxPage: Math.ceil(comment.commenttotal / limit) || 1,
|
maxPage: Math.ceil(comment.Total / limit) || 1,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
replaceEmoji(msg) {
|
replaceEmoji(msg) {
|
||||||
@ -211,4 +218,48 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
filterHotComment(rawList) {
|
||||||
|
return rawList.map(item => {
|
||||||
|
// let time = String(item.PubTime).length < 10 ? null : parseInt(item.PubTime + '000')
|
||||||
|
// let timeStr = time ? dateFormat2(time) : null
|
||||||
|
// if (item.SubComments) {
|
||||||
|
// let firstItem = item.SubComments[0]
|
||||||
|
// firstItem.avatarurl = item.avatarurl
|
||||||
|
// firstItem.praisenum = item.praisenum
|
||||||
|
// item.avatarurl = null
|
||||||
|
// item.praisenum = null
|
||||||
|
// item.SubComments.reverse()
|
||||||
|
// }
|
||||||
|
return {
|
||||||
|
id: `${item.SeqNo}_${item.EncryptUin}`,
|
||||||
|
rootId: item.SeqNo,
|
||||||
|
text: item.Content ? this.replaceEmoji(item.Content).replace(/\\n/g, '\n').split('\n') : [],
|
||||||
|
time: this.formatTime(item.PubTime),
|
||||||
|
timeStr: item.PubTime ? dateFormat2(this.formatTime(item.PubTime)) : null,
|
||||||
|
userName: item.Nick ? item.Nick.substring(1) : '',
|
||||||
|
images: item.Pic ? [item.Pic] : [],
|
||||||
|
avatar: item.Avatar,
|
||||||
|
userId: item.EncryptUin,
|
||||||
|
likedCount: item.PraiseNum,
|
||||||
|
reply: item.SubComments
|
||||||
|
? item.SubComments.map(c => {
|
||||||
|
// let index = c.subcommentid.lastIndexOf('_')
|
||||||
|
return {
|
||||||
|
id: `sub_${item.SeqNo}_${c.EncryptUin}`,
|
||||||
|
text: this.replaceEmoji(c.Content).replace(/\\n/g, '\n').split('\n'),
|
||||||
|
time: this.formatTime(c.PubTime),
|
||||||
|
timeStr: item.PubTime ? dateFormat2(this.formatTime(c.PubTime)) : null,
|
||||||
|
userName: c.Nick.substring(1),
|
||||||
|
avatar: c.Avatar,
|
||||||
|
userId: c.EncryptUin,
|
||||||
|
likedCount: c.PraiseNum,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
: [],
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
formatTime(time) {
|
||||||
|
return String(time).length < 10 ? null : parseInt(time + '000')
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user