├── php-api/ # 改造后的PHP接口层 ├── java-ad-service/ # 若依框架微服务(广告+VIP+分账) ├── uniapp-reader/ # UniApp前端项目 │ ├── pages/ # 各端页面 │ └──
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <template>
  2. <scroll-view scroll-y class="detail-page">
  3. <!-- 封面区域 -->
  4. <view class="cover-section">
  5. <image :src="novel.cover" class="cover-image" />
  6. <view class="cover-overlay">
  7. <text class="title">{{ novel.title }}</text>
  8. <text class="author">{{ novel.author }}</text>
  9. <!-- VIP专享标识 -->
  10. <view v-if="isVIPOnly" class="vip-tag">
  11. <uni-icons type="crown-filled" color="#ffc53d" size="16"></uni-icons>
  12. <text>VIP专享</text>
  13. </view>
  14. </view>
  15. </view>
  16. <!-- 基本信息 -->
  17. <view class="info-card">
  18. <view class="info-item">
  19. <uni-icons type="flag" size="18" color="#666"></uni-icons>
  20. <text>状态:{{ novel.status }}</text>
  21. </view>
  22. <view class="info-item">
  23. <uni-icons type="list" size="18" color="#666"></uni-icons>
  24. <text>分类:{{ novel.category }}</text>
  25. </view>
  26. <view class="info-item">
  27. <uni-icons type="eye" size="18" color="#666"></uni-icons>
  28. <text>人气:{{ formatCount(novel.views) }}</text>
  29. </view>
  30. <view class="info-item">
  31. <uni-icons type="calendar" size="18" color="#666"></uni-icons>
  32. <text>更新:{{ novel.updateTime }}</text>
  33. </view>
  34. </view>
  35. <!-- 操作按钮 -->
  36. <view class="action-buttons">
  37. <button class="read-btn" @click="startReading">
  38. {{ lastChapter ? '继续阅读' : '开始阅读' }}
  39. </button>
  40. <button class="add-btn" @click="addToBookshelf">
  41. <uni-icons :type="inBookshelf ? 'star-filled' : 'star'" color="#ffc53d" size="18"></uni-icons>
  42. {{ inBookshelf ? '已在书架' : '加入书架' }}
  43. </button>
  44. </view>
  45. <!-- 简介 -->
  46. <view class="description">
  47. <text class="section-title">内容简介</text>
  48. <text class="content">{{ novel.description }}</text>
  49. </view>
  50. <!-- 章节列表 -->
  51. <view class="chapter-list">
  52. <text class="section-title">目录</text>
  53. <view class="chapter-header">
  54. <text>共{{ novel.chapterCount }}章</text>
  55. <text @click="reverseOrder">{{ sortDesc ? '正序' : '倒序' }}</text>
  56. </view>
  57. <view class="chapter-item"
  58. v-for="chapter in sortedChapters"
  59. :key="chapter.id"
  60. @click="readChapter(chapter)"
  61. >
  62. <text class="chapter-title">{{ chapter.title }}</text>
  63. <view class="chapter-meta">
  64. <text>{{ formatDate(chapter.updateTime) }}</text>
  65. <!-- VIP章节标识 -->
  66. <view v-if="chapter.vip" class="chapter-vip">
  67. <uni-icons type="crown" size="14" color="#ffc53d"></uni-icons>
  68. <text>VIP</text>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. </scroll-view>
  74. </template>
  75. <script setup>
  76. import { ref, computed, onMounted } from 'vue'
  77. import { useUserStore } from '@/stores/user'
  78. import { useVipStore } from '@/stores/vip'
  79. import { request } from '@/utils/request'
  80. const props = defineProps({
  81. novelId: {
  82. type: Number,
  83. required: true
  84. }
  85. })
  86. const novel = ref({
  87. id: 1,
  88. title: '哎呀电子科技传奇',
  89. author: '哎呀作者',
  90. cover: '/static/covers/novel1.jpg',
  91. status: '连载中',
  92. category: '都市异能',
  93. views: 12500,
  94. updateTime: '2025-06-10 12:30',
  95. description: '这是一个关于哎呀电子科技崛起的故事,讲述了一群程序员如何通过技术创新改变世界...',
  96. chapterCount: 120,
  97. vipOnly: true // 整本VIP专享
  98. })
  99. const chapters = ref([
  100. { id: 1, title: '第1章 命运的转折', updateTime: '2025-05-01', vip: false },
  101. { id: 2, title: '第2章 初遇哎呀科技', updateTime: '2025-05-03', vip: false },
  102. // ...中间章节
  103. { id: 100, title: '第100章 突破性进展', updateTime: '2025-06-05', vip: true },
  104. { id: 101, title: '第101章 VIP专享章节', updateTime: '2025-06-10', vip: true }
  105. ])
  106. const sortDesc = ref(false)
  107. const lastChapter = ref(null)
  108. const inBookshelf = ref(false)
  109. const userStore = useUserStore()
  110. const vipStore = useVipStore()
  111. // 是否是VIP专享书籍
  112. const isVIPOnly = computed(() => {
  113. return novel.value.vipOnly
  114. })
  115. // 排序后的章节列表
  116. const sortedChapters = computed(() => {
  117. return sortDesc.value
  118. ? [...chapters.value].reverse()
  119. : chapters.value
  120. })
  121. // 格式化数字
  122. const formatCount = (num) => {
  123. if (num > 10000) return (num / 10000).toFixed(1) + '万'
  124. return num
  125. }
  126. // 格式化日期
  127. const formatDate = (dateStr) => {
  128. return dateStr.slice(5) // 显示月-日
  129. }
  130. // 开始阅读
  131. const startReading = () => {
  132. if (isVIPOnly.value && !vipStore.isVIP) {
  133. uni.showModal({
  134. title: 'VIP专享内容',
  135. content: '此书籍为VIP专享,开通会员即可无限制阅读',
  136. confirmText: '开通会员',
  137. success: (res) => {
  138. if (res.confirm) {
  139. uni.navigateTo({ url: '/pages/vip/index' })
  140. }
  141. }
  142. })
  143. return
  144. }
  145. const chapterId = lastChapter.value?.id || chapters.value[0].id
  146. readChapter({ id: chapterId })
  147. }
  148. // 阅读章节
  149. const readChapter = (chapter) => {
  150. if (chapter.vip && !vipStore.isVIP) {
  151. uni.showModal({
  152. title: 'VIP章节',
  153. content: '此章节为VIP专享,开通会员即可阅读',
  154. confirmText: '开通会员',
  155. success: (res) => {
  156. if (res.confirm) {
  157. uni.navigateTo({ url: '/pages/vip/index' })
  158. }
  159. }
  160. })
  161. return
  162. }
  163. uni.navigateTo({
  164. url: `/pages/reader/index?novelId=${novel.value.id}&chapterId=${chapter.id}`
  165. })
  166. }
  167. // 加入书架
  168. const addToBookshelf = () => {
  169. inBookshelf.value = !inBookshelf.value
  170. uni.showToast({
  171. title: inBookshelf.value ? '已加入书架' : '已移除书架',
  172. icon: 'none'
  173. })
  174. }
  175. // 切换排序
  176. const reverseOrder = () => {
  177. sortDesc.value = !sortDesc.value
  178. }
  179. // 加载数据
  180. onMounted(async () => {
  181. // 获取小说详情
  182. const res = await request({
  183. url: `/novel/${props.novelId}`,
  184. method: 'GET'
  185. })
  186. novel.value = res.data.novel
  187. chapters.value = res.data.chapters
  188. // 获取最后阅读章节
  189. if (userStore.userId) {
  190. const progressRes = await request({
  191. url: `/reading/progress?novelId=${props.novelId}`,
  192. method: 'GET',
  193. headers: {
  194. 'Authorization': `Bearer ${uni.getStorageSync('token')}`
  195. }
  196. })
  197. lastChapter.value = progressRes.data.lastChapter
  198. }
  199. })
  200. </script>
  201. <style scoped>
  202. .detail-page {
  203. height: 100vh;
  204. background-color: var(--bg-color);
  205. padding-bottom: 50px;
  206. }
  207. .cover-section {
  208. position: relative;
  209. height: 300px;
  210. }
  211. .cover-image {
  212. width: 100%;
  213. height: 100%;
  214. object-fit: cover;
  215. }
  216. .cover-overlay {
  217. position: absolute;
  218. bottom: 0;
  219. left: 0;
  220. right: 0;
  221. background: linear-gradient(transparent, rgba(0,0,0,0.7));
  222. padding: 20px;
  223. color: white;
  224. }
  225. .title {
  226. font-size: 24px;
  227. font-weight: bold;
  228. display: block;
  229. margin-bottom: 5px;
  230. }
  231. .author {
  232. font-size: 16px;
  233. opacity: 0.8;
  234. display: block;
  235. }
  236. .vip-tag {
  237. position: absolute;
  238. top: 20px;
  239. right: 20px;
  240. background: rgba(0,0,0,0.6);
  241. border: 1px solid #ffc53d;
  242. border-radius: 15px;
  243. padding: 5px 10px;
  244. display: flex;
  245. align-items: center;
  246. font-size: 14px;
  247. }
  248. .vip-tag text {
  249. margin-left: 5px;
  250. }
  251. .info-card {
  252. background-color: var(--card-bg);
  253. border-radius: 12px;
  254. padding: 15px;
  255. margin: 15px;
  256. box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  257. }
  258. .info-item {
  259. display: flex;
  260. align-items: center;
  261. margin-bottom: 10px;
  262. font-size: 14px;
  263. }
  264. .info-item text {
  265. margin-left: 8px;
  266. }
  267. .action-buttons {
  268. display: flex;
  269. padding: 0 15px;
  270. margin: 20px 0;
  271. }
  272. .read-btn {
  273. flex: 2;
  274. background: linear-gradient(to right, #2a5caa, #1a3353);
  275. color: white;
  276. border: none;
  277. border-radius: 24px;
  278. height: 44px;
  279. line-height: 44px;
  280. font-weight: bold;
  281. margin-right: 10px;
  282. }
  283. .add-btn {
  284. flex: 1;
  285. background-color: var(--card-bg);
  286. border: 1px solid var(--primary-color);
  287. color: var(--primary-color);
  288. border-radius: 24px;
  289. height: 44px;
  290. line-height: 44px;
  291. display: flex;
  292. justify-content: center;
  293. align-items: center;
  294. }
  295. .description {
  296. background-color: var(--card-bg);
  297. border-radius: 12px;
  298. padding: 15px;
  299. margin: 15px;
  300. }
  301. .section-title {
  302. font-size: 18px;
  303. font-weight: bold;
  304. display: block;
  305. margin-bottom: 10px;
  306. }
  307. .content {
  308. font-size: 14px;
  309. line-height: 1.8;
  310. color: var(--text-color);
  311. }
  312. .chapter-list {
  313. background-color: var(--card-bg);
  314. border-radius: 12px;
  315. padding: 15px;
  316. margin: 15px;
  317. }
  318. .chapter-header {
  319. display: flex;
  320. justify-content: space-between;
  321. font-size: 14px;
  322. color: #666;
  323. margin-bottom: 10px;
  324. padding-bottom: 10px;
  325. border-bottom: 1px solid #eee;
  326. }
  327. .chapter-item {
  328. padding: 12px 0;
  329. border-bottom: 1px solid #f5f5f5;
  330. }
  331. .chapter-title {
  332. font-size: 16px;
  333. display: block;
  334. margin-bottom: 5px;
  335. }
  336. .chapter-meta {
  337. display: flex;
  338. justify-content: space-between;
  339. font-size: 12px;
  340. color: #999;
  341. }
  342. .chapter-vip {
  343. display: flex;
  344. align-items: center;
  345. color: #ffc53d;
  346. }
  347. .chapter-vip text {
  348. margin-left: 3px;
  349. }
  350. </style>