小说小程序前端代码仓库(小程序)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

914 lines
20 KiB

<template>
<!-- 小说详情页面 -->
<view class="novel-detail">
<!-- 顶部返回导航 -->
<uv-navbar title="小说详情" :autoBack="true" fixed placeholder titleStyle="color: #333; font-weight: 700;" :border="false">
<template #left>
<uv-icon name="arrow-left" size="46" color="#333" @click="goBack" />
</template>
</uv-navbar>
<!-- 小说基本信息 -->
<view class="novel-info">
<view class="novel-cover">
<image :src="novelData.coverUrl" mode="aspectFill"></image>
</view>
<view class="novel-basic">
<text class="title">{{ novelData.title }}</text>
<view class="author-line">
<text class="label">作者</text>
<text class="author">{{ novelData.author }}</text>
</view>
<view class="status-line">
<text class="label">完结</text>
<text class="status">{{ novelData.status }}</text>
</view>
<view class="score-line">
<text class="score">{{ novelData.score || 2814}}</text>
<text class="score-label">作者累计亲密度值</text>
</view>
</view>
</view>
<!-- 推荐票数显示 -->
<view class="recommendation-section">
<view class="rec-left">
<text class="rec-count">2814</text>
<text class="rec-label">推荐票数</text>
</view>
<view class="rec-divider"></view>
<view class="rec-right">
<button class="recommend-btn" @click="recommendNovel">
<text class="btn-icon">📑</text>
投推荐票
</button>
</view>
</view>
<!-- 阅读和收藏按钮 -->
<!-- 我的等级 -->
<view class="user-level">
<view class="level-left">
<view class="level-title">
<text class="title-icon">👑</text>
<text>我的等级</text>
</view>
<view class="level-info">
<image class="user-avatar" src="https://tse4-mm.cn.bing.net/th/id/OIP-C.iUyxJ_fxLjjX3kEBjteXWwAAAA?rs=1&pid=ImgDetMain" mode="aspectFill"></image>
<view class="user-details">
<text class="username">周海</text>
<view class="user-score">
<text class="score-value">6785452</text>
<text class="score-label">亲密值</text>
</view>
<text class="user-role">护书使者 五级</text>
</view>
</view>
</view>
<view class="level-right">
<view class="rank-btn">
<image class="rank-icon" src="https://tse4-mm.cn.bing.net/th/id/OIP-C.iUyxJ_fxLjjX3kEBjteXWwAAAA?rs=1&pid=ImgDetMain" mode="aspectFit"></image>
<text>读者榜单</text>
<text class="check-text">点击查看</text>
</view>
</view>
</view>
<!-- 小说简介 -->
<view class="novel-intro">
<view class="intro-title">
<text>简介</text>
</view>
<view class="intro-content">
<text>这游戏也太真实了吧</text>
<text>搬砖跑腿捡垃圾送快递......公司最多能让你体会到996的艰辛在这里你能体会到超级加倍的007</text>
<text>好了不废话了伟大的管理者大人嘛就去搬砖了那位大人说了只要我们努力献上自己的肝下个月他又能换一套全新的动力甲到时候候带我们开全新的地图去广阔的废土捡更多的垃圾</text>
<text>穿越到废土世界的基光发现自己解锁了游戏所系统能够从平行世界召唤名为"玩家"的生物</text>
</view>
</view>
<!-- 目录 -->
<view class="novel-catalog" @click="handleShowCatalog">
<view class="catalog-header">
<view class="catalog-title">
<text class="title-icon">📖</text>
<text>目录</text>
</view>
<view class="chapter-nav">
<text class="current-chapter">第九集 - 高去与归来</text>
<text class="nav-arrow">></text>
</view>
</view>
</view>
<!-- 目录弹窗完整内容内联 -->
<view v-if="showCatalog" class="catalog-popup-fullscreen" style="top:196px;bottom:0;height:auto;min-height:calc(100vh - 196px);">
<view class="catalog-header">
<view class="header-left" @click.stop="showCatalog = false">
<uv-icon name="arrow-down" size="46" color="#333" @click="goBack" />
</view>
<view class="header-title">目录</view>
<view class="header-right" @click.stop="orderAsc = !orderAsc">倒序</view>
</view>
<scroll-view scroll-y class="catalog-list" style="padding-bottom:0;margin-bottom:0;">
<view v-for="(item, idx) in (orderAsc ? chapterList : [...chapterList].reverse())" :key="item.id" @click="selectChapter(orderAsc ? idx : chapterList.length - 1 - idx)"
:class="['catalog-item', {active: (orderAsc ? idx : chapterList.length - 1 - idx) === currentIndex}]">
<view class="item-main">
<text class="item-title">{{ item.title }}</text>
<text v-if="item.vip" class="vip-tag">付费</text>
</view>
</view>
</scroll-view>
</view>
<!-- 书评区域 -->
<view class="comments-section">
<view class="comments-header">
<view class="header-left">
<text class="title-icon">📝</text>
<text>书评</text>
</view>
<view class="header-right">
<text @click="goToWriteReview">写书评</text>
</view>
</view>
<view class="comment-list">
<view class="comment-item">
<view class="comment-header">
<image class="avatar" src="https://tse4-mm.cn.bing.net/th/id/OIP-C.iUyxJ_fxLjjX3kEBjteXWwAAAA?rs=1&pid=ImgDetMain" mode="aspectFill"></image>
<text class="username">方香橙</text>
</view>
<view class="comment-body">
<text class="content-text">我是本书的作者方香橙,这是一本甜文爽文哒!请放心入坑,五星好评!女主又美有个性可爱,绝对不圣母,不傻白!男主身心干净深情独宠媳妇儿一个人...</text>
<view class="comment-footer">
<text class="comment-time">2024.07.09</text>
<view class="comment-likes" @click="goToCommentReply">
<text class="like-icon">💬</text>
<text class="like-count">17</text>
</view>
</view>
</view>
</view>
<view class="comment-item">
<view class="comment-header">
<image class="avatar" src="https://tse4-mm.cn.bing.net/th/id/OIP-C.iUyxJ_fxLjjX3kEBjteXWwAAAA?rs=1&pid=ImgDetMain" mode="aspectFill"></image>
<text class="username">战斗世界</text>
</view>
<view class="comment-body">
<text class="content-text">这本小说了创意了雄天霸业奇新颖深刻以白色能量为主...</text>
</view>
</view>
</view>
</view>
<!-- 底部操作栏 -->
<view class="novel-bottom">
<view class="bottom-left">
<view class="action-btn" @click="addToBookshelf">
<text class="btn-icon">📚</text>
<text>加入书架</text>
</view>
<view class="action-btn" @click="goToGiftbox">
<text class="btn-icon">🎁</text>
<text>礼物盒</text>
</view>
<view class="action-btn" @click="toggleInteractive">
<text class="btn-icon">🎯</text>
<text>互动打赏</text>
</view>
</view>
<view class="bottom-right">
<button class="read-now-btn" @click="startReading">立即阅读</button>
</view>
</view>
</view>
</template>
<script>
import catalogpopup from '@/components/novel/CatalogPopup.vue'
export default {
components: {
'uv-navbar': () => import('@/uni_modules/uv-navbar/components/uv-navbar/uv-navbar.vue'),
'uv-icon': () => import('@/uni_modules/uv-icon/components/uv-icon/uv-icon.vue'),
catalogpopup
},
data() {
return {
novelData: {
id: '1',
title: '这游戏也太真实了',
author: '大宝鉴在在',
category: '玄幻',
wordCount: '2814',
coverUrl: 'https://tse4-mm.cn.bing.net/th/id/OIP-C.iUyxJ_fxLjjX3kEBjteXWwAAAA?rs=1&pid=ImgDetMain',
introduction: '这游戏也太真实了!\n模拟,模拟,模拟,这游戏……公空居然把自己做成了游戏的NPC?这是什么新型的套路啊!好了,不要慌了,作为的管理者人员都在忙碌着,都在工作人员中,只要我们努力就自己的事,下个月他又给一套全新的剧情开始,如何将模拟的开关全新的世界,去广阔的世界去探索吧!'
},
isCollected: false,
chapterCount: 2814,
comments: [
{
username: '方寒锋',
avatar: '/static/images/user1.jpg',
content: '我是全书中年龄最大的人,这是一本很好的文章!满满心头热,只要对你"安全"文案有兴趣的,都可以不虚,不害怕,不要想太多就去尝试阅读吧!',
time: '2024-07-09'
}
],
showCatalog: false,
orderAsc: true,
currentIndex: 0,
chapterList: [
{ id: 1, title: '第一章 重回2004', vip: false },
{ id: 2, title: '第二章 陈年旧恨', vip: false },
{ id: 3, title: '第三章 再相见', vip: false },
{ id: 4, title: '第四章 李东的邀请', vip: false },
{ id: 5, title: '第五章 小气的男', vip: false },
{ id: 6, title: '第六章 先送谁?', vip: false },
{ id: 7, title: '第七章 打听行情', vip: false },
{ id: 8, title: '第八章 省城探路', vip: false },
{ id: 9, title: '第九章 订货', vip: false },
{ id: 10, title: '第十章 第一桶金', vip: true },
{ id: 11, title: '第十一章 高富帅来袭', vip: true },
{ id: 12, title: '第十二章 故学后,挥场见!', vip: true },
{ id: 13, title: '第十三章 你来我往', vip: true },
{ id: 14, title: '第十四章 你来我往', vip: true },
{ id: 15, title: '第十五章 你来我往', vip: true },
{ id: 16, title: '第十六章 你来我往', vip: true },
{ id: 17, title: '第十七章 你来我往', vip: true },
{ id: 18, title: '第十八章 你来我往', vip: true }
]
}
},
computed: {
userInfo() {
return {
avatar: '/static/images/avatar.jpg',
level: '67级达人'
}
}
},
methods: {
goBack() {
uni.navigateBack()
},
startReading() {
uni.navigateTo({
url: `/pages_order/novel/readnovels?id=${this.novelData.id}`
})
},
toggleCollect() {
this.isCollected = !this.isCollected
// TODO: 实现收藏功能
},
recommendNovel() {
if (!this.novelData.id) {
uni.showToast({
title: '无效的小说ID',
icon: 'none'
})
return
}
uni.navigateTo({
url: `/pages_order/novel/vote?id=${this.novelData.id}`
})
},
goToWriteReview() {
// 跳转到写书评页面,传递书名参数
uni.navigateTo({
url: `/pages_order/novel/Review?title=${encodeURIComponent(this.novelData.title)}`
})
},
addToBookshelf() {
// TODO: 实现加入书架功能
uni.showToast({
title: '已加入书架',
icon: 'success'
})
},
toggleInteractive() {
// 跳转到互动打赏页面
uni.navigateTo({
url: `/pages_order/novel/Tipping?id=${this.novelData.id}`
})
},
goToGiftbox() {
uni.navigateTo({ url: '/pages_order/novel/Giftbox' })
},
handleShowCatalog() {
console.log('点击目录区域');
this.showCatalog = true;
},
selectChapter(idx) {
this.currentIndex = idx
this.showCatalog = false
// TODO: 跳转到对应章节内容
},
goToCommentReply() {
uni.navigateTo({
url: '/pages_order/novel/comments'
})
}
}
}
</script>
<style lang="scss" scoped>
.novel-detail {
min-height: 100vh;
background-color: #f5f5f5;
padding-bottom: 30rpx;
}
.nav-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20rpx 30rpx;
background-color: transparent;
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 100;
}
.novel-info {
padding: 20rpx;
display: flex;
background: #fff;
}
.novel-cover {
width: 200rpx;
height: 280rpx;
margin-right: 20rpx;
}
.novel-cover image {
width: 100%;
height: 100%;
border-radius: 8rpx;
}
.novel-basic {
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.title {
font-size: 36rpx;
font-weight: bold;
margin-bottom: 16rpx;
}
.author-line, .status-line {
display: flex;
align-items: center;
margin-bottom: 12rpx;
font-size: 28rpx;
color: #666;
}
.label {
color: #999;
margin-right: 8rpx;
}
.score-line {
margin-top: 16rpx;
}
.score {
font-size: 32rpx;
color: #333;
font-weight: bold;
}
.score-label {
font-size: 24rpx;
color: #999;
margin-left: 8rpx;
}
.recommendation-section {
padding: 24rpx 32rpx;
background: #fff;
display: flex;
justify-content: space-between;
align-items: center;
position: relative;
}
.rec-left {
display: flex;
flex-direction: column;
align-items: flex-start;
margin-left: 70rpx;
}
.rec-count {
font-size: 44rpx;
font-weight: 500;
color: #333;
line-height: 1.2;
}
.rec-label {
font-size: 26rpx;
color: #999;
margin-top: 4rpx;
}
.rec-divider {
position: absolute;
right: 160rpx;
top: 20rpx;
bottom: 20rpx;
width: 2rpx;
background: #eee;
}
.rec-right {
flex-shrink: 0;
}
.recommend-btn {
background: #fff;
color: #4a90e2;
border: 2rpx solid #4a90e2;
border-radius: 40rpx;
padding: 12rpx 32rpx;
font-size: 28rpx;
display: flex;
align-items: center;
line-height: 1;
height: 64rpx;
}
.btn-icon {
margin-right: 8rpx;
font-size: 32rpx;
}
.action-buttons {
display: flex;
padding: 30rpx;
gap: 20rpx;
button {
flex: 1;
height: 80rpx;
border-radius: 40rpx;
font-size: 32rpx;
display: flex;
align-items: center;
justify-content: center;
}
.read-btn {
background-color: #4a90e2;
color: #fff;
}
.collect-btn {
background-color: #f0f0f0;
color: #666;
}
}
.user-level {
margin: 20rpx 30rpx;
background-color: #fff;
border-radius: 12rpx;
padding: 24rpx 32rpx;
display: flex;
justify-content: space-between;
align-items: stretch;
}
.level-left {
flex: 1;
}
.level-title {
display: flex;
align-items: center;
gap: 8rpx;
margin-bottom: 20rpx;
margin-left: 20rpx;
.title-icon {
font-size: 36rpx;
color: #FFB800;
}
text {
font-size: 32rpx;
font-weight: 500;
color: #333;
}
}
.level-info {
display: flex;
align-items: flex-start;
gap: 20rpx;
}
.user-avatar {
width: 80rpx;
height: 80rpx;
border-radius: 50%;
border: 2rpx solid #f0f0f0;
}
.user-details {
display: flex;
flex-direction: column;
gap: 8rpx;
}
.username {
font-size: 28rpx;
color: #333;
font-weight: 500;
}
.user-score {
display: flex;
align-items: center;
gap: 8rpx;
.score-value {
font-size: 28rpx;
color: #333;
}
.score-label {
font-size: 24rpx;
color: #999;
}
}
.user-role {
font-size: 24rpx;
color: #666;
background: #f5f5f5;
padding: 4rpx 12rpx;
border-radius: 4rpx;
display: inline-block;
}
.level-right {
display: flex;
align-items: center;
}
.rank-btn {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 0 20rpx;
.rank-icon {
width: 200rpx;
height: 60rpx;
margin-bottom: 8rpx;
}
text {
font-size: 26rpx;
color: #333;
line-height: 1.4;
}
.check-text {
font-size: 22rpx;
color: #999;
}
}
.novel-intro {
margin: 20rpx 30rpx;
background-color: #fff;
border-radius: 12rpx;
padding: 24rpx;
}
.intro-title {
font-size: 32rpx;
font-weight: 500;
color: #333;
margin-bottom: 16rpx;
}
.intro-content {
font-size: 28rpx;
color: #666;
line-height: 1.6;
display: flex;
flex-direction: column;
gap: 16rpx;
text {
display: block;
}
}
.comments-section {
margin: 20rpx 30rpx;
background-color: #fff;
border-radius: 12rpx;
padding: 24rpx;
}
.comments-header {
display: flex;
align-items: center;
margin-bottom: 24rpx;
border-bottom: 2rpx solid #f5f5f5;
padding-bottom: 24rpx;
justify-content: flex-start;
}
.header-left {
display: flex;
align-items: center;
gap: 8rpx;
.title-icon {
font-size: 32rpx;
}
text {
display: flex;
align-items: center;
font-size: 32rpx;
font-weight: 500;
color: #333;
white-space: nowrap;
}
}
.header-right {
margin-left: auto;
}
.comment-list {
display: flex;
flex-direction: column;
gap: 32rpx;
}
.comment-item {
display: flex;
flex-direction: column;
gap: 16rpx;
}
.comment-header {
display: flex;
align-items: center;
gap: 12rpx;
}
.avatar {
width: 64rpx;
height: 64rpx;
border-radius: 50%;
}
.username {
font-size: 28rpx;
color: #333;
font-weight: 500;
}
.comment-body {
padding-left: 76rpx;
}
.content-text {
font-size: 28rpx;
color: #333;
line-height: 1.6;
}
.comment-footer {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 16rpx;
}
.comment-time {
font-size: 24rpx;
color: #999;
}
.comment-likes {
display: flex;
align-items: center;
gap: 4rpx;
}
.like-icon {
font-size: 24rpx;
color: #999;
}
.like-count {
font-size: 24rpx;
color: #999;
}
.novel-catalog {
margin: 20rpx 30rpx;
background-color: #fff;
border-radius: 12rpx;
padding: 24rpx;
}
.catalog-header {
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 2rpx solid #f5f5f5;
padding-bottom: 24rpx;
}
.catalog-title {
display: flex;
align-items: center;
gap: 8rpx;
.title-icon {
font-size: 32rpx;
}
text {
font-size: 32rpx;
font-weight: 500;
color: #333;
}
}
.chapter-nav {
display: flex;
align-items: center;
gap: 8rpx;
.current-chapter {
font-size: 28rpx;
color: #666;
}
.nav-arrow {
font-size: 28rpx;
color: #999;
}
}
.novel-bottom {
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 100rpx;
background: #fff;
display: flex;
align-items: center;
padding: 0 30rpx;
box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
}
.bottom-left {
flex: 1;
display: flex;
gap: 40rpx;
}
.action-btn {
display: flex;
flex-direction: column;
align-items: center;
gap: 4rpx;
.btn-icon {
font-size: 40rpx;
line-height: 1;
}
text {
font-size: 24rpx;
color: #666;
}
}
.bottom-right {
flex-shrink: 0;
}
.read-now-btn {
background: #1a237e;
color: #fff;
font-size: 32rpx;
height: 80rpx;
line-height: 80rpx;
padding: 0 60rpx;
border-radius: 40rpx;
border: none;
}
.catalog-popup-fullscreen {
position: fixed;
left: 0;
top: 196px;
width: 100vw;
background: #fff;
z-index: 9999;
border-top-left-radius: 32rpx;
border-top-right-radius: 32rpx;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
display: flex;
flex-direction: column;
box-shadow: 0 8rpx 48rpx rgba(0,0,0,0.18);
overflow: hidden;
min-height: calc(100vh - 196px);
}
.catalog-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 24rpx;
height: 96rpx;
border-bottom: 1px solid #eee;
position: sticky;
top: 0;
background: #fff;
z-index: 2;
}
.header-left {
width: 60rpx;
display: flex;
align-items: center;
justify-content: flex-start;
}
.header-title {
flex: 1;
text-align: center;
font-size: 32rpx;
font-weight: bold;
color: #222;
}
.header-right {
color: #223a7a;
font-size: 28rpx;
font-weight: 500;
min-width: 80rpx;
text-align: right;
}
.catalog-list {
flex: 1;
overflow: auto;
padding-bottom: 40rpx;
}
.catalog-item {
padding: 0 32rpx;
min-height: 80rpx;
display: flex;
flex-direction: column;
justify-content: center;
border-bottom: 1px solid #f5f5f5;
background: #fff;
color: #222;
font-size: 30rpx;
position: relative;
}
.catalog-item.active {
color: #ff5a5f;
background: #fff7f7;
}
.item-main {
display: flex;
align-items: center;
gap: 16rpx;
}
.item-title {
font-size: 30rpx;
}
.vip-tag {
background: #ffe1b2;
color: #ff9900;
border-radius: 20rpx;
font-size: 24rpx;
padding: 2rpx 18rpx;
margin-left: 16rpx;
}
</style>