裂变星小程序-25.03.04
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.

185 lines
5.2 KiB

  1. <template>
  2. <view class="page">
  3. <navbar title="文章分享" leftClick @leftClick="$utils.navigateBack" />
  4. <view class="content">
  5. <uv-form
  6. ref="form"
  7. :model="form"
  8. :rules="rules"
  9. labelPosition="left"
  10. labelWidth="300rpx"
  11. :labelStyle="{
  12. color: '#1B1B1B',
  13. fontSize: '32rpx',
  14. fontWeight: 'bold',
  15. }"
  16. >
  17. <view class="form-item">
  18. <uv-form-item label="用户ID" prop="id">
  19. <view class="form-item-content">
  20. <template v-if="form.id">
  21. <text>{{ form.id }}</text>
  22. <view style="margin-left: 20rpx;">
  23. <button class="btn-simple" plain @click="$utils.copyText(form.id)">
  24. <uv-icon name="file-text" color="#05D9A2" size="28rpx"></uv-icon>
  25. </button>
  26. </view>
  27. </template>
  28. </view>
  29. </uv-form-item>
  30. </view>
  31. <view class="form-item">
  32. <uv-form-item label="选择封面图" prop="imageUrl">
  33. <view class="form-item-content">
  34. <formUpload v-model="form.imageUrl">
  35. <template v-slot="{ value }">
  36. <view class="flex" style="min-width: 116rpx; height: 45rpx;">
  37. <image
  38. :src="value"
  39. mode="aspectFill"
  40. style="width: 68rpx; height: 68rpx;"
  41. radius="14rpx"
  42. />
  43. <uv-icon style="margin-left: 20rpx" name="arrow-right" color="#000000" size="28rpx"></uv-icon>
  44. </view>
  45. </template>
  46. </formUpload>
  47. </view>
  48. </uv-form-item>
  49. </view>
  50. <view class="form-item">
  51. <uv-form-item label="标题" labelWidth="84rpx" prop="title">
  52. <view class="form-item-content">
  53. <formInput v-model="form.title" placeholder="请输入你的文章标题" width="584rpx"></formInput>
  54. </view>
  55. </uv-form-item>
  56. </view>
  57. <view class="form-item">
  58. <uv-form-item label="设置转发次数(次)" prop="times">
  59. <view class="form-item-content">
  60. <formNumberBox v-model="form.times" ></formNumberBox>
  61. </view>
  62. </uv-form-item>
  63. </view>
  64. <view class="form-item">
  65. <uv-form-item label="选择二维码" prop="qrCode">
  66. <view class="form-item-content">
  67. <formUpload v-model="form.qrCode">
  68. <template v-slot="{ value }">
  69. <view class="flex" style="min-width: 93rpx; height: 45rpx;">
  70. <image
  71. :src="value"
  72. mode="aspectFill"
  73. style="width: 45rpx; height: 45rpx;"
  74. radius="14rpx"
  75. />
  76. <uv-icon style="margin-left: 20rpx" name="arrow-right" color="#000000" size="28rpx"></uv-icon>
  77. </view>
  78. </template>
  79. </formUpload>
  80. </view>
  81. </uv-form-item>
  82. </view>
  83. <view class="form-item">
  84. <uv-form-item label="文章内容" prop="description" labelPosition="top">
  85. <view style="margin-top: 32rpx;">
  86. <editor id="editor" class="editor"
  87. @ready="onEditorReady"
  88. ></editor>
  89. <button @click="insertImage" class="btn-insert-image">
  90. <uv-icon name="plus" color="#707070" size="48rpx"></uv-icon>
  91. </button>
  92. </view>
  93. </uv-form-item>
  94. </view>
  95. </uv-form>
  96. </view>
  97. <button class="button-submit" @click="onSubmit">
  98. 提交审核
  99. </button>
  100. </view>
  101. </template>
  102. <script>
  103. import formInput from '../components/formInput.vue'
  104. import formNumberBox from '../components/formNumberBox.vue'
  105. import formUpload from '../components/formUpload.vue'
  106. import formTextarea from '../components/formTextarea.vue'
  107. export default {
  108. components: {
  109. formInput,
  110. formNumberBox,
  111. formUpload,
  112. formTextarea,
  113. },
  114. data() {
  115. return {
  116. form: {
  117. id: null,
  118. imageUrl: null,
  119. title: null,
  120. times: 10,
  121. qrCode: null,
  122. description: null,
  123. },
  124. rules: {
  125. // todo
  126. },
  127. editorCtx: null,
  128. }
  129. },
  130. methods: {
  131. onEditorReady() {
  132. uni.createSelectorQuery().select('#editor').context((res) => {
  133. this.editorCtx = res.context
  134. }).exec()
  135. },
  136. insertImage() {
  137. uni.chooseImage({
  138. count: 1,
  139. success: (res) => {
  140. this.editorCtx.insertImage({
  141. src: res.tempFilePaths[0],
  142. alt: '图像',
  143. })
  144. }
  145. })
  146. },
  147. onSubmit() {
  148. // todo
  149. const params = { ...this.form }
  150. this.$api('submitPersonalSharing', params)
  151. },
  152. }
  153. }
  154. </script>
  155. <style scoped lang="scss">
  156. @import '../styles/pageForm.scss';
  157. .editor {
  158. height: 411rpx;
  159. }
  160. .btn-simple {
  161. width: auto;
  162. height: auto;
  163. border: none;
  164. box-shadow: none;
  165. padding: 0;
  166. }
  167. .button-submit {
  168. margin: 0;
  169. position: fixed;
  170. bottom: 138rpx;
  171. left: 20rpx;
  172. width: calc(100% - 40rpx);
  173. height: 90rpx;
  174. }
  175. </style>