完善评论
parent
09f4d8ac0c
commit
ca12dc604d
|
@ -29,7 +29,8 @@ export default {
|
||||||
const { body, statusCode } = await _requestObj2.promise
|
const { body, statusCode } = await _requestObj2.promise
|
||||||
// console.log(body)
|
// console.log(body)
|
||||||
if (statusCode != 200 || body.err_code !== 0) throw new Error('获取热门评论失败')
|
if (statusCode != 200 || body.err_code !== 0) throw new Error('获取热门评论失败')
|
||||||
return { source: 'kg', comments: this.filterComment(body.weightList || []) }
|
const total = body.weightList?.length ?? 0
|
||||||
|
return { source: 'kg', comments: this.filterComment(body.weightList || []), total, page, limit, maxPage: 1 }
|
||||||
},
|
},
|
||||||
async getReplyComment({ songmid, audioId }, replyId, page = 1, limit = 100) {
|
async getReplyComment({ songmid, audioId }, replyId, page = 1, limit = 100) {
|
||||||
if (this._requestObj2) this._requestObj2.cancelHttp()
|
if (this._requestObj2) this._requestObj2.cancelHttp()
|
||||||
|
|
|
@ -28,7 +28,7 @@ export default {
|
||||||
const { body, statusCode } = await _requestObj2.promise
|
const { body, statusCode } = await _requestObj2.promise
|
||||||
if (statusCode != 200 || body.result !== 'ok') throw new Error('获取热门评论失败')
|
if (statusCode != 200 || body.result !== 'ok') throw new Error('获取热门评论失败')
|
||||||
// console.log(body)
|
// console.log(body)
|
||||||
return { source: 'kw', comments: this.filterComment(body.rows) }
|
return { source: 'kw', comments: this.filterComment(body.rows), total: body.total, page, limit, maxPage: Math.ceil(body.total / limit) || 1 }
|
||||||
},
|
},
|
||||||
filterComment(rawList) {
|
filterComment(rawList) {
|
||||||
if (!rawList) return []
|
if (!rawList) return []
|
||||||
|
|
|
@ -53,7 +53,7 @@ export default {
|
||||||
const { body, statusCode } = await _requestObj2.promise
|
const { body, statusCode } = await _requestObj2.promise
|
||||||
// console.log(body)
|
// console.log(body)
|
||||||
if (statusCode != 200 || body.returnCode !== '000000') throw new Error('获取热门评论失败')
|
if (statusCode != 200 || body.returnCode !== '000000') throw new Error('获取热门评论失败')
|
||||||
return { source: 'mg', comments: this.filterComment(body.data.items) }
|
return { source: 'mg', comments: this.filterComment(body.data.items), total: body.data.itemTotal, page, limit, maxPage: Math.ceil(body.data.itemTotal / limit) || 1 }
|
||||||
},
|
},
|
||||||
async getReplyComment(musicInfo, replyId, page = 1, limit = 10) {
|
async getReplyComment(musicInfo, replyId, page = 1, limit = 10) {
|
||||||
if (this._requestObj2) this._requestObj2.cancelHttp()
|
if (this._requestObj2) this._requestObj2.cancelHttp()
|
||||||
|
|
|
@ -77,6 +77,7 @@ export default {
|
||||||
if (this._requestObj) this._requestObj.cancelHttp()
|
if (this._requestObj) this._requestObj.cancelHttp()
|
||||||
|
|
||||||
const _requestObj = httpFetch('http://c.y.qq.com/base/fcgi-bin/fcg_global_comment_h5.fcg', {
|
const _requestObj = httpFetch('http://c.y.qq.com/base/fcgi-bin/fcg_global_comment_h5.fcg', {
|
||||||
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'User-Agent': 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)',
|
'User-Agent': 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)',
|
||||||
},
|
},
|
||||||
|
@ -110,6 +111,7 @@ export default {
|
||||||
if (this._requestObj2) this._requestObj2.cancelHttp()
|
if (this._requestObj2) this._requestObj2.cancelHttp()
|
||||||
|
|
||||||
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',
|
||||||
headers: {
|
headers: {
|
||||||
'User-Agent': 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)',
|
'User-Agent': 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)',
|
||||||
},
|
},
|
||||||
|
@ -134,6 +136,9 @@ export default {
|
||||||
source: 'tx',
|
source: 'tx',
|
||||||
comments: this.filterComment(comment.commentlist),
|
comments: this.filterComment(comment.commentlist),
|
||||||
total: comment.commenttotal,
|
total: comment.commenttotal,
|
||||||
|
page,
|
||||||
|
limit,
|
||||||
|
maxPage: Math.ceil(comment.commenttotal / limit) || 1,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
replaceEmoji(msg) {
|
replaceEmoji(msg) {
|
||||||
|
@ -149,7 +154,8 @@ export default {
|
||||||
},
|
},
|
||||||
filterComment(rawList) {
|
filterComment(rawList) {
|
||||||
return rawList.map(item => {
|
return rawList.map(item => {
|
||||||
let time = item.rootcommentid ? parseInt(item.rootcommentid.substring(item.rootcommentid.lastIndexOf('_') + 1) + '000') : null
|
let time = parseInt(item.time + '000')
|
||||||
|
let timeStr = dateFormat2(time)
|
||||||
if (item.middlecommentcontent) {
|
if (item.middlecommentcontent) {
|
||||||
let firstItem = item.middlecommentcontent[0]
|
let firstItem = item.middlecommentcontent[0]
|
||||||
firstItem.avatarurl = item.avatarurl
|
firstItem.avatarurl = item.avatarurl
|
||||||
|
@ -159,23 +165,23 @@ export default {
|
||||||
item.middlecommentcontent.reverse()
|
item.middlecommentcontent.reverse()
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
id: item.subcommentid,
|
id: `${item.rootcommentid}_${item.commentid}`,
|
||||||
rootId: item.rootcommentid,
|
rootId: item.rootcommentid,
|
||||||
text: item.rootcommentcontent ? this.replaceEmoji(item.rootcommentcontent).replace(/\\n/g, '\n').split('\n') : [],
|
text: item.rootcommentcontent ? this.replaceEmoji(item.rootcommentcontent).replace(/\\n/g, '\n').split('\n') : [],
|
||||||
time,
|
time: item.rootcommentid == item.commentid ? time : null,
|
||||||
timeStr: time ? dateFormat2(time) : null,
|
timeStr: item.rootcommentid == item.commentid ? timeStr : null,
|
||||||
userName: item.rootcommentnick ? item.rootcommentnick.substring(1) : '',
|
userName: item.rootcommentnick ? item.rootcommentnick.substring(1) : '',
|
||||||
avatar: item.avatarurl,
|
avatar: item.avatarurl,
|
||||||
userId: item.encrypt_rootcommentuin,
|
userId: item.encrypt_rootcommentuin,
|
||||||
likedCount: item.praisenum,
|
likedCount: item.praisenum,
|
||||||
reply: item.middlecommentcontent
|
reply: item.middlecommentcontent
|
||||||
? item.middlecommentcontent.map(c => {
|
? item.middlecommentcontent.map(c => {
|
||||||
let index = c.subcommentid.lastIndexOf('_')
|
// let index = c.subcommentid.lastIndexOf('_')
|
||||||
return {
|
return {
|
||||||
id: c.subcommentid,
|
id: `sub_${item.rootcommentid}_${c.subcommentid}`,
|
||||||
text: this.replaceEmoji(c.subcommentcontent).replace(/\\n/g, '\n').split('\n'),
|
text: this.replaceEmoji(c.subcommentcontent).replace(/\\n/g, '\n').split('\n'),
|
||||||
time: parseInt(c.subcommentid.substring(index + 1) + '000'),
|
time: c.subcommentid == item.commentid ? time : null,
|
||||||
timeStr: dateFormat2(parseInt(c.subcommentid.substring(index + 1) + '000')),
|
timeStr: c.subcommentid == item.commentid ? timeStr : null,
|
||||||
userName: c.replynick.substring(1),
|
userName: c.replynick.substring(1),
|
||||||
avatar: c.avatarurl,
|
avatar: c.avatarurl,
|
||||||
userId: c.encrypt_replyuin,
|
userId: c.encrypt_replyuin,
|
||||||
|
|
|
@ -104,7 +104,8 @@ export default {
|
||||||
const { body, statusCode } = await _requestObj2.promise
|
const { body, statusCode } = await _requestObj2.promise
|
||||||
if (statusCode != 200 || body.code !== 200) throw new Error('获取热门评论失败')
|
if (statusCode != 200 || body.code !== 200) throw new Error('获取热门评论失败')
|
||||||
// console.log(body)
|
// console.log(body)
|
||||||
return { source: 'wy', comments: this.filterComment(body.data.hotComments) }
|
const total = body.data.hotComments?.length ?? 0
|
||||||
|
return { source: 'wy', comments: this.filterComment(body.data.hotComments), total, page, limit, maxPage: 1 }
|
||||||
},
|
},
|
||||||
filterComment(rawList) {
|
filterComment(rawList) {
|
||||||
return rawList.map(item => {
|
return rawList.map(item => {
|
||||||
|
|
Loading…
Reference in New Issue