修复:内测问题修改
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
// 播放章节
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user