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

208 lines
3.8 KiB

7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
  1. <template>
  2. <view class="page">
  3. <navbar title="新建章节" leftClick @leftClick="$utils.navigateBack" />
  4. <view class="form-box top-fixed">
  5. <view class="form-item">
  6. <text class="required">*</text>
  7. <text class="label">章节名称</text>
  8. <input class="input"
  9. type="text"
  10. placeholder='请输入章节号与章节名。例如:"第十章天降奇缘"'
  11. v-model="form.title" />
  12. </view>
  13. <view class="form-item">
  14. <text class="required">*</text>
  15. <text class="label">章节内容</text>
  16. <view class="textarea-container">
  17. <!-- <textarea class="textarea"
  18. placeholder="请输入章节内容"
  19. :maxlength="100000"
  20. v-model="form.details" /> -->
  21. <!-- <view class="toolbar">
  22. <view class="indent-btn" @tap="addIndent">缩进</view>
  23. </view> -->
  24. <uv-textarea v-model="form.details"
  25. :maxlength="-1"
  26. autoHeight
  27. class="textarea"
  28. placeholder="请输入章节内容"></uv-textarea>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="footer-btns">
  33. <button class="btn save-btn" @click="onPublish(0)">保存</button>
  34. <button class="btn publish-btn" @click="onPublish(1)">发布</button>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. export default {
  40. data() {
  41. return {
  42. form: {
  43. title: '',
  44. details: '',
  45. },
  46. id : 0,
  47. cid : 0,
  48. }
  49. },
  50. onLoad({id, cid}) {
  51. this.id = id
  52. this.cid = cid || 0
  53. },
  54. methods: {
  55. async onPublish(status) {
  56. let data = {
  57. bookId : this.id,
  58. num : this.form.details.length,
  59. title : this.form.title,
  60. details : this.form.details,
  61. }
  62. if(this.cid){
  63. data.id = this.id
  64. }
  65. if(status == 1){
  66. data.status = status
  67. }
  68. await this.$fetch('saveOrUpdateCatalog', data)
  69. uni.showToast({
  70. title: status ? '发布成功' : '保存成功'
  71. })
  72. setTimeout(uni.navigateBack, 800, -1)
  73. },
  74. }
  75. }
  76. </script>
  77. <style scoped lang="scss">
  78. .page {
  79. min-height: 100vh;
  80. background: #f7f8fa;
  81. display: flex;
  82. flex-direction: column;
  83. }
  84. .form-box {
  85. background: #fff;
  86. margin: 0;
  87. padding: 0 32rpx;
  88. border-radius: 0;
  89. position: relative;
  90. }
  91. .top-fixed {
  92. margin-top: 0;
  93. }
  94. .form-item {
  95. display: flex;
  96. flex-direction: column;
  97. margin-top: 32rpx;
  98. position: relative;
  99. }
  100. .label {
  101. font-size: 28rpx;
  102. color: #222;
  103. margin-bottom: 12rpx;
  104. margin-left: 32rpx;
  105. }
  106. .required {
  107. color: #f44;
  108. position: absolute;
  109. left: 0;
  110. top: 0;
  111. font-size: 32rpx;
  112. }
  113. .input {
  114. border: none;
  115. border-bottom: 1rpx solid #eee;
  116. font-size: 28rpx;
  117. padding: 16rpx 0;
  118. background: transparent;
  119. }
  120. .textarea-container {
  121. position: relative;
  122. line-height: 50rpx;
  123. /deep/ .uv-textarea{
  124. min-height: 70vh;
  125. border: none !important;
  126. font-size: 28rpx;
  127. padding: 16rpx 0;
  128. background: transparent;
  129. resize: none;
  130. width: 100%;
  131. }
  132. }
  133. .textarea {
  134. min-height: 70vh;
  135. border: none;
  136. border-bottom: 1rpx solid #eee;
  137. font-size: 28rpx;
  138. padding: 16rpx 0;
  139. background: transparent;
  140. resize: none;
  141. width: 100%;
  142. }
  143. .toolbar {
  144. display: flex;
  145. padding: 10rpx 0;
  146. margin-top: 10rpx;
  147. }
  148. .indent-btn {
  149. background: #eaeaea;
  150. color: #333;
  151. padding: 8rpx 20rpx;
  152. border-radius: 6rpx;
  153. font-size: 26rpx;
  154. }
  155. .footer-btns {
  156. position: fixed;
  157. left: 0;
  158. bottom: 0;
  159. width: 100vw;
  160. background: #fff;
  161. display: flex;
  162. justify-content: space-between;
  163. padding: 24rpx 48rpx 32rpx 48rpx;
  164. box-sizing: border-box;
  165. z-index: 10;
  166. box-shadow: 0 -2rpx 12rpx rgba(0, 0, 0, 0.03);
  167. }
  168. .btn {
  169. flex: 1;
  170. height: 80rpx;
  171. font-size: 32rpx;
  172. border-radius: 40rpx;
  173. margin: 0 12rpx;
  174. font-weight: 500;
  175. }
  176. .save-btn {
  177. background: #fff;
  178. color: #0a225f;
  179. border: 2rpx solid #0a225f;
  180. }
  181. .publish-btn {
  182. background: #0a225f;
  183. color: #fff;
  184. border: none;
  185. }
  186. </style>