修复:内测问题修改

This commit is contained in:
2025-12-03 14:10:27 +08:00
parent 35e27753b8
commit 677fe7436e
19 changed files with 172 additions and 163 deletions

View File

@@ -79,15 +79,15 @@
<!-- 底部操作栏 -->
<view class="action-bar">
<template v-if="bookInfo.isBuy">
<template v-if="bookInfo.isBuy || hasVip">
<view class="action-btn read" @click="goToReader">
<text>{{ $t('bookDetails.startReading') }}</text>
</view>
<view class="action-btn purchased">
<!-- <view class="action-btn purchased">
<wd-button disabled custom-class="purchased-btn">
{{ $t('bookDetails.buttonText2') }}
</wd-button>
</view>
</view> -->
<view class="action-btn listen" @click="goToListen">
<text>{{ $t('bookDetails.startListening') }}</text>
</view>
@@ -120,19 +120,23 @@
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
import { onLoad, onShow } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import { t } from '@/utils/i18n'
import { bookApi } from '@/api/modules/book'
import { useUserStore } from '@/stores/user'
import type { IBookDetail, IBook, IComment } from '@/types/book'
import type { IGoods } from '@/types/order'
import GoodsSelector from '@/components/order/GoodsSelector.vue'
import CommentList from '@/components/book/CommentList.vue'
const { t } = useI18n()
const userStore = useUserStore()
// 路由参数
const bookId = ref(0)
const pageFrom = ref('')
// 会员状态
const hasVip = computed(() => userStore.userInfo?.userEbookVip?.length > 0 || false)
// 数据状态
const bookInfo = ref<IBookDetail>({
id: 0,

View File

@@ -172,10 +172,11 @@
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { ref, onMounted, computed } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { homeApi } from '@/api/modules/book_home'
import { getNotchHeight } from '@/utils/system'
import { useUserStore } from '@/stores/user'
import BookPrice from '@/components/book/BookPrice.vue'
import type {
IBook,
@@ -184,6 +185,8 @@ import type {
IVipInfo
} from '@/types/book'
const userStore = useUserStore()
// 状态定义
const showMyBooks = ref(false)
const showActivity = ref(false)
@@ -208,17 +211,7 @@ const currentLevel1Index = ref(0)
const currentLevel2Index = ref(0)
// VIP信息
const vipInfo = ref<IVipInfo | null>(null)
/**
* 获取VIP信息
*/
const getVipInfo = async () => {
const res = await homeApi.getVipInfo()
if (res.vipInfo) {
vipInfo.value = res.vipInfo
}
}
const vipInfo = computed(() => userStore.userInfo?.userEbookVip?.[0] || null)
/**
* 获取我的书单
@@ -388,7 +381,6 @@ onMounted(() => {
*/
onShow(() => {
// 刷新数据
getVipInfo()
getMyBooks()
getRecommendBooks()
getActivityLabels()

View File

@@ -16,7 +16,7 @@
<text class="author">{{ $t('bookDetails.authorName') }}{{ bookInfo.author?.authorName }}</text>
</view>
<wd-button
v-if="!bookInfo.isBuy"
v-if="!bookInfo.isBuy && !hasVip"
type="primary"
size="small"
@click="purchaseVisible = true"
@@ -63,18 +63,22 @@
<script setup lang="ts">
import { ref, computed } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import { t } from '@/utils/i18n'
import { bookApi } from '@/api/modules/book'
import { useUserStore } from '@/stores/user'
import type { IBookDetail, IChapter } from '@/types/book'
import type { IGoods } from '@/types/order'
import GoodsSelector from '@/components/order/GoodsSelector.vue'
const { t } = useI18n()
const userStore = useUserStore()
// 路由参数
const bookId = ref(0)
const fromIndex = ref(-1)
// 会员状态
const hasVip = computed(() => userStore.userInfo?.userEbookVip?.length > 0 || false)
// 数据状态
const bookInfo = ref<IBookDetail>({
id: 0,
@@ -163,7 +167,7 @@ async function loadChapterList() {
// 判断章节是否锁定
function isLocked(index: number): boolean {
return !bookInfo.value.isBuy && index + 1 > bookInfo.value.freeChapterCount
return !bookInfo.value.isBuy && index + 1 > bookInfo.value.freeChapterCount && !hasVip.value
}
// 播放章节

View File

@@ -80,7 +80,8 @@
:class="{ 'chapter-item-active': currentChapterIndex === index }"
@click="selectChapter(index)"
>
<text class="chapter-title">{{ chapter.chapter }}</text>
<text class="chapter-title" :class="{ locked: isLocked(index) }">{{ chapter.chapter }}</text>
<wd-icon v-if="isLocked(index)" name="lock-on" size="20px" />
</view>
</scroll-view>
</view>
@@ -92,10 +93,15 @@
import { ref, computed, onMounted, onUnmounted } from 'vue'
import { onLoad, onHide, onUnload } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import { useUserStore } from '@/stores/user'
import { bookApi } from '@/api/modules/book'
import type { IBookDetail, IChapter } from '@/types/book'
const { t } = useI18n()
const userStore = useUserStore()
// 会员状态
const hasVip = computed(() => userStore.userInfo?.userEbookVip?.length > 0 || false)
// 路由参数
const bookId = ref(0)
@@ -284,6 +290,11 @@ async function loadChapterList() {
}
}
// 判断章节是否锁定
function isLocked(index: number): boolean {
return !bookInfo.value.isBuy && index + 1 > bookInfo.value.freeChapterCount && !hasVip.value
}
// 加载章节内容(带音频时间点)
async function loadChapterContent(chapterId: number) {
try {
@@ -375,7 +386,7 @@ function togglePlay() {
// 上一章
async function prevChapter() {
if (currentChapterIndex.value > 0) {
if (currentChapterIndex.value > 0 && !isLocked(currentChapterIndex.value - 1)) {
currentChapterIndex.value--
await loadChapterContent(chapterList.value[currentChapterIndex.value].id)
playChapter(chapterList.value[currentChapterIndex.value])
@@ -390,19 +401,23 @@ async function prevChapter() {
// 下一章
async function nextChapter() {
// 检查是否锁定
if (isBuy.value === '1' && currentChapterIndex.value + 1 >= count.value) {
uni.showModal({
title: t('common.limit_title'),
content: t('book.afterPurchase'),
confirmText: t('common.confirm_text'),
success: (res) => {
if (res.confirm) {
uni.navigateTo({
url: `/pages/book/order?id=${bookId.value}`
})
}
}
if (isLocked(currentChapterIndex.value + 1)) {
uni.showToast({
title: t('book.afterPurchase'),
icon: 'none'
})
// uni.showModal({
// title: t('common.limit_title'),
// content: t('book.afterPurchase'),
// confirmText: t('common.confirm_text'),
// success: (res) => {
// if (res.confirm) {
// uni.navigateTo({
// url: `/pages/book/order?id=${bookId.value}`
// })
// }
// }
// })
return
}
@@ -491,7 +506,7 @@ async function selectChapter(index: number) {
}
// 检查是否锁定
if (isBuy.value === '1' && index >= count.value) {
if (isLocked(index)) {
uni.showToast({
title: t('book.afterPurchase'),
icon: 'none'
@@ -698,6 +713,10 @@ function formatTime(seconds: number): string {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
&.locked {
color: #999;
}
}
.chapter-item-active .chapter-title {

View File

@@ -102,6 +102,7 @@
<text class="popup-title">{{ $t('book.zjContents') }}</text>
<scroll-view scroll-y class="chapter-list">
<view
v-if="chapterList.length > 0"
v-for="(chapter, index) in chapterList"
:key="chapter.id"
class="chapter-item"
@@ -111,8 +112,9 @@
<text class="chapter-text" :class="{ locked: isLocked(index) }">
{{ chapter.chapter }}{{ chapter.content ? ' - ' + chapter.content : '' }}
</text>
<wd-icon v-if="isLocked(index)" name="lock-on" size="20px" />
<wd-icon v-if="isLocked(index) && !hasVip" name="lock-on" size="20px" />
</view>
<wd-status-tip v-else image="content" :tip="$t('global.dataNull')" />
</scroll-view>
</view>
</wd-popup>
@@ -191,6 +193,7 @@
import { ref, computed, onMounted } from 'vue'
import { onLoad, onShow, onHide, onBackPress } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import { useUserStore } from '@/stores/user'
import { useBookStore } from '@/stores/book'
import { bookApi } from '@/api/modules/book'
import type { IChapter, IChapterContent, IReadProgress } from '@/types/book'
@@ -198,6 +201,10 @@ import { onPageBack } from '@/utils/index'
const { t } = useI18n()
const bookStore = useBookStore()
const userStore = useUserStore()
// 会员状态
const hasVip = computed(() => userStore.userInfo?.userEbookVip?.length > 0 || false)
// 路由参数
const bookId = ref(0)
@@ -430,7 +437,7 @@ async function switchChapter(chapter: IChapter, index: number) {
// 判断章节是否锁定
function isLocked(index: number): boolean {
return !isBuy.value && index + 1 > count.value
return !isBuy.value && index + 1 > count.value && !hasVip.value
}
// 判断是否是图片
@@ -604,10 +611,9 @@ function changeReadMode(mode: 'scroll' | 'page') {
// 语言配置
const bookLanguages = ref([])
const currentLanguage = ref('')
const currentLanguage = ref('中文')
onMounted(() => {
currentLanguage.value = uni.getStorageSync('currentBookLanguage') || '中文'
console.log('currentLanguage', currentLanguage.value)
})
const getBookLanguages = async () => {
const res = await bookApi.getBookLanguages(bookId.value)
@@ -658,7 +664,7 @@ async function saveProgress() {
position: fixed;
left: 0;
right: 0;
z-index: 999;
z-index: 90;
background: inherit;
display: flex;
align-items: center;