revert 解决冲突
This commit is contained in:
2025-11-27 15:38:24 +08:00
parent 3da220526b
commit 64abd3d4ab
28 changed files with 1059 additions and 705 deletions

View File

@@ -230,43 +230,70 @@ function initScrollHeight() {
// 加载书籍详情
async function loadBookInfo() {
const res = await bookApi.getBookInfo(bookId.value)
bookInfo.value = res.bookInfo
try {
const res = await bookApi.getBookInfo(bookId.value)
if (res.bookInfo) {
bookInfo.value = res.bookInfo
}
} catch (error) {
console.error('Failed to load book info:', error)
}
}
// 加载购买商品信息
async function loadGoodsInfo() {
const res = await bookApi.getBookGoods(bookId.value)
goodsList.value = res.productList || []
try {
const res = await bookApi.getBookGoods(bookId.value)
if (res.code === 0) {
goodsList.value = res.productList || []
}
} catch (error) {
console.error('Failed to load goods info:', error)
}
}
// 加载统计数据
async function loadBookCount() {
const res = await bookApi.getBookReadCount(bookId.value)
if (res.code === 0) {
readCount.value = res.readCount || 0
listenCount.value = res.listenCount || 0
buyCount.value = res.buyCount || 0
try {
const res = await bookApi.getBookReadCount(bookId.value)
if (res.code === 0) {
readCount.value = res.readCount || 0
listenCount.value = res.listenCount || 0
buyCount.value = res.buyCount || 0
}
} catch (error) {
console.error('Failed to load book count:', error)
}
}
// 加载评论
async function loadComments() {
const res = await bookApi.getBookComments(bookId.value, 1, 10)
if (res.commentsTree && res.commentsTree.length > 0) {
commentList.value = res.commentsTree
} else {
try {
const res = await bookApi.getBookComments(bookId.value, 1, 10)
if (res.commentsTree && res.commentsTree.length > 0) {
commentList.value = res.commentsTree
} else {
nullText.value = t('common.data_null')
}
} catch (error) {
nullText.value = t('common.data_null')
console.error('Failed to load comments:', error)
}
}
// 加载推荐书籍
async function loadRecommendBooks() {
const res = await bookApi.getRecommendBook(bookId.value)
if (res.bookList && res.bookList.length > 0) {
relatedBooks.value = res.bookList
} else {
try {
const res = await bookApi.getRecommendBook(bookId.value)
if (res.bookList && res.bookList.length > 0) {
relatedBooks.value = res.bookList
} else {
nullBookText.value = t('common.data_null')
}
} catch (error) {
nullBookText.value = t('common.data_null')
console.error('Failed to load recommend books:', error)
}
}