小说小程序前端代码仓库(小程序)
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.

736 lines
16 KiB

  1. <template>
  2. <!-- 小说详情页面 -->
  3. <view class="novel-detail">
  4. <navbar title="小说详情" leftClick @leftClick="$utils.navigateBack" />
  5. <!-- 小说基本信息 -->
  6. <view class="novel-info">
  7. <view class="novel-cover">
  8. <image :src="novelData.coverUrl" mode="aspectFill"></image>
  9. </view>
  10. <view class="novel-basic">
  11. <text class="title">{{ novelData.title }}</text>
  12. <view class="author-line">
  13. <text class="label">作者</text>
  14. <text class="author">{{ novelData.author }}</text>
  15. </view>
  16. <view class="status-line">
  17. <text class="label">完结</text>
  18. <text class="status">{{ novelData.status }}</text>
  19. </view>
  20. <view class="score-line">
  21. <text class="score">{{ novelData.score || 2814}}</text>
  22. <text class="score-label">作者累计亲密度值</text>
  23. </view>
  24. </view>
  25. </view>
  26. <!-- 推荐票数显示 -->
  27. <view class="recommendation-section">
  28. <view class="rec-left">
  29. <text class="rec-count">2814</text>
  30. <text class="rec-label">推荐票数</text>
  31. </view>
  32. <view class="rec-divider"></view>
  33. <view class="rec-right">
  34. <button class="recommend-btn" @click="$refs.novelVotePopup.open()">
  35. <text class="btn-icon">📑</text>
  36. 投推荐票
  37. </button>
  38. </view>
  39. </view>
  40. <!-- 阅读和收藏按钮 -->
  41. <!-- 我的等级 -->
  42. <view class="user-level">
  43. <view class="level-left">
  44. <view class="level-title">
  45. <!-- <text class="title-icon">👑</text> -->
  46. <image style="width: 30rpx;height: 30rpx;" src="/pages_order/static/book/level.png"
  47. mode="aspectFill"></image>
  48. <text>我的等级</text>
  49. </view>
  50. <view class="level-info">
  51. <image class="user-avatar"
  52. src="/pages_order/static/book/dj.png"
  53. mode="aspectFill"></image>
  54. <view class="user-details">
  55. <text class="username">
  56. <image
  57. src="https://tse4-mm.cn.bing.net/th/id/OIP-C.iUyxJ_fxLjjX3kEBjteXWwAAAA?rs=1&pid=ImgDetMain"
  58. mode="aspectFill"></image>
  59. <view class="name">
  60. 周海
  61. </view>
  62. </text>
  63. <view class="user-score">
  64. <text class="score-value">6785452</text>
  65. <text class="score-label">亲密值</text>
  66. </view>
  67. <text class="user-role">护书使者 五级</text>
  68. </view>
  69. </view>
  70. </view>
  71. <view class="level-right">
  72. <view class="rank-btn">
  73. <image class="rank-icon" src="/pages_order/static/book/bd.png" mode="aspectFit"></image>
  74. <text class="check-text">点击查看</text>
  75. </view>
  76. </view>
  77. </view>
  78. <!-- 小说简介 -->
  79. <view class="novel-intro">
  80. <view class="intro-title">
  81. <text>简介</text>
  82. </view>
  83. <view class="intro-content">
  84. <text>这游戏也太真实了吧</text>
  85. <text>搬砖跑腿捡垃圾送快递......公司最多能让你体会到996的艰辛在这里你能体会到超级加倍的007</text>
  86. <text>好了不废话了伟大的管理者大人嘛就去搬砖了那位大人说了只要我们努力献上自己的肝下个月他又能换一套全新的动力甲到时候候带我们开全新的地图去广阔的废土捡更多的垃圾</text>
  87. <text>穿越到废土世界的基光发现自己解锁了游戏所系统能够从平行世界召唤名为"玩家"的生物</text>
  88. </view>
  89. </view>
  90. <!-- 目录 -->
  91. <view class="novel-catalog" @click="$refs.chapterPopup.open()">
  92. <view class="catalog-header">
  93. <view class="catalog-title">
  94. <text class="title-icon">📖</text>
  95. <text>目录</text>
  96. </view>
  97. <view class="chapter-nav">
  98. <text class="current-chapter">第九集 - 高去与归来</text>
  99. <text class="nav-arrow">></text>
  100. </view>
  101. </view>
  102. </view>
  103. <!-- 目录弹窗完整内容内联 -->
  104. <!-- 书评区域 -->
  105. <view class="comments-section">
  106. <view class="comments-header">
  107. <view class="header-left">
  108. <text class="title-icon">📝</text>
  109. <text>书评</text>
  110. </view>
  111. <view class="header-right">
  112. <text @click="goToWriteReview">写书评</text>
  113. </view>
  114. </view>
  115. <view class="comment-list">
  116. <commentItem v-for="(item, index) in 10" :key="index" />
  117. </view>
  118. </view>
  119. <!-- 底部操作栏 -->
  120. <view class="novel-bottom">
  121. <view class="bottom-left">
  122. <view class="action-btn" @click="addToBookshelf">
  123. <text class="btn-icon">📚</text>
  124. <text>加入书架</text>
  125. </view>
  126. <view class="action-btn" @click="goToGiftbox">
  127. <text class="btn-icon">🎁</text>
  128. <text>礼物盒</text>
  129. </view>
  130. <view class="action-btn" @click="toggleInteractive">
  131. <text class="btn-icon">🎯</text>
  132. <text>互动打赏</text>
  133. </view>
  134. </view>
  135. <view class="bottom-right">
  136. <button class="read-now-btn" @click="startReading">立即阅读</button>
  137. </view>
  138. </view>
  139. <novelVotePopup ref="novelVotePopup"/>
  140. <chapterPopup ref="chapterPopup" />
  141. </view>
  142. </template>
  143. <script>
  144. import catalogpopup from '@/components/novel/CatalogPopup.vue'
  145. import chapterPopup from '../components/novel/chapterPopup.vue'
  146. import commentItem from '../components/comment/commentItem.vue'
  147. import novelVotePopup from '../components/novel/novelVotePopup.vue'
  148. export default {
  149. components: {
  150. catalogpopup,
  151. chapterPopup,
  152. commentItem,
  153. novelVotePopup,
  154. },
  155. data() {
  156. return {
  157. novelData: {
  158. id: '1',
  159. title: '这游戏也太真实了',
  160. author: '大宝鉴在在',
  161. category: '玄幻',
  162. wordCount: '2814',
  163. coverUrl: 'https://tse4-mm.cn.bing.net/th/id/OIP-C.iUyxJ_fxLjjX3kEBjteXWwAAAA?rs=1&pid=ImgDetMain',
  164. introduction: '这游戏也太真实了!\n模拟,模拟,模拟,这游戏……公空居然把自己做成了游戏的NPC?这是什么新型的套路啊!好了,不要慌了,作为的管理者人员都在忙碌着,都在工作人员中,只要我们努力就自己的事,下个月他又给一套全新的剧情开始,如何将模拟的开关全新的世界,去广阔的世界去探索吧!'
  165. },
  166. isCollected: false,
  167. comments: [{
  168. username: '方寒锋',
  169. avatar: '/static/images/user1.jpg',
  170. content: '我是全书中年龄最大的人,这是一本很好的文章!满满心头热,只要对你"安全"文案有兴趣的,都可以不虚,不害怕,不要想太多就去尝试阅读吧!',
  171. time: '2024-07-09'
  172. }],
  173. currentIndex: 0,
  174. }
  175. },
  176. computed: {
  177. userInfo() {
  178. return {
  179. avatar: '/static/images/avatar.jpg',
  180. level: '67级达人'
  181. }
  182. }
  183. },
  184. methods: {
  185. goBack() {
  186. uni.navigateBack()
  187. },
  188. startReading() {
  189. uni.navigateTo({
  190. url: `/pages_order/novel/readnovels?id=${this.novelData.id}`
  191. })
  192. },
  193. toggleCollect() {
  194. this.isCollected = !this.isCollected
  195. // TODO: 实现收藏功能
  196. },
  197. recommendNovel() {
  198. if (!this.novelData.id) {
  199. uni.showToast({
  200. title: '无效的小说ID',
  201. icon: 'none'
  202. })
  203. return
  204. }
  205. uni.navigateTo({
  206. url: `/pages_order/novel/vote?id=${this.novelData.id}`
  207. })
  208. },
  209. goToWriteReview() {
  210. // 跳转到写书评页面,传递书名参数
  211. uni.navigateTo({
  212. url: `/pages_order/novel/Review?title=${encodeURIComponent(this.novelData.title)}`
  213. })
  214. },
  215. addToBookshelf() {
  216. // TODO: 实现加入书架功能
  217. uni.showToast({
  218. title: '已加入书架',
  219. icon: 'success'
  220. })
  221. },
  222. toggleInteractive() {
  223. // 跳转到互动打赏页面
  224. uni.navigateTo({
  225. url: `/pages_order/novel/Tipping?id=${this.novelData.id}`
  226. })
  227. },
  228. goToGiftbox() {
  229. uni.navigateTo({
  230. url: '/pages_order/novel/Giftbox'
  231. })
  232. },
  233. handleShowCatalog() {
  234. console.log('点击目录区域');
  235. this.showCatalog = true;
  236. },
  237. selectChapter(idx) {
  238. this.currentIndex = idx
  239. this.showCatalog = false
  240. // TODO: 跳转到对应章节内容
  241. },
  242. goToCommentReply() {
  243. uni.navigateTo({
  244. url: '/pages_order/novel/comments'
  245. })
  246. }
  247. }
  248. }
  249. </script>
  250. <style lang="scss" scoped>
  251. .novel-detail {
  252. min-height: 100vh;
  253. background-color: #f5f5f5;
  254. padding-bottom: calc(env(safe-area-inset-bottom) + 30rpx);
  255. .nav-header {
  256. display: flex;
  257. justify-content: space-between;
  258. align-items: center;
  259. padding: 20rpx 30rpx;
  260. background-color: transparent;
  261. position: fixed;
  262. top: 0;
  263. left: 0;
  264. right: 0;
  265. z-index: 100;
  266. }
  267. .novel-info {
  268. padding: 20rpx;
  269. display: flex;
  270. background: #fff;
  271. .novel-cover {
  272. width: 200rpx;
  273. height: 280rpx;
  274. margin-right: 20rpx;
  275. image {
  276. width: 100%;
  277. height: 100%;
  278. border-radius: 8rpx;
  279. }
  280. }
  281. .novel-basic {
  282. flex: 1;
  283. display: flex;
  284. flex-direction: column;
  285. justify-content: space-between;
  286. .title {
  287. font-size: 36rpx;
  288. font-weight: bold;
  289. margin-bottom: 16rpx;
  290. }
  291. .author-line,
  292. .status-line {
  293. display: flex;
  294. align-items: center;
  295. margin-bottom: 12rpx;
  296. font-size: 28rpx;
  297. color: #666;
  298. }
  299. .label {
  300. color: #999;
  301. margin-right: 8rpx;
  302. }
  303. .score-line {
  304. margin-top: 16rpx;
  305. .score {
  306. font-size: 32rpx;
  307. color: #333;
  308. font-weight: bold;
  309. }
  310. .score-label {
  311. font-size: 24rpx;
  312. color: #999;
  313. margin-left: 8rpx;
  314. }
  315. }
  316. }
  317. }
  318. .recommendation-section {
  319. padding: 24rpx 32rpx;
  320. background: #fff;
  321. display: flex;
  322. justify-content: space-between;
  323. align-items: center;
  324. position: relative;
  325. .rec-left {
  326. display: flex;
  327. flex-direction: column;
  328. align-items: flex-start;
  329. margin-left: 70rpx;
  330. .rec-count {
  331. font-size: 44rpx;
  332. font-weight: 500;
  333. color: #333;
  334. line-height: 1.2;
  335. }
  336. .rec-label {
  337. font-size: 26rpx;
  338. color: #999;
  339. margin-top: 4rpx;
  340. }
  341. }
  342. .rec-divider {
  343. position: absolute;
  344. right: 160rpx;
  345. top: 20rpx;
  346. bottom: 20rpx;
  347. width: 2rpx;
  348. background: #eee;
  349. }
  350. .rec-right {
  351. flex-shrink: 0;
  352. .recommend-btn {
  353. background: #fff;
  354. color: #4a90e2;
  355. border: 2rpx solid #4a90e2;
  356. border-radius: 40rpx;
  357. padding: 12rpx 32rpx;
  358. font-size: 28rpx;
  359. display: flex;
  360. align-items: center;
  361. line-height: 1;
  362. height: 64rpx;
  363. .btn-icon {
  364. margin-right: 8rpx;
  365. font-size: 32rpx;
  366. }
  367. }
  368. }
  369. }
  370. .action-buttons {
  371. display: flex;
  372. padding: 30rpx;
  373. gap: 20rpx;
  374. button {
  375. flex: 1;
  376. height: 80rpx;
  377. border-radius: 40rpx;
  378. font-size: 32rpx;
  379. display: flex;
  380. align-items: center;
  381. justify-content: center;
  382. }
  383. .read-btn {
  384. background-color: #4a90e2;
  385. color: #fff;
  386. }
  387. .collect-btn {
  388. background-color: #f0f0f0;
  389. color: #666;
  390. }
  391. }
  392. .user-level {
  393. margin: 20rpx 30rpx;
  394. background-color: #fff;
  395. border-radius: 12rpx;
  396. padding: 24rpx 32rpx;
  397. display: flex;
  398. justify-content: space-between;
  399. align-items: stretch;
  400. .level-left {
  401. flex: 1;
  402. .level-title {
  403. display: flex;
  404. align-items: center;
  405. gap: 8rpx;
  406. margin-bottom: 20rpx;
  407. margin-left: 20rpx;
  408. .title-icon {
  409. font-size: 36rpx;
  410. color: #FFB800;
  411. }
  412. text {
  413. font-size: 32rpx;
  414. font-weight: 500;
  415. color: #333;
  416. }
  417. }
  418. .level-info {
  419. display: flex;
  420. align-items: flex-start;
  421. gap: 20rpx;
  422. .user-avatar {
  423. width: 80rpx;
  424. height: 80rpx;
  425. border-radius: 50%;
  426. border: 2rpx solid #f0f0f0;
  427. }
  428. .user-details {
  429. display: flex;
  430. flex-direction: column;
  431. gap: 8rpx;
  432. .username {
  433. display: flex;
  434. font-size: 28rpx;
  435. color: #333;
  436. font-weight: 500;
  437. image {
  438. width: 60rpx;
  439. height: 60rpx;
  440. }
  441. }
  442. .user-score {
  443. display: flex;
  444. align-items: center;
  445. gap: 8rpx;
  446. .score-value {
  447. font-size: 28rpx;
  448. color: #333;
  449. }
  450. .score-label {
  451. font-size: 24rpx;
  452. color: #999;
  453. }
  454. }
  455. .user-role {
  456. font-size: 24rpx;
  457. color: #666;
  458. background: #f5f5f5;
  459. padding: 4rpx 12rpx;
  460. border-radius: 4rpx;
  461. display: inline-block;
  462. }
  463. }
  464. }
  465. }
  466. .level-right {
  467. display: flex;
  468. align-items: center;
  469. .rank-btn {
  470. display: flex;
  471. flex-direction: column;
  472. align-items: center;
  473. justify-content: center;
  474. padding: 0 20rpx;
  475. .rank-icon {
  476. width: 200rpx;
  477. height: 60rpx;
  478. margin-bottom: 8rpx;
  479. }
  480. text {
  481. font-size: 26rpx;
  482. color: #333;
  483. line-height: 1.4;
  484. }
  485. .check-text {
  486. font-size: 22rpx;
  487. color: #999;
  488. }
  489. }
  490. }
  491. }
  492. .novel-intro {
  493. margin: 20rpx 30rpx;
  494. background-color: #fff;
  495. border-radius: 12rpx;
  496. padding: 24rpx;
  497. .intro-title {
  498. font-size: 32rpx;
  499. font-weight: 500;
  500. color: #333;
  501. margin-bottom: 16rpx;
  502. }
  503. .intro-content {
  504. font-size: 28rpx;
  505. color: #666;
  506. line-height: 1.6;
  507. display: flex;
  508. flex-direction: column;
  509. gap: 16rpx;
  510. text {
  511. display: block;
  512. }
  513. }
  514. }
  515. .comments-section {
  516. margin: 20rpx 30rpx;
  517. background-color: #fff;
  518. border-radius: 12rpx;
  519. padding: 24rpx;
  520. .comments-header {
  521. display: flex;
  522. align-items: center;
  523. margin-bottom: 24rpx;
  524. border-bottom: 2rpx solid #f5f5f5;
  525. padding-bottom: 24rpx;
  526. justify-content: flex-start;
  527. .header-left {
  528. display: flex;
  529. align-items: center;
  530. gap: 8rpx;
  531. .title-icon {
  532. font-size: 32rpx;
  533. }
  534. text {
  535. display: flex;
  536. align-items: center;
  537. font-size: 32rpx;
  538. font-weight: 500;
  539. color: #333;
  540. white-space: nowrap;
  541. }
  542. }
  543. .header-right {
  544. margin-left: auto;
  545. }
  546. }
  547. .comment-list {
  548. display: flex;
  549. flex-direction: column;
  550. gap: 32rpx;
  551. }
  552. .like-icon {
  553. font-size: 24rpx;
  554. color: #999;
  555. }
  556. .like-count {
  557. font-size: 24rpx;
  558. color: #999;
  559. }
  560. }
  561. .novel-catalog {
  562. margin: 20rpx 30rpx;
  563. background-color: #fff;
  564. border-radius: 12rpx;
  565. padding: 24rpx;
  566. .catalog-header {
  567. display: flex;
  568. justify-content: space-between;
  569. align-items: center;
  570. border-bottom: 2rpx solid #f5f5f5;
  571. .catalog-title {
  572. display: flex;
  573. align-items: center;
  574. gap: 8rpx;
  575. .title-icon {
  576. font-size: 32rpx;
  577. }
  578. text {
  579. font-size: 32rpx;
  580. font-weight: 500;
  581. color: #333;
  582. }
  583. }
  584. .chapter-nav {
  585. display: flex;
  586. align-items: center;
  587. gap: 8rpx;
  588. .current-chapter {
  589. font-size: 28rpx;
  590. color: #666;
  591. }
  592. .nav-arrow {
  593. font-size: 28rpx;
  594. color: #999;
  595. }
  596. }
  597. }
  598. }
  599. .novel-bottom {
  600. position: fixed;
  601. bottom: 0;
  602. left: 0;
  603. right: 0;
  604. height: 100rpx;
  605. background: #fff;
  606. display: flex;
  607. align-items: center;
  608. padding: 0 30rpx;
  609. padding-bottom: env(safe-area-inset-bottom);
  610. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
  611. .bottom-left {
  612. flex: 1;
  613. display: flex;
  614. gap: 40rpx;
  615. .action-btn {
  616. display: flex;
  617. flex-direction: column;
  618. align-items: center;
  619. gap: 4rpx;
  620. .btn-icon {
  621. font-size: 40rpx;
  622. line-height: 1;
  623. }
  624. text {
  625. font-size: 24rpx;
  626. color: #666;
  627. }
  628. }
  629. }
  630. .bottom-right {
  631. flex-shrink: 0;
  632. .read-now-btn {
  633. background: #1a237e;
  634. color: #fff;
  635. font-size: 32rpx;
  636. height: 80rpx;
  637. line-height: 80rpx;
  638. padding: 0 60rpx;
  639. border-radius: 40rpx;
  640. border: none;
  641. }
  642. }
  643. }
  644. }
  645. </style>