index.ux 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <import name="x-book" src="../../components/book/book.ux"></import>
  2. <template>
  3. <list id="free" class="free-wrap" v-if="list.length>0 && isInit">
  4. <list-item type="tab">
  5. <div class="type-bar">
  6. <block for="type in typeList">
  7. <div class="type-item" @click="typeChange(type.index)">
  8. <text class="{{type.index === current ? 'cur' : ''}}">{{type.name}}</text>
  9. <text class="choose-bar" show="{{type.index === current}}"></text>
  10. </div>
  11. </block>
  12. </div>
  13. </list-item>
  14. <list-item type="banner" class="free-title" if="{{endTime}}">
  15. <text>限时免费结束时间:{{endTime}}</text>
  16. </list-item>
  17. <block for="book in list" if="{{isInit && list.length>0}}">
  18. <list-item type="books-item" class="book-list__wrap book-list__wrap--multi">
  19. <div class="book-list__multi">
  20. <div class="book-item">
  21. <x-book multi="{{true}}" width="{{150}}" book="{{book}}">
  22. <div class="book-info__multi">
  23. <text class="name">{{book.book_name}}</text>
  24. <text class="intro">{{book.intro}}</text>
  25. </div>
  26. </x-book>
  27. </div>
  28. </div>
  29. </list-item>
  30. </block>
  31. <list-item type="blank" if="{{isInit && list.length<=0}}" class="blank_img">
  32. <image src="https://cdn-novel.iycdm.com/quickapp/activity/white_shelf.png"></image>
  33. </list-item>
  34. </list>
  35. </template>
  36. <script>
  37. import { getFreeBook } from "../../api";
  38. import router from '@system.router';
  39. import prompt from '@system.prompt';
  40. export default {
  41. public: {
  42. bid: "",
  43. chapter_sequence: "",
  44. },
  45. private: {
  46. isInit: false,
  47. list: [],
  48. endTime: '',
  49. typeList: [
  50. {
  51. name: "男生",
  52. index: 1
  53. },
  54. {
  55. name: "女生",
  56. index: 2
  57. }
  58. ],
  59. current: 2
  60. },
  61. onInit() {
  62. this.getBookList(this.current)
  63. },
  64. typeChange(index) {
  65. this.current = index;
  66. this.getBookList(index);
  67. },
  68. async getBookList(index = 2) {
  69. let data = await getFreeBook(index);
  70. if (!data || (Array.isArray(data) && data.length <= 0)) {
  71. this.list = [];
  72. this.endTime = undefined;
  73. this.isInit = true;
  74. } else {
  75. this.list = data.list;
  76. this.endTime = data.end_time;
  77. this.isInit = true;
  78. }
  79. },
  80. }
  81. </script>
  82. <style lang="less">
  83. .free-title {
  84. margin: 30px 0;
  85. justify-content: center;
  86. text {
  87. width: 600px;
  88. height: 60px;
  89. line-height: 60px;
  90. text-align: center;
  91. background-color: rgba(239, 89, 82, 0.1);
  92. border: 1px solid rgba(239, 89, 82, 1);
  93. color: #ef5952;
  94. font-size: 26px;
  95. border-radius: 30px;
  96. }
  97. }
  98. .book-list__wrap {
  99. background-color: #fff;
  100. // margin-top: 24px;
  101. padding: 0 24px;
  102. flex-direction: column;
  103. .book-list__title {
  104. padding: 30px 0;
  105. align-items: center;
  106. text {
  107. color: #333;
  108. font-size: 32px;
  109. }
  110. }
  111. }
  112. .book-list {
  113. flex: 1;
  114. flex-direction: row;
  115. flex-wrap: wrap;
  116. justify-content: space-between;
  117. }
  118. .book-list__multi {
  119. margin-top: 30px;
  120. flex-direction: column;
  121. .book-item {
  122. margin-bottom: 30px;
  123. }
  124. .book-info__multi {
  125. flex: 1;
  126. flex-direction: column;
  127. justify-content: flex-start;
  128. align-items: flex-start;
  129. margin-left: 38px;
  130. // margin-bottom: 40px;
  131. .name {
  132. font-size: 32px;
  133. color: #333;
  134. lines: 1;
  135. text-overflow: ellipsis;
  136. }
  137. .intro {
  138. font-size: 24px;
  139. color: #666;
  140. lines: 3;
  141. text-overflow: ellipsis;
  142. margin-top: 36px;
  143. line-height: 36px;
  144. }
  145. }
  146. }
  147. .blank_img {
  148. width: 100%;
  149. height: 100%;
  150. align-items: center;
  151. justify-content: center;
  152. image {
  153. width: 500px;
  154. }
  155. }
  156. .type-bar {
  157. width: 100%;
  158. .type-item {
  159. flex: 1;
  160. justify-content: center;
  161. align-items: center;
  162. flex-direction: column;
  163. position: relative;
  164. text {
  165. font-size: 30px;
  166. color: #999;
  167. // padding: 34px 0;
  168. }
  169. .cur {
  170. color: #3AACFF;
  171. font-size: 36px;
  172. font-weight: bold;
  173. }
  174. .choose-bar {
  175. width: 38px;
  176. height: 4px;
  177. background-color: #3AACFF;
  178. border-radius: 2px;
  179. margin-top: 10px;
  180. }
  181. }
  182. }
  183. </style>