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

188 lines
3.5 KiB

  1. <template>
  2. <view class="review-page">
  3. <!-- 顶部导航栏 -->
  4. <navbar title="写书评" :leftClick="true" @leftClick="goBack" />
  5. <view class="review-content">
  6. <view class="book-title-label">书本名称</view>
  7. <view class="book-title">{{ bookTitle }}</view>
  8. <view class="form-area flex-grow">
  9. <view class="form-label-row">
  10. <text class="required-star">*</text>
  11. <text class="form-label">书评内容</text>
  12. </view>
  13. <textarea v-model="form.content" class="review-textarea custom-placeholder full-textarea"
  14. placeholder="请输入书评内容" />
  15. </view>
  16. </view>
  17. <view class="review-footer">
  18. <view class="footer-divider"></view>
  19. <button class="submit-btn" @click="submitReview">发布</button>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import navbar from '@/components/base/navbar.vue'
  25. export default {
  26. components: {
  27. navbar
  28. },
  29. data() {
  30. return {
  31. bookTitle: '',
  32. form: {
  33. content: ''
  34. },
  35. rules: {
  36. content: [{
  37. required: true,
  38. message: '请输入书评内容',
  39. trigger: ['blur', 'change']
  40. }]
  41. }
  42. }
  43. },
  44. onLoad(options) {
  45. // 通过路由参数获取书名
  46. this.bookTitle = options.title || '未知书名'
  47. },
  48. methods: {
  49. goBack() {
  50. uni.navigateBack()
  51. },
  52. submitReview() {
  53. this.$refs.reviewForm.validate().then(() => {
  54. // 提交逻辑,实际开发中可调用API
  55. uni.showToast({
  56. title: '发布成功',
  57. icon: 'success'
  58. })
  59. setTimeout(() => {
  60. uni.navigateBack()
  61. }, 1000)
  62. }).catch(() => {})
  63. }
  64. }
  65. }
  66. </script>
  67. <style scoped lang="scss">
  68. .review-page {
  69. min-height: 100vh;
  70. background: #f8f8f8;
  71. display: flex;
  72. flex-direction: column;
  73. margin-top: -50rpx;
  74. }
  75. .review-content {
  76. background: #fff;
  77. margin: 24rpx 24rpx 0 24rpx;
  78. border-radius: 16rpx;
  79. padding: 32rpx 24rpx 24rpx 24rpx;
  80. display: flex;
  81. flex-direction: column;
  82. flex: 1;
  83. min-height: 0;
  84. padding-bottom: 140rpx;
  85. margin-top: calc(var(--status-bar-height, 0px) + 100rpx);
  86. }
  87. .flex-grow {
  88. flex: 1 1 0;
  89. display: flex;
  90. flex-direction: column;
  91. min-height: 0;
  92. }
  93. .book-title-label {
  94. color: #bdbdbd;
  95. font-size: 24rpx;
  96. margin-bottom: 4rpx;
  97. }
  98. .book-title {
  99. font-size: 28rpx;
  100. color: #222;
  101. margin-bottom: 36rpx;
  102. border-bottom: 1px solid #ededed;
  103. padding-bottom: 8rpx;
  104. }
  105. .form-area {
  106. margin-top: 18rpx;
  107. }
  108. .form-label-row {
  109. display: flex;
  110. align-items: center;
  111. margin-bottom: 8rpx;
  112. }
  113. .required-star {
  114. color: #e23d3d;
  115. font-size: 22rpx;
  116. margin-right: 4rpx;
  117. line-height: 1;
  118. }
  119. .form-label {
  120. color: #222;
  121. font-size: 26rpx;
  122. font-weight: 400;
  123. }
  124. .review-textarea {
  125. width: 100%;
  126. min-height: 320rpx;
  127. border: none;
  128. background: transparent;
  129. font-size: 28rpx;
  130. color: #333;
  131. resize: none;
  132. margin-top: 0;
  133. outline: none;
  134. }
  135. .review-textarea.custom-placeholder::placeholder {
  136. color: #d2d2d2;
  137. font-size: 26rpx;
  138. }
  139. .full-textarea {
  140. flex: 1;
  141. min-height: 0;
  142. max-height: none;
  143. box-sizing: border-box;
  144. margin-bottom: 0;
  145. }
  146. .review-footer {
  147. position: fixed;
  148. left: 0;
  149. right: 0;
  150. bottom: 90rpx;
  151. background: #fff;
  152. padding: 24rpx 32rpx 32rpx 32rpx;
  153. box-shadow: 0 -2rpx 12rpx rgba(0, 0, 0, 0.03);
  154. z-index: 10;
  155. }
  156. .footer-divider {
  157. width: 100%;
  158. height: 2rpx;
  159. background: #f2f2f2;
  160. margin-bottom: 24rpx;
  161. }
  162. .submit-btn {
  163. width: 100%;
  164. height: 80rpx;
  165. background: #0a225f;
  166. color: #fff;
  167. font-size: 30rpx;
  168. border-radius: 40rpx;
  169. font-weight: 500;
  170. letter-spacing: 2rpx;
  171. }
  172. </style>