apply.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. onLoad() {
  31. uni.redirectTo({ url: '/pages/profile/service-role-apply' })
  32. },
  33. data() {
  34. return {
  35. formData: {
  36. realName: '',
  37. phone: '',
  38. qualification: ''
  39. },
  40. submitting: false
  41. }
  42. },
  43. methods: {
  44. async handleSubmit() {
  45. if (!this.formData.realName) {
  46. uni.showToast({ title: '请输入真实姓名', icon: 'none' })
  47. return
  48. }
  49. if (!this.formData.phone) {
  50. uni.showToast({ title: '请输入手机号', icon: 'none' })
  51. return
  52. }
  53. this.submitting = true
  54. try {
  55. const res = await nutritionistApply(this.formData)
  56. if (res.code === 200) {
  57. uni.showModal({
  58. title: '申请成功',
  59. content: '您的营养师申请已提交,请等待审核',
  60. showCancel: false,
  61. success: () => uni.navigateBack()
  62. })
  63. } else {
  64. uni.showToast({ title: res.message || '提交失败', icon: 'none' })
  65. }
  66. } catch (e) {
  67. uni.showToast({ title: '提交失败', icon: 'none' })
  68. } finally {
  69. this.submitting = false
  70. }
  71. }
  72. }
  73. }
  74. </script>
  75. <style>
  76. .container {
  77. padding: 30rpx;
  78. background: #f8f8f8;
  79. min-height: 100vh;
  80. }
  81. .header {
  82. text-align: center;
  83. padding: 40rpx 0;
  84. }
  85. .title {
  86. font-size: 40rpx;
  87. font-weight: bold;
  88. color: #333;
  89. }
  90. .subtitle {
  91. font-size: 28rpx;
  92. color: #666;
  93. margin-top: 16rpx;
  94. display: block;
  95. }
  96. .form {
  97. background: #fff;
  98. border-radius: 20rpx;
  99. padding: 40rpx;
  100. }
  101. .form-item {
  102. margin-bottom: 40rpx;
  103. }
  104. .label {
  105. font-size: 28rpx;
  106. color: #333;
  107. display: block;
  108. margin-bottom: 20rpx;
  109. font-weight: bold;
  110. }
  111. .input {
  112. width: 100%;
  113. height: 80rpx;
  114. border: 1rpx solid #e0e0e0;
  115. border-radius: 10rpx;
  116. padding: 0 20rpx;
  117. font-size: 28rpx;
  118. box-sizing: border-box;
  119. }
  120. .textarea {
  121. width: 100%;
  122. height: 200rpx;
  123. border: 1rpx solid #e0e0e0;
  124. border-radius: 10rpx;
  125. padding: 20rpx;
  126. font-size: 28rpx;
  127. box-sizing: border-box;
  128. }
  129. .counter {
  130. font-size: 24rpx;
  131. color: #999;
  132. text-align: right;
  133. display: block;
  134. margin-top: 10rpx;
  135. }
  136. .btn-submit {
  137. width: 100%;
  138. height: 90rpx;
  139. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  140. color: #fff;
  141. border-radius: 45rpx;
  142. font-size: 32rpx;
  143. font-weight: bold;
  144. margin-top: 40rpx;
  145. }
  146. .btn-submit[disabled] {
  147. opacity: 0.6;
  148. }
  149. </style>