小说小程序前端代码仓库(小程序)
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.

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