小说小程序前端代码仓库(小程序)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

216 lines
4.5 KiB

  1. <template>
  2. <view class="chapter-popup-container" :class="{'dark-mode': isDarkMode}">
  3. <uv-popup ref="popup" :round="30" :customStyle="popupStyle">
  4. <view class="catalog-popup-fullscreen theme-transition">
  5. <view class="catalog-header theme-transition">
  6. <view class="header-left" @click.stop="close">
  7. <uv-icon name="arrow-down" size="46" :color="isDarkMode ? '#ccc' : '#333'"/>
  8. </view>
  9. <view class="header-title theme-transition">目录</view>
  10. <view class="header-right theme-transition" @click.stop="orderAsc = !orderAsc">倒序</view>
  11. </view>
  12. <scroll-view scroll-y class="catalog-list">
  13. <view v-for="(item, idx) in (orderAsc ? chapterList : [...chapterList].reverse())" :key="item.id"
  14. @click="selectChapter(item, idx)"
  15. :class="['catalog-item theme-transition', {active: idx == currentIndex}]">
  16. <view class="item-main">
  17. <text class="item-title theme-transition">{{ item.title }}</text>
  18. <text v-if="item.vip == 'Y'" class="vip-tag theme-transition">付费</text>
  19. </view>
  20. </view>
  21. <uv-empty mode="list" v-if="chapterList.length == 0"></uv-empty>
  22. </scroll-view>
  23. </view>
  24. </uv-popup>
  25. </view>
  26. </template>
  27. <script>
  28. import themeMixin from '@/mixins/themeMode.js'
  29. export default {
  30. props : {
  31. 'bookId' : {
  32. default : 0
  33. },
  34. 'currentIndex' : {
  35. // default : 0
  36. },
  37. 'chapterList' : {
  38. default : []
  39. }
  40. },
  41. mixins: [themeMixin],
  42. data() {
  43. return {
  44. chapterCount: 2814,
  45. orderAsc : true,
  46. // chapterList: [],
  47. }
  48. },
  49. computed: {
  50. popupStyle() {
  51. return {
  52. height: '70vh',
  53. background: this.isDarkMode ? '#222' : '#fff'
  54. }
  55. }
  56. },
  57. methods: {
  58. open() {
  59. this.$refs.popup.open('bottom')
  60. // 获取章节
  61. // this.$fetch('getBookCatalogList', {
  62. // bookId : this.bookId,
  63. // pageNo : 1,
  64. // pageSize : 9999999,
  65. // reverse : this.orderAsc ? 1 : 0,
  66. // }).then(res => {
  67. // this.chapterList = res.records
  68. // })
  69. },
  70. close() {
  71. this.$refs.popup.close()
  72. },
  73. selectChapter(item, index) {
  74. this.close()
  75. this.$emit('selectChapter', {item, index})
  76. },
  77. }
  78. }
  79. </script>
  80. <style scoped lang="scss">
  81. .chapter-popup-container {
  82. .catalog-popup-fullscreen {
  83. position: relative;
  84. height: 100%;
  85. width: 100vw;
  86. background: #fff;
  87. display: flex;
  88. flex-direction: column;
  89. overflow: hidden;
  90. .catalog-header {
  91. display: flex;
  92. align-items: center;
  93. justify-content: space-between;
  94. padding: 0 24rpx;
  95. height: 96rpx;
  96. border-bottom: 1px solid #eee;
  97. position: sticky;
  98. top: 0;
  99. background: #fff;
  100. z-index: 2;
  101. }
  102. .header-left {
  103. width: 60rpx;
  104. display: flex;
  105. align-items: center;
  106. justify-content: flex-start;
  107. }
  108. .header-title {
  109. flex: 1;
  110. text-align: center;
  111. font-size: 32rpx;
  112. font-weight: bold;
  113. color: #222;
  114. }
  115. .header-right {
  116. color: #223a7a;
  117. font-size: 28rpx;
  118. font-weight: 500;
  119. min-width: 80rpx;
  120. text-align: right;
  121. }
  122. .catalog-list {
  123. height: calc(100% - 180rpx);
  124. overflow: auto;
  125. padding-bottom: 40rpx;
  126. }
  127. .catalog-item {
  128. padding: 0 32rpx;
  129. min-height: 80rpx;
  130. display: flex;
  131. flex-direction: column;
  132. justify-content: center;
  133. border-bottom: 1px solid #f5f5f5;
  134. background: #fff;
  135. color: #222;
  136. font-size: 30rpx;
  137. position: relative;
  138. }
  139. .catalog-item.active {
  140. color: #ff5a5f;
  141. background: #fff7f7;
  142. }
  143. .item-main {
  144. display: flex;
  145. align-items: center;
  146. gap: 16rpx;
  147. }
  148. .item-title {
  149. font-size: 30rpx;
  150. }
  151. .vip-tag {
  152. background: #ffe1b2;
  153. color: #ff9900;
  154. border-radius: 20rpx;
  155. font-size: 24rpx;
  156. padding: 2rpx 18rpx;
  157. margin-left: 16rpx;
  158. }
  159. }
  160. }
  161. /* 暗色主题样式 */
  162. .chapter-popup-container.dark-mode {
  163. .catalog-popup-fullscreen {
  164. background: $dark-bg-color-secondary;
  165. .catalog-header {
  166. background: $dark-bg-color-secondary;
  167. border-bottom: 1px solid $dark-border-color;
  168. .header-title {
  169. color: $dark-text-color-primary;
  170. }
  171. .header-right {
  172. color: $dark-accent-color;
  173. }
  174. }
  175. .catalog-list {
  176. .catalog-item {
  177. background: $dark-bg-color-secondary;
  178. color: $dark-text-color-secondary;
  179. border-bottom: 1px solid $dark-border-color;
  180. &.active {
  181. color: #ff5a5f;
  182. background: rgba(255, 90, 95, 0.1);
  183. }
  184. .item-title {
  185. color: $dark-text-color-secondary;
  186. }
  187. .vip-tag {
  188. background: rgba(255, 153, 0, 0.2);
  189. color: #ff9900;
  190. }
  191. }
  192. }
  193. }
  194. }
  195. </style>