apply.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <view class="container">
  3. <view class="header">
  4. <text class="title">成为营养师</text>
  5. <text class="subtitle">提交您的专业资质,成为认证家庭营养师</text>
  6. </view>
  7. <view class="form">
  8. <view class="form-item">
  9. <text class="label">真实姓名</text>
  10. <input class="input" v-model="formData.realName" placeholder="请输入真实姓名" />
  11. </view>
  12. <view class="form-item">
  13. <text class="label">手机号</text>
  14. <input class="input" v-model="formData.phone" type="number" placeholder="请输入手机号" maxlength="11" />
  15. </view>
  16. <view class="form-item">
  17. <text class="label">专业资质说明</text>
  18. <textarea class="textarea" v-model="formData.qualification" placeholder="请说明您的营养师资质、从业经验等" maxlength="500" />
  19. <text class="counter">{{ formData.qualification.length }}/500</text>
  20. </view>
  21. <button class="btn-submit" :disabled="submitting" @click="handleSubmit">
  22. {{ submitting ? '提交中...' : '提交申请' }}
  23. </button>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import { nutritionistApply } from '@/utils/api'
  29. export default {
  30. data() {
  31. return {
  32. formData: {
  33. realName: '',
  34. phone: '',
  35. qualification: ''
  36. },
  37. submitting: false
  38. }
  39. },
  40. methods: {
  41. async handleSubmit() {
  42. if (!this.formData.realName) {
  43. uni.showToast({ title: '请输入真实姓名', icon: 'none' })
  44. return
  45. }
  46. if (!this.formData.phone) {
  47. uni.showToast({ title: '请输入手机号', icon: 'none' })
  48. return
  49. }
  50. this.submitting = true
  51. try {
  52. const res = await nutritionistApply(this.formData)
  53. if (res.code === 200) {
  54. uni.showModal({
  55. title: '申请成功',
  56. content: '您的营养师申请已提交,请等待审核',
  57. showCancel: false,
  58. success: () => uni.navigateBack()
  59. })
  60. } else {
  61. uni.showToast({ title: res.message || '提交失败', icon: 'none' })
  62. }
  63. } catch (e) {
  64. uni.showToast({ title: '提交失败', icon: 'none' })
  65. } finally {
  66. this.submitting = false
  67. }
  68. }
  69. }
  70. }
  71. </script>
  72. <style>
  73. .container {
  74. padding: 30rpx;
  75. background: #f8f8f8;
  76. min-height: 100vh;
  77. }
  78. .header {
  79. text-align: center;
  80. padding: 40rpx 0;
  81. }
  82. .title {
  83. font-size: 40rpx;
  84. font-weight: bold;
  85. color: #333;
  86. }
  87. .subtitle {
  88. font-size: 28rpx;
  89. color: #666;
  90. margin-top: 16rpx;
  91. display: block;
  92. }
  93. .form {
  94. background: #fff;
  95. border-radius: 20rpx;
  96. padding: 40rpx;
  97. }
  98. .form-item {
  99. margin-bottom: 40rpx;
  100. }
  101. .label {
  102. font-size: 28rpx;
  103. color: #333;
  104. display: block;
  105. margin-bottom: 20rpx;
  106. font-weight: bold;
  107. }
  108. .input {
  109. width: 100%;
  110. height: 80rpx;
  111. border: 1rpx solid #e0e0e0;
  112. border-radius: 10rpx;
  113. padding: 0 20rpx;
  114. font-size: 28rpx;
  115. box-sizing: border-box;
  116. }
  117. .textarea {
  118. width: 100%;
  119. height: 200rpx;
  120. border: 1rpx solid #e0e0e0;
  121. border-radius: 10rpx;
  122. padding: 20rpx;
  123. font-size: 28rpx;
  124. box-sizing: border-box;
  125. }
  126. .counter {
  127. font-size: 24rpx;
  128. color: #999;
  129. text-align: right;
  130. display: block;
  131. margin-top: 10rpx;
  132. }
  133. .btn-submit {
  134. width: 100%;
  135. height: 90rpx;
  136. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  137. color: #fff;
  138. border-radius: 45rpx;
  139. font-size: 32rpx;
  140. font-weight: bold;
  141. margin-top: 40rpx;
  142. }
  143. .btn-submit[disabled] {
  144. opacity: 0.6;
  145. }
  146. </style>