book.ux 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <div class="{{multi ? 'book-wrap__multi' : 'book-wrap'}}" style="{{bookSimpleStyle()}}" @click="getBooks(book)">
  3. <block if="!multi">
  4. <image style="height: {{width * 1.33}}px" class="book-cover__simple" src="{{book.cover_url}}"></image>
  5. <text class="book-name {{lines ? 'book-name__line2' : ''}}">{{book.book_name}}</text>
  6. <slot></slot>
  7. </block>
  8. <block else>
  9. <image style="{{bookMultiStyle()}}" class="book-cover__multi" src="{{book.cover_url}}"></image>
  10. <slot>
  11. <div class="book-info__multi">
  12. <text class="name">{{book.book_name}}</text>
  13. <text class="intro">{{book.book_summary}}</text>
  14. </div>
  15. </slot>
  16. </block>
  17. </div>
  18. </template>
  19. <script>
  20. import router from "@system.router";
  21. export default {
  22. props: {
  23. multi: {
  24. type: Boolean,
  25. default: false
  26. },
  27. prevent: {
  28. type: Boolean,
  29. default: false
  30. },
  31. read: {
  32. type: Boolean,
  33. default: false
  34. },
  35. similar: {
  36. type: Boolean,
  37. default: false
  38. },
  39. book: {
  40. type: Object,
  41. default: {}
  42. },
  43. width: {
  44. type: Number,
  45. default: 200
  46. },
  47. lines: {
  48. type: Boolean,
  49. default: false
  50. }
  51. },
  52. bookSimpleStyle() {
  53. if (!this.multi) {
  54. return {
  55. width: this.width + 'px'
  56. }
  57. }
  58. },
  59. bookMultiStyle() {
  60. if (this.multi) {
  61. return {
  62. width: this.width + 'px',
  63. height: this.width * 1.33 + 'px'
  64. }
  65. }
  66. },
  67. getBooks(book) {
  68. if (this.prevent) return;
  69. console.log("click_book", book);
  70. if (this.read) {
  71. router.push({
  72. uri: "/views/Reader",
  73. params: {
  74. bid: book.book_id,
  75. chapter_id: book.recent_cid
  76. }
  77. })
  78. return;
  79. }
  80. if (this.similar) {
  81. router.replace({
  82. uri: "/views/Detail",
  83. params: {
  84. bid: book.book_id || ""
  85. }
  86. })
  87. } else {
  88. router.push({
  89. uri: "/views/Detail",
  90. params: {
  91. bid: book.book_id || ""
  92. }
  93. })
  94. }
  95. }
  96. }
  97. </script>
  98. <style lang="less" scoped>
  99. .book-wrap {
  100. width: 200px;
  101. flex-shrink: 0;
  102. flex-direction: column;
  103. .book-cover__simple {
  104. width: 100%;
  105. height: 264px;
  106. border-radius: 6px;
  107. }
  108. .book-name {
  109. font-size: 24px;
  110. color: #999;
  111. margin-top: 14px;
  112. margin-bottom: 36px;
  113. lines: 1;
  114. text-overflow: ellipsis;
  115. &__line2 {
  116. lines: 2;
  117. }
  118. }
  119. }
  120. .book-wrap__multi {
  121. /* flex: 1; */
  122. flex-direction: row;
  123. .book-cover__multi {
  124. width: 200px;
  125. flex-shrink: 0;
  126. height: 266px;
  127. border-radius: 6px;
  128. }
  129. .book-info__multi {
  130. flex: 1;
  131. height: 266px;
  132. flex-direction: column;
  133. margin-left: 38px;
  134. margin-bottom: 40px;
  135. .name {
  136. font-size: 36px;
  137. color: #333;
  138. margin-bottom: 54px;
  139. lines: 1;
  140. text-overflow: ellipsis;
  141. }
  142. .intro {
  143. font-size: 26px;
  144. color: #666;
  145. line-height: 40px;
  146. lines: 4;
  147. text-overflow: ellipsis;
  148. }
  149. }
  150. }
  151. </style>