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

234 lines
4.3 KiB

  1. <template>
  2. <uv-popup ref="popup" :round="30" :customStyle="{height: '70vh'}">
  3. <view class="catalog-popup-fullscreen">
  4. <view class="catalog-header">
  5. <view class="header-left" @click.stop="close">
  6. <uv-icon name="arrow-down" size="46" color="#333"/>
  7. </view>
  8. <view class="header-title">目录</view>
  9. <view class="header-right" @click.stop="orderAsc = !orderAsc">倒序</view>
  10. </view>
  11. <scroll-view scroll-y class="catalog-list">
  12. <view v-for="(item, idx) in (orderAsc ? chapterList : [...chapterList].reverse())" :key="item.id"
  13. @click="selectChapter(orderAsc ? idx : chapterList.length - 1 - idx)"
  14. :class="['catalog-item', {active: (orderAsc ? idx : chapterList.length - 1 - idx) === currentIndex}]">
  15. <view class="item-main">
  16. <text class="item-title">{{ item.title }}</text>
  17. <text v-if="item.vip" class="vip-tag">付费</text>
  18. </view>
  19. </view>
  20. </scroll-view>
  21. </view>
  22. </uv-popup>
  23. </template>
  24. <script>
  25. export default {
  26. data() {
  27. return {
  28. chapterCount: 2814,
  29. orderAsc : true,
  30. currentIndex : 0,
  31. chapterList: [{
  32. id: 1,
  33. title: '第一章 重回2004',
  34. vip: false
  35. },
  36. {
  37. id: 2,
  38. title: '第二章 陈年旧恨',
  39. vip: false
  40. },
  41. {
  42. id: 3,
  43. title: '第三章 再相见',
  44. vip: false
  45. },
  46. {
  47. id: 4,
  48. title: '第四章 李东的邀请',
  49. vip: false
  50. },
  51. {
  52. id: 5,
  53. title: '第五章 小气的男',
  54. vip: false
  55. },
  56. {
  57. id: 6,
  58. title: '第六章 先送谁?',
  59. vip: false
  60. },
  61. {
  62. id: 7,
  63. title: '第七章 打听行情',
  64. vip: false
  65. },
  66. {
  67. id: 8,
  68. title: '第八章 省城探路',
  69. vip: false
  70. },
  71. {
  72. id: 9,
  73. title: '第九章 订货',
  74. vip: false
  75. },
  76. {
  77. id: 10,
  78. title: '第十章 第一桶金',
  79. vip: true
  80. },
  81. {
  82. id: 11,
  83. title: '第十一章 高富帅来袭',
  84. vip: true
  85. },
  86. {
  87. id: 12,
  88. title: '第十二章 故学后,挥场见!',
  89. vip: true
  90. },
  91. {
  92. id: 13,
  93. title: '第十三章 你来我往',
  94. vip: true
  95. },
  96. {
  97. id: 14,
  98. title: '第十四章 你来我往',
  99. vip: true
  100. },
  101. {
  102. id: 15,
  103. title: '第十五章 你来我往',
  104. vip: true
  105. },
  106. {
  107. id: 16,
  108. title: '第十六章 你来我往',
  109. vip: true
  110. },
  111. {
  112. id: 17,
  113. title: '第十七章 你来我往',
  114. vip: true
  115. },
  116. {
  117. id: 18,
  118. title: '第十八章 你来我往',
  119. vip: true
  120. }
  121. ]
  122. }
  123. },
  124. methods: {
  125. open() {
  126. this.$refs.popup.open('bottom')
  127. },
  128. close() {
  129. this.$refs.popup.close()
  130. },
  131. selectChapter(){
  132. },
  133. selectChapter(idx) {
  134. this.currentIndex = idx
  135. this.showCatalog = false
  136. // TODO: 跳转到对应章节内容
  137. },
  138. }
  139. }
  140. </script>
  141. <style scoped lang="scss">
  142. .catalog-popup-fullscreen {
  143. position: relative;
  144. height: 100%;
  145. width: 100vw;
  146. background: #fff;
  147. display: flex;
  148. flex-direction: column;
  149. overflow: hidden;
  150. .catalog-header {
  151. display: flex;
  152. align-items: center;
  153. justify-content: space-between;
  154. padding: 0 24rpx;
  155. height: 96rpx;
  156. border-bottom: 1px solid #eee;
  157. position: sticky;
  158. top: 0;
  159. background: #fff;
  160. z-index: 2;
  161. }
  162. .header-left {
  163. width: 60rpx;
  164. display: flex;
  165. align-items: center;
  166. justify-content: flex-start;
  167. }
  168. .header-title {
  169. flex: 1;
  170. text-align: center;
  171. font-size: 32rpx;
  172. font-weight: bold;
  173. color: #222;
  174. }
  175. .header-right {
  176. color: #223a7a;
  177. font-size: 28rpx;
  178. font-weight: 500;
  179. min-width: 80rpx;
  180. text-align: right;
  181. }
  182. .catalog-list {
  183. height: calc(100% - 180rpx);
  184. overflow: auto;
  185. padding-bottom: 40rpx;
  186. }
  187. .catalog-item {
  188. padding: 0 32rpx;
  189. min-height: 80rpx;
  190. display: flex;
  191. flex-direction: column;
  192. justify-content: center;
  193. border-bottom: 1px solid #f5f5f5;
  194. background: #fff;
  195. color: #222;
  196. font-size: 30rpx;
  197. position: relative;
  198. }
  199. .catalog-item.active {
  200. color: #ff5a5f;
  201. background: #fff7f7;
  202. }
  203. .item-main {
  204. display: flex;
  205. align-items: center;
  206. gap: 16rpx;
  207. }
  208. .item-title {
  209. font-size: 30rpx;
  210. }
  211. .vip-tag {
  212. background: #ffe1b2;
  213. color: #ff9900;
  214. border-radius: 20rpx;
  215. font-size: 24rpx;
  216. padding: 2rpx 18rpx;
  217. margin-left: 16rpx;
  218. }
  219. }
  220. </style>