修复:解决测试发现的问题
This commit is contained in:
@@ -128,7 +128,7 @@
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
<wd-button type="primary" custom-class="buy-btn" @click="handlePurchase">
|
||||
<wd-button type="primary" block @click="handlePurchase">
|
||||
{{ $t('bookDetails.buy') }}
|
||||
</wd-button>
|
||||
</view>
|
||||
@@ -222,15 +222,12 @@ function initScrollHeight() {
|
||||
// 加载书籍详情
|
||||
async function loadBookInfo() {
|
||||
try {
|
||||
uni.showLoading({ title: t('global.loading') })
|
||||
const res = await bookApi.getBookInfo(bookId.value)
|
||||
uni.hideLoading()
|
||||
|
||||
if (res.bookInfo) {
|
||||
bookInfo.value = res.bookInfo
|
||||
}
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
console.error('Failed to load book info:', error)
|
||||
}
|
||||
}
|
||||
@@ -531,6 +528,7 @@ function goToDetail(id: number) {
|
||||
&.buy-full {
|
||||
flex: 1;
|
||||
padding: 0 30rpx;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,7 +330,6 @@ const getBooksByLabel = async (
|
||||
labelId: number,
|
||||
type: 'activity' | 'category'
|
||||
) => {
|
||||
uni.showLoading({ title: t('common.loading') })
|
||||
try {
|
||||
const res = await homeApi.getBooksByLabel(labelId)
|
||||
if (type === 'activity') {
|
||||
@@ -348,8 +347,6 @@ const getBooksByLabel = async (
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取图书列表失败:', error)
|
||||
} finally {
|
||||
uni.hideLoading()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -130,11 +130,9 @@ async function loadBookInfo() {
|
||||
// 加载章节列表
|
||||
async function loadChapterList() {
|
||||
try {
|
||||
uni.showLoading({ title: t('global.loading') })
|
||||
const res = await bookApi.getBookChapter({
|
||||
bookId: bookId.value
|
||||
})
|
||||
uni.hideLoading()
|
||||
|
||||
if (res.chapterList && res.chapterList.length > 0) {
|
||||
chapterList.value = res.chapterList
|
||||
@@ -142,7 +140,6 @@ async function loadChapterList() {
|
||||
nullText.value = t('common.data_null')
|
||||
}
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
nullText.value = t('common.data_null')
|
||||
console.error('Failed to load chapter list:', error)
|
||||
}
|
||||
|
||||
@@ -258,8 +258,6 @@ async function loadBookInfo() {
|
||||
// 加载章节列表
|
||||
async function loadChapterList() {
|
||||
try {
|
||||
uni.showLoading({ title: t('common.loading') })
|
||||
|
||||
const res = await bookApi.getBookChapter({
|
||||
bookId: bookId.value
|
||||
})
|
||||
@@ -269,8 +267,6 @@ async function loadChapterList() {
|
||||
if (res.chapterList && res.chapterList.length > 0) {
|
||||
chapterList.value = res.chapterList
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
// 加载当前章节内容
|
||||
if (currentChapterIndex.value < chapterList.value.length) {
|
||||
const currentChapter = chapterList.value[currentChapterIndex.value]
|
||||
@@ -280,14 +276,12 @@ async function loadChapterList() {
|
||||
playChapter(currentChapter)
|
||||
}
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '章节列表为空',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
console.error('Failed to load chapter list:', error)
|
||||
uni.showToast({
|
||||
title: '加载章节失败',
|
||||
@@ -298,9 +292,7 @@ async function loadChapterList() {
|
||||
|
||||
// 加载章节内容(带音频时间点)
|
||||
async function loadChapterContent(chapterId: number) {
|
||||
try {
|
||||
uni.showLoading({ title: t('common.loading') })
|
||||
|
||||
try {
|
||||
console.log('加载章节内容, chapterId:', chapterId)
|
||||
const res = await bookApi.getChapterContentListen(chapterId)
|
||||
console.log('章节内容响应:', res)
|
||||
@@ -327,11 +319,8 @@ async function loadChapterContent(chapterId: number) {
|
||||
console.log('章节内容为空')
|
||||
currentContent.value = '暂无内容'
|
||||
}
|
||||
|
||||
uni.hideLoading()
|
||||
} catch (error) {
|
||||
console.error('Failed to load chapter content:', error)
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '加载内容失败',
|
||||
icon: 'none'
|
||||
@@ -364,7 +353,6 @@ function playChapter(chapter: IChapter) {
|
||||
|
||||
if (audioContext.value) {
|
||||
console.log('设置音频源:', chapter.voices)
|
||||
uni.showLoading({ title: t('common.readAudio') })
|
||||
|
||||
audioContext.value.src = chapter.voices
|
||||
audioContext.value.playbackRate = playbackRate.value
|
||||
@@ -372,7 +360,6 @@ function playChapter(chapter: IChapter) {
|
||||
// 监听音频准备就绪
|
||||
audioContext.value.onCanplay(() => {
|
||||
console.log('音频准备就绪')
|
||||
uni.hideLoading()
|
||||
})
|
||||
|
||||
audioContext.value.play()
|
||||
|
||||
0
pages/book/order.vue
Normal file
0
pages/book/order.vue
Normal file
@@ -2,12 +2,27 @@
|
||||
<view class="reader-page" :class="themeClass">
|
||||
<!-- 顶部标题栏 (可隐藏) -->
|
||||
<view class="reader-header" :style="{ top: notchHeight + 'px' }">
|
||||
<wd-icon name="arrow-left" size="20px" @click="goBack" />
|
||||
<wd-icon name="arrow-left" size="20px" @click="onPageBack" />
|
||||
<text class="chapter-title">{{ currentChapterTitle }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 阅读内容区域 -->
|
||||
<view class="reader-content" @click="toggleControls">
|
||||
<!-- 仿真翻页 -->
|
||||
<!-- <view class="content-wrapper">
|
||||
<nx-turn
|
||||
:initPage="0"
|
||||
:pageCount="4"
|
||||
>
|
||||
<template v-slot:page-content="{ page }">
|
||||
<text>{{ page }}</text>
|
||||
</template>
|
||||
<template v-slot:next-page-content="{ page }">
|
||||
<text>{{ page }}</text>
|
||||
</template>
|
||||
</nx-turn>
|
||||
</view> -->
|
||||
|
||||
<!-- 左右翻页模式 -->
|
||||
<view
|
||||
v-if="readMode === 'page'"
|
||||
@@ -37,9 +52,9 @@
|
||||
</view>
|
||||
|
||||
<!-- 页码指示器 -->
|
||||
<view v-show="showControls" class="page-indicator">
|
||||
<!-- <view v-show="showControls" class="page-indicator">
|
||||
{{ currentPage }} / {{ totalPages }}
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
<!-- 上下滚动模式 -->
|
||||
@@ -99,8 +114,6 @@
|
||||
<wd-icon v-if="isLocked(index)" name="lock" size="20px" />
|
||||
</view>
|
||||
</scroll-view>
|
||||
<!-- 底部占位 -->
|
||||
<view class="setting-ooter-placeholder"></view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
|
||||
@@ -165,13 +178,11 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 底部占位 -->
|
||||
<view class="setting-ooter-placeholder"></view>
|
||||
</wd-popup>
|
||||
|
||||
<!-- 空状态 -->
|
||||
<view v-if="chapterList.length === 0 && !loading" class="empty-state">
|
||||
<text>{{ nullStatus }}</text>
|
||||
<text>{{ $t('common.data_null') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -183,6 +194,7 @@ import { useI18n } from 'vue-i18n'
|
||||
import { useBookStore } from '@/stores/book'
|
||||
import { bookApi } from '@/api/modules/book'
|
||||
import type { IChapter, IChapterContent, IReadProgress } from '@/types/book'
|
||||
import { onPageBack } from '@/utils/index'
|
||||
|
||||
const { t } = useI18n()
|
||||
const bookStore = useBookStore()
|
||||
@@ -199,7 +211,6 @@ const currentChapterIndex = ref(0)
|
||||
const currentChapterId = ref(0)
|
||||
const currentContentId = ref(0)
|
||||
const loading = ref(false)
|
||||
const nullStatus = ref('')
|
||||
|
||||
// 阅读设置
|
||||
const fontSizeLevel = ref(1)
|
||||
@@ -260,7 +271,6 @@ const currentChapterTitle = computed(() => {
|
||||
return chapter.chapter + (chapter.content ? ' - ' + chapter.content : '')
|
||||
})
|
||||
|
||||
// 生命周期
|
||||
onLoad((options: any) => {
|
||||
if (options.bookId) bookId.value = Number(options.bookId)
|
||||
if (options.isBuy) isBuy.value = options.isBuy
|
||||
@@ -290,20 +300,23 @@ onShow(() => {
|
||||
}, 300)
|
||||
} else {
|
||||
currentPage.value = 1
|
||||
calculatePages()
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
initHeights()
|
||||
calculatePages()
|
||||
})
|
||||
|
||||
onHide(() => {
|
||||
saveProgress()
|
||||
console.log('onHide')
|
||||
})
|
||||
|
||||
onBackPress(() => {
|
||||
saveProgress()
|
||||
console.log('onBackPress')
|
||||
return false
|
||||
})
|
||||
|
||||
@@ -313,7 +326,7 @@ function initHeights() {
|
||||
const windowHeight = systemInfo.windowHeight
|
||||
|
||||
// 翻页模式高度
|
||||
const math = Math.floor((windowHeight - (notchHeight.value + 130)) / lineHeight.value)
|
||||
const math = Math.floor((windowHeight - (notchHeight.value + 80)) / lineHeight.value)
|
||||
wrapHeight.value = math * lineHeight.value
|
||||
|
||||
// 滚动模式高度
|
||||
@@ -359,11 +372,8 @@ async function loadChapterList() {
|
||||
|
||||
// 默认加载第一章
|
||||
await loadChapterContent(chapterList.value[0].id, 0)
|
||||
} else {
|
||||
nullStatus.value = t('common.data_null')
|
||||
}
|
||||
} catch (error) {
|
||||
nullStatus.value = t('common.data_null')
|
||||
console.error('Failed to load chapter list:', error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
@@ -373,9 +383,7 @@ async function loadChapterList() {
|
||||
// 加载章节内容
|
||||
async function loadChapterContent(chapterId: number, index: number) {
|
||||
try {
|
||||
uni.showLoading({ title: t('global.loading') })
|
||||
const res = await bookApi.getChapterContent(chapterId)
|
||||
uni.hideLoading()
|
||||
|
||||
if (res.contentPage && res.contentPage.length > 0) {
|
||||
contentList.value = res.contentPage
|
||||
@@ -402,7 +410,6 @@ async function loadChapterContent(chapterId: number, index: number) {
|
||||
catalogVisible.value = false
|
||||
}
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
console.error('Failed to load chapter content:', error)
|
||||
}
|
||||
}
|
||||
@@ -524,6 +531,7 @@ function toggleControls() {
|
||||
function showCatalog() {
|
||||
catalogVisible.value = true
|
||||
settingsVisible.value = false
|
||||
showControls.value = false
|
||||
}
|
||||
|
||||
// 关闭目录
|
||||
@@ -534,9 +542,9 @@ function closeCatalog() {
|
||||
|
||||
// 显示设置
|
||||
function showSettings() {
|
||||
console.log('currentLanguage', currentLanguage.value)
|
||||
settingsVisible.value = true
|
||||
catalogVisible.value = false
|
||||
showControls.value = false
|
||||
}
|
||||
// 关闭设置
|
||||
function closeSettings() {
|
||||
@@ -615,21 +623,12 @@ const changeBookLanguage = (language: any) => {
|
||||
|
||||
// 保存进度
|
||||
async function saveProgress() {
|
||||
if (isBuy.value === '0') {
|
||||
try {
|
||||
await bookApi.saveReadProgress(bookId.value, currentChapterId.value, currentContentId.value)
|
||||
} catch (error) {
|
||||
console.error('Failed to save progress:', error)
|
||||
}
|
||||
try {
|
||||
await bookApi.saveReadProgress(bookId.value, currentChapterId.value, currentContentId.value)
|
||||
} catch (error) {
|
||||
console.error('Failed to save progress:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 返回
|
||||
function goBack() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/book/detail?id=' + bookId.value
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@@ -885,10 +884,5 @@ function goBack() {
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
|
||||
/* 底部占位 */
|
||||
.setting-ooter-placeholder {
|
||||
height: 55px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -181,9 +181,7 @@ async function loadComments() {
|
||||
}
|
||||
|
||||
try {
|
||||
uni.showLoading({ title: t('global.loading') })
|
||||
const res = await bookApi.getBookComments(bookId.value, page.value.current, page.value.limit)
|
||||
uni.hideLoading()
|
||||
|
||||
commentsCount.value = res.commentsCount || 0
|
||||
|
||||
@@ -194,7 +192,6 @@ async function loadComments() {
|
||||
nullText.value = t('common.data_null')
|
||||
}
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
nullText.value = t('common.data_null')
|
||||
console.error('Failed to load comments:', error)
|
||||
}
|
||||
@@ -472,7 +469,7 @@ function toggleEmoji() {
|
||||
}
|
||||
|
||||
.editor {
|
||||
border: 1rpx solid #ddd;
|
||||
border: 1px solid #ddd;
|
||||
width: 100%;
|
||||
min-height: 200rpx;
|
||||
height: 200rpx;
|
||||
|
||||
Reference in New Issue
Block a user