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

181 lines
3.6 KiB

  1. <template>
  2. <view class="chapter-container">
  3. <navbar title="章节列表" leftClick @leftClick="$utils.navigateBack"/>
  4. <view class="tabs">
  5. <uv-tabs :list="tabs"
  6. :activeStyle="{color : '#0A2463', fontWeight : 600}"
  7. lineColor="#0A2463"
  8. :inactiveStyle="{color: '#0A2463'}"
  9. lineHeight="8rpx"
  10. lineWidth="50rpx"
  11. :scrollable="false"
  12. :current="activeTab"
  13. @click="clickTabs"></uv-tabs>
  14. </view>
  15. <view class="chapter-list">
  16. <view class="chapter-item" v-for="(chapter, index) in chapters" :key="index" @click="editChapter(chapter)">
  17. <view class="chapter-info">
  18. <text class="chapter-title">章节名</text>
  19. <text class="chapter-number">{{index + 1}}</text>
  20. </view>
  21. <uv-icon name="arrow-right" color="#999" size="28"></uv-icon>
  22. </view>
  23. </view>
  24. <view class="bottom-actions">
  25. <button class="btn-settings" @click="handleSettings">设置作品</button>
  26. <button class="btn-new" @click="addNewChapter">新建章节</button>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import BackArrow from './components/BackArrow.vue';
  32. export default {
  33. components: {
  34. BackArrow,
  35. },
  36. data() {
  37. return {
  38. tabs : [
  39. {
  40. name : '已发布',
  41. },
  42. {
  43. name : '草稿箱',
  44. }
  45. ],
  46. activeTab: 0,
  47. chapters: [] // 真实章节数据
  48. }
  49. },
  50. onLoad(options) {
  51. // 根据tab参数决定初始tab
  52. if (options.activeTab) {
  53. this.activeTab = options.activeTab;
  54. }
  55. this.loadChapters();
  56. // 判断是否需要弹窗
  57. if (options && options.fromSave === '1') {
  58. uni.showToast({
  59. title: '保存成功',
  60. icon: 'success'
  61. });
  62. }
  63. if (options && options.fromPublish === '1') {
  64. uni.showToast({
  65. title: '发布成功',
  66. icon: 'success'
  67. });
  68. }
  69. },
  70. methods: {
  71. loadChapters() {
  72. if (this.activeTab === 'published') {
  73. this.chapters = uni.getStorageSync('publishedChapters') || [];
  74. } else {
  75. this.chapters = uni.getStorageSync('chapters') || [];
  76. }
  77. },
  78. goBack() {
  79. uni.navigateBack()
  80. },
  81. clickTabs(tab) {
  82. this.activeTab = tab.index;
  83. },
  84. addNewChapter() {
  85. uni.navigateTo({
  86. url: '/pages_order/author/editor'
  87. })
  88. },
  89. editChapter(chapter) {
  90. uni.navigateTo({
  91. url: '/pages_order/author/editor?id=' + chapter.id
  92. })
  93. },
  94. handleSettings() {
  95. uni.navigateTo({
  96. url: '/pages_order/novel/createNovel?type=edit'
  97. })
  98. }
  99. }
  100. }
  101. </script>
  102. <style lang="scss" scoped>
  103. .chapter-container {
  104. min-height: 100vh;
  105. background-color: #fff;
  106. padding-bottom: 70px;
  107. .chapter-list {
  108. padding: 20rpx 40rpx;
  109. background-color: rgb(255, 254, 254);
  110. margin: 50rpx 40rpx;
  111. border-radius: 3%;
  112. .chapter-item {
  113. display: flex;
  114. justify-content: space-between;
  115. align-items: center;
  116. padding: 15px 0;
  117. border-bottom: 1px solid #eee;
  118. .chapter-info {
  119. .chapter-title {
  120. font-size: 14px;
  121. color: #999;
  122. margin-bottom: 5px;
  123. display: block;
  124. }
  125. .chapter-number {
  126. font-size: 16px;
  127. color: #333;
  128. display: block;
  129. }
  130. }
  131. .icon-arrow {
  132. color: #999;
  133. font-size: 16px;
  134. }
  135. }
  136. }
  137. .bottom-actions {
  138. padding-bottom: calc(env(safe-area-inset-bottom) + 30rpx);
  139. position: fixed;
  140. bottom: 0;
  141. left: 0;
  142. right: 0;
  143. display: flex;
  144. padding: 10px 15px;
  145. background: #fff;
  146. box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.05);
  147. button {
  148. flex: 1;
  149. height: 40px;
  150. border-radius: 20px;
  151. font-size: 16px;
  152. margin: 0 5px;
  153. &.btn-settings {
  154. background: #fff;
  155. border: 1px solid #ddd;
  156. color: #333;
  157. }
  158. &.btn-new {
  159. background: #2b4acb;
  160. color: #fff;
  161. border: none;
  162. }
  163. }
  164. }
  165. }
  166. </style>