book.ux 2.7 KB

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