index.ux 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <div class="page-column">
  3. <div class="title-bar" show="{{!editStatus}}">
  4. <text class="text-black">共收藏{{ shelfList.length }}本</text>
  5. <div @click="switchToEdit" if="{{ shelfList.length }}">
  6. <text class="text-primary iconfont">&#xe621;</text>
  7. <text class="text-primary">编辑</text>
  8. </div>
  9. </div>
  10. <div class="title-bar" show="{{editStatus}}">
  11. <text class="text-black">已删除{{ deleteList.length }}本</text>
  12. <div>
  13. <text class="text-cancel" @click="cancelEdit">取消</text>
  14. <text class="text-primary" @click="finishEdit">完成</text>
  15. </div>
  16. </div>
  17. <div class="bookshelf-list">
  18. <div
  19. class="bookshelf-item"
  20. for="shelfList"
  21. show="{{deleteList.indexOf($item.id)===-1}}"
  22. >
  23. <stack class="bookshelf-img">
  24. <div class="img-container">
  25. <image src="{{$item.novelImg}}" @click="clickImg($item)"></image>
  26. </div>
  27. <div class="delete-icon" @click="deleteBook($item)">
  28. <image
  29. src="../../assets/images/cancel.png"
  30. show="{{editStatus}}"
  31. ></image>
  32. </div>
  33. </stack>
  34. <text class="bookshelf-title">{{ $item.novelName }}</text>
  35. </div>
  36. </div>
  37. </div>
  38. </template>
  39. <script>
  40. export default {
  41. props: ['shelfList'],
  42. data: {
  43. img: '/assets/images/pic_1.jpg',
  44. editStatus: false,
  45. deleteList: []
  46. },
  47. onInit() {},
  48. /* -------------------SelfCustomEvent------------------ */
  49. clickImg(item) {
  50. if (!this.editStatus) {
  51. this.gotoBookContent(item)
  52. } else {
  53. this.deleteBook(item)
  54. }
  55. },
  56. gotoBookContent(item) {
  57. $utils.route2theUrl('pages/book-content', {
  58. bookId: item.id,
  59. bookTitle: item.novelName,
  60. total: item.novelChapterCount || 100,
  61. })
  62. },
  63. deleteBook(item) {
  64. this.deleteList.push(item.id)
  65. },
  66. switchToEdit() {
  67. this.editStatus = true
  68. },
  69. finishEdit() {
  70. let shelfList = this.shelfList.filter(book => {
  71. return this.deleteList.indexOf(book.id) === -1
  72. })
  73. this.$emit('updateShelf', { shelfList })
  74. this.editStatus = false
  75. this.deleteList = []
  76. },
  77. cancelEdit() {
  78. this.editStatus = false
  79. this.deleteList = []
  80. }
  81. }
  82. </script>
  83. <style lang="less">
  84. @import '../../assets/styles/index.less';
  85. .text-cancel {
  86. color: @text-grey;
  87. margin-right: @gap-4;
  88. }
  89. .bookshelf-list {
  90. width: 100%;
  91. padding: 20px;
  92. flex-wrap: wrap;
  93. .flex-box-mixins(row, flex-start, flex-start);
  94. .bookshelf-item {
  95. width: 28%;
  96. margin: 20px;
  97. .flex-box-mixins(column, flex-start, flex-start);
  98. .bookshelf-title {
  99. width: 100%;
  100. text-align: center;
  101. }
  102. }
  103. .bookshelf-img {
  104. width: 100%;
  105. height: 270px;
  106. .flex-box-mixins(row, flex-end, flex-end);
  107. .img-container {
  108. width: 100%;
  109. height: 100%;
  110. flex: 1;
  111. }
  112. .delete-icon {
  113. width: 60px;
  114. height: 60px;
  115. padding: @gap-1;
  116. }
  117. image {
  118. border-radius: 5px;
  119. width: 100%;
  120. height: 100%;
  121. flex: 1;
  122. }
  123. }
  124. }
  125. </style>