播放详情页新增歌曲评论加载显示

This commit is contained in:
lyswhut
2020-10-27 18:09:17 +08:00
parent 8d8cabd5b3
commit 8c76c3d81c
17 changed files with 442 additions and 158 deletions
+3 -3
View File
@@ -43,11 +43,11 @@ export const dateFormat = (date = new Date(), format = 'YYYY-MM-DD hh:mm:ss') =>
export const dateFormat2 = time => {
let differ = parseInt((Date.now() - time) / 1000)
if (differ < 60) {
return differ + '秒前'
return window.i18n.t('base.date_format_second', { num: differ })
} else if (differ < 3600) {
return parseInt(differ / 60) + '分钟前'
return window.i18n.t('base.date_format_minute', { num: parseInt(differ / 60) })
} else if (differ < 86400) {
return parseInt(differ / 3600) + '小时前'
return window.i18n.t('base.date_format_hour', { num: parseInt(differ / 3600) })
} else {
return dateFormat(time)
}
+4 -4
View File
@@ -15,10 +15,10 @@ export default {
const { body, statusCode } = await _requestObj.promise
// console.log(body)
if (statusCode != 200 || body.err_code !== 0) throw new Error('获取评论失败')
return { source: 'kg', comments: this.filterComment(body.list), total: body.count, page, limit, maxPage: Math.ceil(body.count / limit) || 1 }
return { source: 'kg', comments: this.filterComment(body.list || []), total: body.count, page, limit, maxPage: Math.ceil(body.count / limit) || 1 }
},
async getHotComment({ hash, songmid }, page = 1, limit = 100) {
console.log(songmid)
// console.log(songmid)
if (this._requestObj2) this._requestObj2.cancelHttp()
const _requestObj2 = httpFetch(`http://comment.service.kugou.com/index.php?r=commentsv2/getCommentWithLike&code=fc4be23b4e972707f36b8a828a93ba8a&extdata=${hash}&p=${page}&pagesize=${limit}&ver=1.01&clientver=8373&appid=1001&kugouid=687373022`, {
@@ -29,7 +29,7 @@ export default {
const { body, statusCode } = await _requestObj2.promise
// console.log(body)
if (statusCode != 200 || body.err_code !== 0) throw new Error('获取热门评论失败')
return { source: 'kg', comments: this.filterComment(body.weightList) }
return { source: 'kg', comments: this.filterComment(body.weightList || []) }
},
async getReplyComment({ songmid }, replyId, page = 1, limit = 100) {
if (this._requestObj2) this._requestObj2.cancelHttp()
@@ -42,7 +42,7 @@ export default {
const { body, statusCode } = await _requestObj2.promise
// console.log(body)
if (statusCode != 200 || body.err_code !== 0) throw new Error('获取回复评论失败')
return { source: 'kg', comments: this.filterComment(body.list) }
return { source: 'kg', comments: this.filterComment(body.list || []) }
},
filterComment(rawList) {
return rawList.map(item => {
+2 -2
View File
@@ -161,7 +161,7 @@ export default {
return {
id: item.subcommentid,
rootId: item.rootcommentid,
text: item.rootcommentcontent ? this.replaceEmoji(item.rootcommentcontent).split('\n') : [],
text: item.rootcommentcontent ? this.replaceEmoji(item.rootcommentcontent).replace(/\\\n/g, '\n').split('\n') : [],
time,
timeStr: time ? dateFormat2(time) : null,
userName: item.rootcommentnick ? item.rootcommentnick.substring(1) : '',
@@ -172,7 +172,7 @@ export default {
let index = c.subcommentid.lastIndexOf('_')
return {
id: c.subcommentid,
text: this.replaceEmoji(c.subcommentcontent).split('\n'),
text: this.replaceEmoji(c.subcommentcontent).replace(/\\\n/g, '\n').split('\n'),
time: parseInt(c.subcommentid.substring(index + 1) + '000'),
timeStr: dateFormat2(parseInt(c.subcommentid.substring(index + 1) + '000')),
userName: c.replynick.substring(1),