index.ux 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <import name="x-book" src="../../components/book/book.ux"></import>
  2. <template>
  3. <div class="detail-wrap">
  4. <div class="book-wrap">
  5. <x-book multi="{{true}}" width="{{180}}" book="{{book}}" prevent="{{true}}">
  6. <div class="book-info">
  7. <text class="name">{{book.book_name}}</text>
  8. <div class="category">
  9. <text>{{book.book_category}}</text>
  10. <text class="status">{{book.book_end_status ? '完结': '连载'}}</text>
  11. </div>
  12. <text class="words">字数:{{bookWordsFormat(book.book_word_count)}}</text>
  13. <div class="user-operator">
  14. <text class="add" @click="addShelf">加入书架</text>
  15. <text class="read" @click="toRead">立即阅读</text>
  16. </div>
  17. </div>
  18. </x-book>
  19. <stack class="book-intro">
  20. <text class="short-info__text">{{substrInfoText()}}</text>
  21. <text class="toggle" @click="toggleTextStatus">{{showLongText ? '收起' : '展开'}}</text>
  22. </stack>
  23. </div>
  24. <text class="lastest-chapter" @click="toRead(book.last_cid)">最新章节:{{book.last_chapter}}</text>
  25. <div class="box-wrap short-chapter__list">
  26. <div class="small-title">
  27. <div class="wrap-left">
  28. <!-- <text class="border-left"></text> -->
  29. <text class="title">目录</text>
  30. <text class="total">共{{book.book_chapter_total}}章</text>
  31. </div>
  32. <text class="wrap-right">{{book.update_time}}</text>
  33. </div>
  34. <div class="chapter-list">
  35. <block for="chapters">
  36. <text class="chapter-item" @click="toRead($item.chapter_id)">{{$item.chapter_name}}</text>
  37. </block>
  38. </div>
  39. <text class="more-chapters" @click="toBookCatalog">更多目录 &gt;</text>
  40. </div>
  41. <div class="box-wrap similar-list__wrap">
  42. <div class="small-title">
  43. <div class="wrap-left">
  44. <!-- <text class="border-left"></text> -->
  45. <text class="title">同款推荐</text>
  46. </div>
  47. </div>
  48. <div class="similar-wrap">
  49. <block for="similar">
  50. <x-book similar="{{true}}" book="{{$item}}"></x-book>
  51. </block>
  52. </div>
  53. </div>
  54. </div>
  55. </template>
  56. <script>
  57. import { getBooksInfo, getShortCatalog, getSimilarBooks } from "../../api";
  58. import router from '@system.router';
  59. export default {
  60. protected: {
  61. bid: ""
  62. },
  63. private: {
  64. showLongText: false,
  65. book: {},
  66. chapters: [],
  67. similar: []
  68. },
  69. substrInfoText() {
  70. if (this.book.book_summary) {
  71. return this.showLongText ? this.book.book_summary : this.book.book_summary.slice(0, 110);
  72. } else return "";
  73. },
  74. toggleTextStatus() {
  75. this.showLongText = !this.showLongText;
  76. this.substrInfoText();
  77. },
  78. addShelf() { },
  79. toRead(cid) {
  80. let chapter_id = this.book.first_cid;
  81. if (cid) chapter_id = cid;
  82. router.push({
  83. uri: "/views/Reader",
  84. params: {
  85. bid: this.book.book_id,
  86. chapter_id: chapter_id
  87. }
  88. })
  89. },
  90. toBookCatalog() {
  91. router.push({
  92. uri: "/views/Catalog",
  93. params: {
  94. bid: this.book.book_id
  95. }
  96. })
  97. },
  98. bookWordsFormat(words) {
  99. if (words > 10000) return (words / 10000).toFixed(2) + "万字";
  100. else return words + "字";
  101. },
  102. async getBooksInfo(bid) {
  103. this.book = await getBooksInfo(bid);
  104. this.chapters = await getShortCatalog(bid);
  105. this.similar = await getSimilarBooks(this.book.book_category_id, bid);
  106. },
  107. onInit() {
  108. console.log("book bid", this.bid);
  109. this.getBooksInfo("5pNo6A7wqQmB1WgQygDjkOM9VZn2vXeY");
  110. },
  111. }
  112. </script>
  113. <style lang="less">
  114. @import "../../assets/less/detail.less";
  115. </style>