apply.vue 4.0 KB

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