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

154 lines
3.1 KiB

  1. <template>
  2. <!-- 申请成为作者页面 -->
  3. <view class="creator-page">
  4. <navbar title="请成为创作者" leftClick @leftClick="$utils.navigateBack" />
  5. <view class="form-card">
  6. <view class="form-item">
  7. <text class="label">笔名</text>
  8. <input v-model="form.name" placeholder="请输入" class="input" placeholder-class="input-placeholder" />
  9. </view>
  10. <view class="form-item">
  11. <text class="label">简介</text>
  12. <textarea v-model="form.details" placeholder="请输入" class="textarea" placeholder-class="input-placeholder" />
  13. </view>
  14. </view>
  15. <view class="footer-btn-area">
  16. <button class="submit-btn" @click="submit">成为创作者</button>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. components: {
  23. },
  24. data() {
  25. return {
  26. form : {
  27. name : '',
  28. details : '',
  29. },
  30. }
  31. },
  32. onLoad() {
  33. this.getMyWriter()
  34. },
  35. methods: {
  36. submit() {
  37. if (!this.form.name) {
  38. uni.showToast({ title: '请输入笔名', icon: 'none' })
  39. return
  40. }
  41. if (!this.form.details) {
  42. uni.showToast({ title: '请输入简介', icon: 'none' })
  43. return
  44. }
  45. let data = {
  46. penName : this.form.name,
  47. details : this.form.details,
  48. }
  49. if(this.form.id){
  50. data.id = this.form.id
  51. }
  52. this.$api('saveOrUpdateWriter', data, res => {
  53. if(res.code == 200){
  54. uni.showToast({ title: '申请成功', icon: 'success' })
  55. setTimeout(() => {
  56. uni.navigateBack()
  57. }, 800)
  58. }
  59. })
  60. },
  61. getMyWriter(){
  62. this.$api('getMyWriter')
  63. .then(res => {
  64. if(res.result){
  65. this.form = res.result
  66. }
  67. })
  68. },
  69. }
  70. }
  71. </script>
  72. <style scoped lang="scss">
  73. .creator-page {
  74. min-height: 100vh;
  75. background: #f7f8fa;
  76. display: flex;
  77. flex-direction: column;
  78. }
  79. .form-card {
  80. background: #fff;
  81. border-radius: 20rpx;
  82. margin: 40rpx 32rpx 0 32rpx;
  83. padding: 32rpx 24rpx;
  84. box-shadow: 0 4rpx 24rpx 0 rgba(0, 0, 0, 0.04);
  85. }
  86. .form-item {
  87. display: flex;
  88. flex-direction: column;
  89. margin-bottom: 32rpx;
  90. position: relative;
  91. }
  92. .label {
  93. font-size: 28rpx;
  94. color: #222;
  95. font-weight: bold;
  96. margin-bottom: 12rpx;
  97. &::before{
  98. content: '*';
  99. color: #e23d3d;
  100. font-size: 28rpx;
  101. }
  102. }
  103. .input,
  104. .textarea {
  105. width: 100%;
  106. height: 80rpx;
  107. border: none;
  108. border-bottom: 1.5rpx solid #ececec;
  109. font-size: 28rpx;
  110. background: transparent;
  111. padding: 18rpx 0 12rpx 0;
  112. margin-bottom: 2rpx;
  113. }
  114. .input-placeholder {
  115. color: #d2d2d2;
  116. font-size: 26rpx;
  117. }
  118. .textarea {
  119. min-height: 120rpx;
  120. resize: none;
  121. }
  122. .footer-btn-area {
  123. margin-top: auto;
  124. padding: 48rpx 32rpx 32rpx 32rpx;
  125. background: transparent;
  126. margin-bottom: 80rpx;
  127. }
  128. .submit-btn {
  129. width: 100%;
  130. height: 88rpx;
  131. background: #0a2e6d;
  132. color: #fff;
  133. font-size: 32rpx;
  134. border-radius: 44rpx;
  135. font-weight: bold;
  136. letter-spacing: 2rpx;
  137. transition: background 0.2s;
  138. }
  139. </style>