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

230 lines
5.2 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="box">
  16. <view class="chapter-list" >
  17. <view class="draft-header">
  18. <text class="draft-title">{{ activeTab === 0 ? '草稿箱章节' : '已发布章节' }}</text>
  19. <text class="delete-btn" @click="reverseList">{{ queryParams.reverse ? '正序' : '倒序' }}</text>
  20. </view>
  21. <view
  22. class="chapter-item"
  23. v-for="(chapter, index) in list"
  24. :key="chapter.id"
  25. @click="editChapter(chapter)">
  26. <view class="chapter-info">
  27. <text class="chapter-title">章节名</text>
  28. <text class="chapter-number">{{ chapter.title }}</text>
  29. </view>
  30. <uv-icon name="arrow-right" color="#999" size="28"></uv-icon>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="bottom-actions">
  35. <button class="btn-settings" @click="handleSettings">设置作品</button>
  36. <button class="btn-new" @click="addNewChapter">新建章节</button>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import mixinsList from '@/mixins/list.js'
  42. export default {
  43. mixins: [mixinsList],
  44. components: {
  45. },
  46. data() {
  47. return {
  48. tabs : [
  49. {
  50. name : '草稿箱',
  51. index : 1
  52. },
  53. {
  54. name : '已发布',
  55. index : 0
  56. }
  57. ],
  58. activeTab: 0,
  59. mixinsListApi : 'getMyShopNovelPage',
  60. id : 0,
  61. }
  62. },
  63. onLoad(options) {
  64. this.queryParams.reverse = 0
  65. // 根据tab参数决定初始tab
  66. if (options.activeTab) {
  67. this.activeTab = options.activeTab;
  68. }
  69. if(options.id){
  70. this.queryParams.bookId = options.id
  71. this.id = options.id
  72. this.queryParams.status = this.activeTab
  73. }
  74. },
  75. methods: {
  76. clickTabs(tab) {
  77. this.activeTab = tab.index;
  78. this.queryParams.status = this.activeTab
  79. this.list = []
  80. this.getData()
  81. },
  82. reverseList() {
  83. this.queryParams.reverse = [1, 0][this.queryParams.reverse]
  84. this.getData()
  85. },
  86. addNewChapter() {
  87. uni.navigateTo({
  88. url: '/pages_order/author/editor?id=' + this.id
  89. })
  90. },
  91. editChapter(chapter) {
  92. uni.navigateTo({
  93. url: '/pages_order/author/editor?cid=' + chapter.id + '&id=' + this.id
  94. })
  95. },
  96. handleSettings() {
  97. uni.navigateTo({
  98. url: '/pages_order/novel/createNovel?id=' + this.id
  99. })
  100. },
  101. deleteAll() {
  102. uni.showModal({
  103. title: '提示',
  104. content: '确定要删除所有草稿章节吗?',
  105. success: (res) => {
  106. if (res.confirm) {
  107. // 调用删除草稿API
  108. this.$api.deleteAllDrafts({bookId: this.id}).then(res => {
  109. if (res.code === 200) {
  110. this.$utils.showToast('删除成功')
  111. this.getData()
  112. }
  113. })
  114. }
  115. }
  116. })
  117. }
  118. }
  119. }
  120. </script>
  121. <style lang="scss" scoped>
  122. .chapter-container {
  123. min-height: 100vh;
  124. background-color: #f7f7f7;
  125. padding-bottom: 70px;
  126. .tabs{
  127. background-color: #fff;
  128. }
  129. .box{
  130. padding: 20rpx 40rpx;
  131. background-color: #fff;
  132. margin: 50rpx 40rpx;
  133. border-radius: 20rpx;
  134. .draft-header {
  135. display: flex;
  136. justify-content: space-between;
  137. align-items: center;
  138. padding-bottom: 20rpx;
  139. border-bottom: 1px dashed #eee;
  140. margin-bottom: 10rpx;
  141. .draft-title {
  142. font-size: 30rpx;
  143. color: #000;
  144. font-weight: 900;
  145. }
  146. .delete-btn {
  147. font-size: 28rpx;
  148. color: #999;
  149. }
  150. }
  151. .chapter-list {
  152. .chapter-item {
  153. display: flex;
  154. justify-content: space-between;
  155. align-items: center;
  156. padding: 15px 0;
  157. border-bottom: 1px solid #eee;
  158. .chapter-info {
  159. .chapter-title {
  160. font-size: 14px;
  161. color: #999;
  162. margin-bottom: 5px;
  163. display: block;
  164. }
  165. .chapter-number {
  166. font-size: 16px;
  167. color: #333;
  168. display: block;
  169. }
  170. }
  171. .icon-arrow {
  172. color: #999;
  173. font-size: 16px;
  174. }
  175. }
  176. }
  177. }
  178. .bottom-actions {
  179. padding-bottom: calc(env(safe-area-inset-bottom) + 30rpx);
  180. position: fixed;
  181. bottom: 0;
  182. left: 0;
  183. right: 0;
  184. display: flex;
  185. padding: 10px 15px;
  186. background: #fff;
  187. box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.05);
  188. button {
  189. flex: 1;
  190. height: 40px;
  191. border-radius: 20px;
  192. font-size: 16px;
  193. margin: 0 5px;
  194. &.btn-settings {
  195. background: #fff;
  196. border: 1px solid #ddd;
  197. color: #333;
  198. }
  199. &.btn-new {
  200. background: #2b4acb;
  201. color: #fff;
  202. border: none;
  203. }
  204. }
  205. }
  206. }
  207. </style>