四零语境前端代码仓库
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.

231 lines
5.0 KiB

1 month ago
1 month ago
1 month ago
1 month ago
  1. <template>
  2. <view class="submit-container">
  3. <!-- 主体内容 -->
  4. <view class="main-content">
  5. <!-- 表单卡片 -->
  6. <view class="form-card">
  7. <!-- 标题 -->
  8. <view class="title-section">
  9. <text class="main-title">信息填写</text>
  10. </view>
  11. <!-- 姓名 -->
  12. <view class="form-item">
  13. <text class="form-label">姓名</text>
  14. <uv-input
  15. v-model="formData.name"
  16. placeholder="请输入"
  17. border="bottom"
  18. :custom-style="{
  19. backgroundColor: '#fff',
  20. borderRadius: '12rpx',
  21. paddingLeft: '-24rpx',
  22. fontSize: '32rpx'
  23. }"
  24. ></uv-input>
  25. </view>
  26. <!-- 联系方式 -->
  27. <view class="form-item">
  28. <text class="form-label">联系方式</text>
  29. <uv-input
  30. v-model="formData.phone"
  31. placeholder="请输入"
  32. border="bottom"
  33. :custom-style="{
  34. backgroundColor: '#fff',
  35. paddingLeft: '-24rpx',
  36. fontSize: '32rpx'
  37. }"
  38. ></uv-input>
  39. </view>
  40. <!-- 个人期待 -->
  41. <view class="form-item">
  42. <text class="form-label">个人期待</text>
  43. <uv-textarea
  44. v-model="formData.looking"
  45. placeholder="请输入"
  46. border="bottom"
  47. :auto-height="true"
  48. :custom-style="{
  49. backgroundColor: '#fff',
  50. paddingLeft: '-24rpx',
  51. fontSize: '32rpx',
  52. }"
  53. ></uv-textarea>
  54. </view>
  55. <!-- 文化背景 -->
  56. <view class="form-item">
  57. <text class="form-label">文化背景</text>
  58. <uv-textarea
  59. v-model="formData.background"
  60. placeholder="请输入"
  61. border="none"
  62. :auto-height="true"
  63. :custom-style="{
  64. backgroundColor: '#fff',
  65. paddingLeft: '-24rpx',
  66. fontSize: '32rpx',
  67. }"
  68. ></uv-textarea>
  69. </view>
  70. </view>
  71. </view>
  72. <!-- 底部固定提交栏 -->
  73. <view class="bottom-bar">
  74. <uv-button
  75. type="primary"
  76. text="提交"
  77. :custom-style="{
  78. width: '100%',
  79. height: '82rpx',
  80. borderRadius: '44rpx',
  81. backgroundColor: '#06DADC',
  82. fontSize: '36rpx',
  83. fontWeight: '500',
  84. border: '1px solid #06DADC'
  85. }"
  86. @click="handleSubmit"
  87. ></uv-button>
  88. <uv-safe-bottom></uv-safe-bottom>
  89. </view>
  90. </view>
  91. </template>
  92. <script>
  93. export default {
  94. data() {
  95. return {
  96. formData: {
  97. name: '',
  98. phone: '',
  99. looking: '',
  100. background: ''
  101. }
  102. }
  103. },
  104. methods: {
  105. async handleSubmit() {
  106. console.log('提交表单', this.formData)
  107. // 这里添加表单提交逻辑
  108. if (!this.formData.name) {
  109. uni.showToast({
  110. title: '请输入姓名',
  111. icon: 'none'
  112. })
  113. return
  114. }
  115. if (!this.formData.phone) {
  116. uni.showToast({
  117. title: '请输入联系方式',
  118. icon: 'none'
  119. })
  120. return
  121. }
  122. try{
  123. const subRes = await this.$api.home.getSignup({
  124. ...this.formData,
  125. id: this.id
  126. })
  127. if (subRes.code === 200) {
  128. uni.showToast({
  129. title: '提交成功',
  130. icon: 'success'
  131. })
  132. setTimeout(() => {
  133. uni.navigateBack({
  134. delta: 2
  135. })
  136. }, 1000)
  137. } else {
  138. uni.showToast({
  139. title: subRes.msg,
  140. icon: 'none'
  141. })
  142. }
  143. } catch (error) {
  144. uni.showToast({
  145. title: error.msg,
  146. icon: 'none'
  147. })
  148. }
  149. // uni.showToast({
  150. // title: '提交成功',
  151. // icon: 'success'
  152. // })
  153. }
  154. }
  155. }
  156. </script>
  157. <style scoped lang="scss">
  158. .submit-container {
  159. background: #F2F2F2;
  160. min-height: 100vh;
  161. display: flex;
  162. flex-direction: column;
  163. }
  164. .main-content {
  165. flex: 1;
  166. padding: 40rpx 32rpx 120rpx;
  167. }
  168. .form-card {
  169. display: flex;
  170. flex-direction: column;
  171. background: #fff;
  172. margin: 0 18rpx;
  173. height: 732rpx;
  174. border-radius: 32rpx;
  175. padding-top: 40rpx;
  176. padding-right: 32rpx;
  177. padding-bottom: 40rpx;
  178. padding-left: 32rpx;
  179. gap: 44rpx;
  180. // box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
  181. .title-section {
  182. // margin-bottom: 40rpx;
  183. .main-title {
  184. font-size: 32rpx;
  185. font-weight: 500;
  186. color: $primary-text-color;
  187. line-height: 1.4;
  188. }
  189. }
  190. }
  191. .form-item {
  192. // margin-bottom: 48rpx;
  193. &:last-child {
  194. margin-bottom: 0;
  195. }
  196. .form-label {
  197. display: block;
  198. font-size: 26rpx;
  199. line-height: 1.4;
  200. color: $primary-text-color;
  201. margin-bottom: 10rpx;
  202. }
  203. }
  204. .bottom-bar {
  205. position: fixed;
  206. bottom: 0;
  207. left: 0;
  208. right: 0;
  209. background: #fff;
  210. padding: 24rpx 50rpx;
  211. z-index: 999;
  212. }
  213. </style>