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

189 lines
4.1 KiB

  1. <template>
  2. <view class="chapter-container">
  3. <view class="header">
  4. <view class="nav-bar">
  5. <view class="back" @click="goBack">
  6. <text class="iconfont icon-back">&#xe60e;</text>
  7. </view>
  8. <view class="tabs">
  9. <view class="tab" :class="{ active: activeTab === 'draft' }" @click="switchTab('draft')">草稿箱</view>
  10. <view class="tab" :class="{ active: activeTab === 'published' }" @click="switchTab('published')">已发布</view>
  11. </view>
  12. <view class="more">
  13. <text class="iconfont">&#xe612;</text>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="chapter-list">
  18. <view class="chapter-item" v-for="(chapter, index) in chapters" :key="index" @click="editChapter(chapter)">
  19. <view class="chapter-info">
  20. <text class="chapter-title">章节名</text>
  21. <text class="chapter-number">{{index + 1}}</text>
  22. </view>
  23. <text class="iconfont icon-arrow">&#xe65f;</text>
  24. </view>
  25. </view>
  26. <view class="bottom-actions">
  27. <button class="btn-settings" @click="handleSettings">设置作品</button>
  28. <button class="btn-new" @click="addNewChapter">新建章节</button>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. data() {
  35. return {
  36. activeTab: 'draft',
  37. chapters: Array(8).fill({}) // 模拟8个章节数据
  38. }
  39. },
  40. methods: {
  41. goBack() {
  42. uni.navigateBack()
  43. },
  44. switchTab(tab) {
  45. this.activeTab = tab
  46. // 根据tab加载不同的章节列表
  47. },
  48. addNewChapter() {
  49. uni.navigateTo({
  50. url: '/pages_order/author/editor'
  51. })
  52. },
  53. editChapter(chapter) {
  54. uni.navigateTo({
  55. url: '/pages_order/author/editor?id=' + chapter.id
  56. })
  57. },
  58. handleSettings() {
  59. uni.navigateTo({
  60. url: '/pages_order/novel/createNovel?type=edit'
  61. })
  62. }
  63. }
  64. }
  65. </script>
  66. <style lang="scss" scoped>
  67. .chapter-container {
  68. min-height: 100vh;
  69. background-color: #fff;
  70. padding-bottom: 70px;
  71. .header {
  72. background: #fff;
  73. padding-top: var(--status-bar-height);
  74. .nav-bar {
  75. height: 44px;
  76. display: flex;
  77. align-items: center;
  78. justify-content: space-between;
  79. padding: 0 15px;
  80. .back {
  81. padding: 5px;
  82. .icon-back {
  83. font-size: 20px;
  84. }
  85. }
  86. .tabs {
  87. display: flex;
  88. .tab {
  89. padding: 0 15px;
  90. font-size: 16px;
  91. color: #666;
  92. position: relative;
  93. &.active {
  94. color: #000;
  95. font-weight: bold;
  96. &::after {
  97. content: '';
  98. position: absolute;
  99. bottom: -4px;
  100. left: 50%;
  101. transform: translateX(-50%);
  102. width: 20px;
  103. height: 2px;
  104. background: #2b4acb;
  105. border-radius: 1px;
  106. }
  107. }
  108. }
  109. }
  110. .more {
  111. padding: 5px;
  112. }
  113. }
  114. }
  115. .chapter-list {
  116. padding: 0 15px;
  117. .chapter-item {
  118. display: flex;
  119. justify-content: space-between;
  120. align-items: center;
  121. padding: 15px 0;
  122. border-bottom: 1px solid #eee;
  123. .chapter-info {
  124. .chapter-title {
  125. font-size: 14px;
  126. color: #999;
  127. margin-bottom: 5px;
  128. display: block;
  129. }
  130. .chapter-number {
  131. font-size: 16px;
  132. color: #333;
  133. display: block;
  134. }
  135. }
  136. .icon-arrow {
  137. color: #999;
  138. font-size: 16px;
  139. }
  140. }
  141. }
  142. .bottom-actions {
  143. position: fixed;
  144. bottom: 0;
  145. left: 0;
  146. right: 0;
  147. display: flex;
  148. padding: 10px 15px;
  149. background: #fff;
  150. box-shadow: 0 -2px 6px rgba(0,0,0,0.05);
  151. button {
  152. flex: 1;
  153. height: 40px;
  154. border-radius: 20px;
  155. font-size: 16px;
  156. margin: 0 5px;
  157. &.btn-settings {
  158. background: #fff;
  159. border: 1px solid #ddd;
  160. color: #333;
  161. }
  162. &.btn-new {
  163. background: #2b4acb;
  164. color: #fff;
  165. border: none;
  166. }
  167. }
  168. }
  169. }
  170. </style>