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

838 lines
17 KiB

  1. <template>
  2. <!-- 小说详情页面 -->
  3. <view class="novel-detail">
  4. <navbar leftClick @leftClick="$utils.navigateBack" />
  5. <!-- 小说基本信息 -->
  6. <view class="novel-info">
  7. <view class="novel-cover">
  8. <image :src="novelData.image &&
  9. novelData.image.split(',')[0]" mode="aspectFill"></image>
  10. </view>
  11. <view class="novel-basic">
  12. <text class="title">{{ novelData.name }}</text>
  13. <view class="author-line">
  14. <text class="label">作者</text>
  15. <text class="author">{{ novelData.author || '暂无显示' }}</text>
  16. </view>
  17. <!-- <view class="status-line">
  18. <text class="label">完结</text>
  19. <text class="status">{{ novelData.status }}</text>
  20. </view> -->
  21. <view class="content-row">
  22. <!-- <view class="book-status">
  23. <text>{{novelData.status}}</text>
  24. </view> -->
  25. <bookStatus :status="novelData.status"/>
  26. <view class="book-text">
  27. {{ novelData.service }}
  28. </view>
  29. </view>
  30. <view class="score-line">
  31. <text class="score">{{ novelData.qmNum || 0}}</text>
  32. <text class="score-label">作者累计亲密度值</text>
  33. </view>
  34. </view>
  35. </view>
  36. <!-- 推荐票数显示 -->
  37. <view class="recommendation-section">
  38. <view class="rec-left">
  39. <text class="rec-count">{{ novelData.tuiNum || 0 }}</text>
  40. <text class="rec-label">推荐票数</text>
  41. </view>
  42. <view class="rec-divider"></view>
  43. <view class="rec-right">
  44. <button class="recommend-btn" @click="$refs.novelVotePopup.open(id)">
  45. <text class="btn-icon">📑</text>
  46. 投推荐票
  47. </button>
  48. </view>
  49. </view>
  50. <!-- 阅读和收藏按钮 -->
  51. <!-- 我的等级 -->
  52. <view class="user-level">
  53. <view class="level-left">
  54. <view class="level-title">
  55. <!-- <text class="title-icon">👑</text> -->
  56. <image style="width: 30rpx;height: 30rpx;" src="/pages_order/static/book/level.png"
  57. mode="aspectFill"></image>
  58. <text>我的等级</text>
  59. </view>
  60. <view class="level-info">
  61. <image class="user-avatar" src="/pages_order/static/book/dj.png" mode="aspectFill"></image>
  62. <view class="user-details">
  63. <text class="username">
  64. <image
  65. src="https://tse4-mm.cn.bing.net/th/id/OIP-C.iUyxJ_fxLjjX3kEBjteXWwAAAA?rs=1&pid=ImgDetMain"
  66. mode="aspectFill"></image>
  67. <view class="name">
  68. 周海
  69. </view>
  70. </text>
  71. <view class="user-score">
  72. <text class="score-value">6785452</text>
  73. <text class="score-label">亲密值</text>
  74. </view>
  75. <text class="user-role">护书使者 五级</text>
  76. </view>
  77. </view>
  78. </view>
  79. <view class="level-right">
  80. <view class="rank-btn" @click="toggleInteractive">
  81. <image class="rank-icon" src="/pages_order/static/book/bd.png" mode="aspectFit"></image>
  82. <text class="check-text">点击查看</text>
  83. </view>
  84. </view>
  85. </view>
  86. <!-- 小说简介 -->
  87. <view class="novel-intro">
  88. <view class="intro-title">
  89. <text>简介</text>
  90. </view>
  91. <view class="intro-content">
  92. {{ novelData.details }}
  93. </view>
  94. </view>
  95. <!-- 目录 -->
  96. <view class="novel-catalog" @click="$refs.chapterPopup.open()">
  97. <view class="catalog-header">
  98. <view class="catalog-title">
  99. <text class="title-icon">📖</text>
  100. <text>目录</text>
  101. </view>
  102. <view class="chapter-nav">
  103. <text class="current-chapter">
  104. {{ catalog ? catalog.title || '暂无章节' : '暂无章节' }}
  105. </text>
  106. <text class="nav-arrow">></text>
  107. </view>
  108. </view>
  109. </view>
  110. <!-- 书评区域 -->
  111. <view class="comments-section">
  112. <view class="comments-header">
  113. <view class="header-left">
  114. <text class="title-icon">📝</text>
  115. <text>书评</text>
  116. </view>
  117. <view class="header-right">
  118. <text @click="goToWriteReview">写书评</text>
  119. </view>
  120. </view>
  121. <view class="comment-list">
  122. <commentItem v-for="(item, index) in list" :item="item" :key="index" />
  123. <uv-empty mode="list" v-if="list.length == 0"></uv-empty>
  124. </view>
  125. </view>
  126. <!-- 底部操作栏 -->
  127. <view class="novel-bottom">
  128. <view class="bottom-left">
  129. <view class="action-btn" @click="addToBookshelf">
  130. <view class="btn-icon">
  131. <uv-icon name="grid" color="#999" size="60rpx"></uv-icon>
  132. </view>
  133. <text>加入书架</text>
  134. </view>
  135. <!-- <view class="action-btn" @click="goToGiftbox">
  136. <text class="btn-icon">🎁</text>
  137. <text>礼物盒</text>
  138. </view> -->
  139. <view class="action-btn" @click="$refs.interactiveGiftPopup.open()">
  140. <view class="btn-icon">
  141. <uv-icon name="gift" color="#999" size="60rpx"></uv-icon>
  142. </view>
  143. <text>互动打赏</text>
  144. </view>
  145. </view>
  146. <view class="bottom-right">
  147. <button class="read-now-btn" @click="toRead">立即阅读</button>
  148. </view>
  149. </view>
  150. <novelVotePopup ref="novelVotePopup" @updateVote="updateVote"/>
  151. <chapterPopup ref="chapterPopup" :bookId="id" :chapterList="chapterList" @selectChapter="selectChapter"/>
  152. <interactiveGiftPopup ref="interactiveGiftPopup" :bookId="id" @giftSent="handleGiftSent"/>
  153. </view>
  154. </template>
  155. <script>
  156. import catalogpopup from '@/components/novel/CatalogPopup.vue'
  157. import chapterPopup from '../components/novel/chapterPopup.vue'
  158. import commentItem from '../components/comment/commentItem.vue'
  159. import novelVotePopup from '../components/novel/novelVotePopup.vue'
  160. import interactiveGiftPopup from '../components/novel/interactiveGiftPopup.vue'
  161. import mixinsList from '@/mixins/list.js'
  162. import bookStatus from '@/components/novel/bookStatus.vue'
  163. export default {
  164. mixins: [mixinsList],
  165. components: {
  166. catalogpopup,
  167. chapterPopup,
  168. commentItem,
  169. novelVotePopup,
  170. interactiveGiftPopup,
  171. bookStatus,
  172. },
  173. data() {
  174. return {
  175. novelData: {},
  176. isCollected: false,
  177. comments: [],
  178. currentIndex: 0,
  179. id: 0,
  180. bookLevel: {},
  181. mixinsListApi: 'getBookCommentList',
  182. catalog: {}, //最后一个章节
  183. fastCatalog: {}, //第一章节
  184. chapterList : [],//章节列表
  185. }
  186. },
  187. computed: {},
  188. onLoad({
  189. id
  190. }) {
  191. this.id = id
  192. this.queryParams.bookId = id
  193. },
  194. onShow() {
  195. this.getDateil()
  196. this.getBookCatalogList()
  197. if(this.isLogin){
  198. this.getAchievement()
  199. }
  200. },
  201. methods: {
  202. updateVote() {
  203. this.getDateil()
  204. this.getAchievement()
  205. },
  206. getDateil() {
  207. let data = {
  208. id: this.id
  209. }
  210. if(uni.getStorageSync('data')){
  211. data.token = uni.getStorageSync('token')
  212. }
  213. this.$fetch('getBookDetail', data).then(res => {
  214. this.novelData = res
  215. })
  216. },
  217. getAchievement() {
  218. this.$fetch('getAchievement', {
  219. id: this.id
  220. }).then(res => {
  221. this.bookLevel = res
  222. })
  223. },
  224. getBookCatalogList() {
  225. this.$fetch('getBookCatalogList', {
  226. bookId : this.id,
  227. pageNo : 1,
  228. pageSize : 9999999,
  229. reverse : 0,
  230. }).then(res => {
  231. this.chapterList = res.records
  232. this.catalog = res.records[res.records.length - 1]
  233. this.fastCatalog = res.records[0]
  234. })
  235. // 获取最后章节
  236. // this.$fetch('getBookCatalogList', {
  237. // bookId: this.id,
  238. // pageNo: 1,
  239. // pageSize: 1,
  240. // reverse: 1,
  241. // }).then(res => {
  242. // this.catalog = res.records[0]
  243. // })
  244. // // 获取第一章节
  245. // this.$fetch('getBookCatalogList', {
  246. // bookId: this.id,
  247. // pageNo: 1,
  248. // pageSize: 1,
  249. // reverse: 0,
  250. // }).then(res => {
  251. // this.fastCatalog = res.records[0]
  252. // })
  253. },
  254. toggleCollect() {
  255. this.isCollected = !this.isCollected
  256. },
  257. goToWriteReview() {
  258. uni.navigateTo({
  259. url: `/pages_order/comment/review?id=${this.id}`
  260. })
  261. },
  262. addToBookshelf() {
  263. this.$fetch('addReadBook', {
  264. shopId: this.id,
  265. name: this.novelData.name,
  266. image: this.novelData.image,
  267. novelId : this.fastCatalog && this.fastCatalog.id
  268. }).then(res => {
  269. uni.showToast({
  270. title: '已加入书架',
  271. icon: 'success'
  272. })
  273. })
  274. },
  275. toggleInteractive() {
  276. uni.navigateTo({
  277. url: `/pages_order/novel/Tipping?id=${this.id}`
  278. })
  279. },
  280. goToGiftbox() {
  281. uni.navigateTo({
  282. url: `/pages_order/novel/Giftbox?id=${this.id}`
  283. })
  284. },
  285. toRead() {
  286. if (!this.fastCatalog) {
  287. uni.showToast({
  288. title: '暂无章节',
  289. icon: 'none'
  290. })
  291. return
  292. }
  293. uni.navigateTo({
  294. url: `/pages_order/novel/readnovels?cid=${this.fastCatalog.id}&id=${this.id}`
  295. })
  296. },
  297. selectChapter({item, index}){
  298. uni.navigateTo({
  299. url: `/pages_order/novel/readnovels?cid=${item.id}&id=${this.id}`
  300. })
  301. },
  302. handleGiftSent(giftData) {
  303. // 处理礼物发送后的逻辑
  304. console.log('礼物发送成功:', giftData);
  305. uni.showToast({
  306. title: `成功赠送${giftData.gift.title} x${giftData.count}`,
  307. icon: 'success'
  308. });
  309. // 重新获取小说详情,更新打赏相关数据
  310. this.getDateil();
  311. // 如果用户已登录,更新成就数据
  312. if(this.isLogin){
  313. this.getAchievement();
  314. }
  315. },
  316. }
  317. }
  318. </script>
  319. <style lang="scss" scoped>
  320. .novel-detail {
  321. min-height: 100vh;
  322. background-color: #f5f5f5;
  323. padding-bottom: calc(env(safe-area-inset-bottom) + 100rpx);
  324. .nav-header {
  325. display: flex;
  326. justify-content: space-between;
  327. align-items: center;
  328. padding: 20rpx 30rpx;
  329. background-color: transparent;
  330. position: fixed;
  331. top: 0;
  332. left: 0;
  333. right: 0;
  334. z-index: 100;
  335. }
  336. .novel-info {
  337. padding: 40rpx;
  338. display: flex;
  339. background: #fff;
  340. .novel-cover {
  341. width: 160rpx;
  342. height: 200rpx;
  343. margin-right: 20rpx;
  344. image {
  345. width: 100%;
  346. height: 100%;
  347. border-radius: 20rpx;
  348. }
  349. }
  350. .novel-basic {
  351. flex: 1;
  352. display: flex;
  353. flex-direction: column;
  354. justify-content: space-between;
  355. .title {
  356. font-size: 36rpx;
  357. font-weight: bold;
  358. margin-bottom: 16rpx;
  359. }
  360. .author-line,
  361. .status-line {
  362. display: flex;
  363. align-items: center;
  364. margin-bottom: 12rpx;
  365. font-size: 26rpx;
  366. color: #666;
  367. }
  368. .content-row {
  369. display: flex;
  370. align-items: center;
  371. margin-bottom: 10rpx;
  372. .book-status {
  373. flex-shrink: 0;
  374. text {
  375. font-size: 20rpx;
  376. color: #67C23A;
  377. background-color: rgba(103, 194, 58, 0.1);
  378. border-radius: 20rpx;
  379. padding: 4rpx 12rpx;
  380. }
  381. }
  382. .book-text {
  383. font-size: 20rpx;
  384. }
  385. }
  386. .label {
  387. color: #999;
  388. margin-right: 8rpx;
  389. }
  390. .score-line {
  391. margin-top: 16rpx;
  392. .score {
  393. font-size: 32rpx;
  394. color: #333;
  395. font-weight: bold;
  396. }
  397. .score-label {
  398. font-size: 24rpx;
  399. color: #999;
  400. margin-left: 8rpx;
  401. }
  402. }
  403. }
  404. }
  405. .recommendation-section {
  406. padding: 24rpx 32rpx;
  407. background: #fff;
  408. display: flex;
  409. justify-content: space-between;
  410. align-items: center;
  411. position: relative;
  412. .rec-left {
  413. display: flex;
  414. flex-direction: column;
  415. align-items: center;
  416. margin-left: 70rpx;
  417. .rec-count {
  418. font-size: 34rpx;
  419. font-weight: 500;
  420. color: #333;
  421. line-height: 1.2;
  422. }
  423. .rec-label {
  424. font-size: 26rpx;
  425. color: #999;
  426. margin-top: 4rpx;
  427. }
  428. }
  429. .rec-divider {
  430. position: absolute;
  431. right: 160rpx;
  432. top: 20rpx;
  433. bottom: 20rpx;
  434. width: 2rpx;
  435. background: #eee;
  436. }
  437. .rec-right {
  438. flex-shrink: 0;
  439. .recommend-btn {
  440. background: #fff;
  441. color: #4a90e2;
  442. border: 2rpx solid #4a90e2;
  443. border-radius: 40rpx;
  444. padding: 12rpx 32rpx;
  445. font-size: 28rpx;
  446. display: flex;
  447. align-items: center;
  448. line-height: 1;
  449. height: 64rpx;
  450. .btn-icon {
  451. margin-right: 8rpx;
  452. font-size: 32rpx;
  453. }
  454. }
  455. }
  456. }
  457. .action-buttons {
  458. display: flex;
  459. padding: 30rpx;
  460. gap: 20rpx;
  461. button {
  462. flex: 1;
  463. height: 80rpx;
  464. border-radius: 40rpx;
  465. font-size: 32rpx;
  466. display: flex;
  467. align-items: center;
  468. justify-content: center;
  469. }
  470. .read-btn {
  471. background-color: #4a90e2;
  472. color: #fff;
  473. }
  474. .collect-btn {
  475. background-color: #f0f0f0;
  476. color: #666;
  477. }
  478. }
  479. .user-level {
  480. margin: 20rpx 30rpx;
  481. background-color: #fff;
  482. border-radius: 12rpx;
  483. padding: 24rpx 32rpx;
  484. display: flex;
  485. justify-content: space-between;
  486. align-items: stretch;
  487. .level-left {
  488. flex: 1;
  489. .level-title {
  490. display: flex;
  491. align-items: center;
  492. gap: 8rpx;
  493. margin-bottom: 20rpx;
  494. margin-left: 20rpx;
  495. .title-icon {
  496. font-size: 36rpx;
  497. color: #FFB800;
  498. }
  499. text {
  500. font-size: 32rpx;
  501. font-weight: 500;
  502. color: #333;
  503. }
  504. }
  505. .level-info {
  506. display: flex;
  507. align-items: flex-start;
  508. gap: 20rpx;
  509. .user-avatar {
  510. width: 80rpx;
  511. height: 80rpx;
  512. border-radius: 50%;
  513. border: 2rpx solid #f0f0f0;
  514. }
  515. .user-details {
  516. display: flex;
  517. flex-direction: column;
  518. gap: 8rpx;
  519. .username {
  520. display: flex;
  521. font-size: 28rpx;
  522. color: #333;
  523. font-weight: 500;
  524. image {
  525. width: 60rpx;
  526. height: 60rpx;
  527. }
  528. }
  529. .user-score {
  530. display: flex;
  531. align-items: center;
  532. gap: 8rpx;
  533. .score-value {
  534. font-size: 28rpx;
  535. color: #333;
  536. }
  537. .score-label {
  538. font-size: 24rpx;
  539. color: #999;
  540. }
  541. }
  542. .user-role {
  543. font-size: 24rpx;
  544. color: #666;
  545. background: #f5f5f5;
  546. padding: 4rpx 12rpx;
  547. border-radius: 4rpx;
  548. display: inline-block;
  549. }
  550. }
  551. }
  552. }
  553. .level-right {
  554. display: flex;
  555. align-items: center;
  556. .rank-btn {
  557. display: flex;
  558. flex-direction: column;
  559. align-items: center;
  560. justify-content: center;
  561. padding: 0 20rpx;
  562. .rank-icon {
  563. width: 200rpx;
  564. height: 60rpx;
  565. margin-bottom: 8rpx;
  566. }
  567. text {
  568. font-size: 26rpx;
  569. color: #333;
  570. line-height: 1.4;
  571. }
  572. .check-text {
  573. font-size: 22rpx;
  574. color: #33e;
  575. }
  576. }
  577. }
  578. }
  579. .novel-intro {
  580. margin: 20rpx 30rpx;
  581. background-color: #fff;
  582. border-radius: 12rpx;
  583. padding: 24rpx;
  584. .intro-title {
  585. font-size: 32rpx;
  586. font-weight: 500;
  587. color: #333;
  588. margin-bottom: 16rpx;
  589. }
  590. .intro-content {
  591. font-size: 28rpx;
  592. color: #666;
  593. line-height: 1.6;
  594. display: flex;
  595. flex-direction: column;
  596. gap: 16rpx;
  597. text {
  598. display: block;
  599. }
  600. }
  601. }
  602. .comments-section {
  603. margin: 20rpx 30rpx;
  604. background-color: #fff;
  605. border-radius: 12rpx;
  606. padding: 24rpx;
  607. .comments-header {
  608. display: flex;
  609. align-items: center;
  610. margin-bottom: 24rpx;
  611. border-bottom: 2rpx solid #f5f5f5;
  612. padding-bottom: 24rpx;
  613. justify-content: flex-start;
  614. .header-left {
  615. display: flex;
  616. align-items: center;
  617. gap: 8rpx;
  618. .title-icon {
  619. font-size: 32rpx;
  620. }
  621. text {
  622. display: flex;
  623. align-items: center;
  624. font-size: 32rpx;
  625. font-weight: 500;
  626. color: #333;
  627. white-space: nowrap;
  628. }
  629. }
  630. .header-right {
  631. margin-left: auto;
  632. }
  633. }
  634. .comment-list {
  635. display: flex;
  636. flex-direction: column;
  637. gap: 32rpx;
  638. }
  639. .like-icon {
  640. font-size: 24rpx;
  641. color: #999;
  642. }
  643. .like-count {
  644. font-size: 24rpx;
  645. color: #999;
  646. }
  647. }
  648. .novel-catalog {
  649. margin: 20rpx 30rpx;
  650. background-color: #fff;
  651. border-radius: 12rpx;
  652. padding: 24rpx;
  653. .catalog-header {
  654. display: flex;
  655. justify-content: space-between;
  656. align-items: center;
  657. border-bottom: 2rpx solid #f5f5f5;
  658. .catalog-title {
  659. display: flex;
  660. align-items: center;
  661. gap: 8rpx;
  662. .title-icon {
  663. font-size: 32rpx;
  664. }
  665. text {
  666. font-size: 32rpx;
  667. font-weight: 500;
  668. color: #333;
  669. }
  670. }
  671. .chapter-nav {
  672. display: flex;
  673. align-items: center;
  674. gap: 8rpx;
  675. .current-chapter {
  676. font-size: 28rpx;
  677. color: #666;
  678. }
  679. .nav-arrow {
  680. font-size: 28rpx;
  681. color: #999;
  682. }
  683. }
  684. }
  685. }
  686. .novel-bottom {
  687. position: fixed;
  688. bottom: 0;
  689. left: 0;
  690. right: 0;
  691. height: 100rpx;
  692. background: #fff;
  693. display: flex;
  694. align-items: center;
  695. padding: 0 30rpx;
  696. padding-top: 15rpx;
  697. padding-bottom: env(safe-area-inset-bottom);
  698. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
  699. gap: 40rpx;
  700. .bottom-left {
  701. display: flex;
  702. gap: 40rpx;
  703. .action-btn {
  704. display: flex;
  705. flex-direction: column;
  706. align-items: center;
  707. gap: 4rpx;
  708. .btn-icon {
  709. font-size: 40rpx;
  710. line-height: 1;
  711. }
  712. text {
  713. font-size: 24rpx;
  714. color: #666;
  715. }
  716. }
  717. }
  718. .bottom-right {
  719. flex: 1;
  720. display: flex;
  721. .read-now-btn {
  722. flex: 1;
  723. background: #1a237e;
  724. color: #fff;
  725. font-size: 32rpx;
  726. height: 80rpx;
  727. line-height: 80rpx;
  728. padding: 0 60rpx;
  729. border-radius: 40rpx;
  730. border: none;
  731. }
  732. }
  733. }
  734. }
  735. </style>