index.vue 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <view class="register-child-page">
  3. <PlayfulCard elevation="1">
  4. <template slot="header">
  5. <view class="playful-card-header">
  6. <text class="playful-title">为孩子创建账户</text>
  7. </view>
  8. </template>
  9. <view v-if="step === 1" class="form-step">
  10. <text>请输入孩子的姓名</text>
  11. <input v-model="childName" placeholder="姓名" class="input" />
  12. <text>出生日期</text>
  13. <input v-model="birth" type="date" class="input" />
  14. </view>
  15. <view v-else-if="step === 2" class="form-step">
  16. <text>选择头像</text>
  17. <view class="avatar-grid">
  18. <image v-for="n in 5" :key="n" :src="avatarPlaceholder" class="avatar" @click="selectAvatar(n)" />
  19. </view>
  20. </view>
  21. <view v-else class="form-step">
  22. <text>确认信息</text>
  23. <text>Name: {{ childName }}</text>
  24. <text>Birth: {{ birth }}</text>
  25. <text>Avatar: {{ selectedAvatar || '默认' }}</text>
  26. </view>
  27. <template slot="actions">
  28. <PlayfulButton v-if="step < 3" variant="primary" size="md" @click="nextStep">
  29. 下一步
  30. </PlayfulButton>
  31. <PlayfulButton v-else variant="primary" size="md" @click="finishRegistration">
  32. 完成
  33. </PlayfulButton>
  34. </template>
  35. </PlayfulCard>
  36. </view>
  37. </template>
  38. <script>
  39. import PlayfulCard from '@/components/PlayfulCard.vue';
  40. import PlayfulButton from '@/components/PlayfulButton.vue';
  41. export default {
  42. name: 'RegisterChild',
  43. components: { PlayfulCard, PlayfulButton },
  44. data() {
  45. return {
  46. step: 1,
  47. childName: '',
  48. birth: '',
  49. selectedAvatar: null,
  50. avatarPlaceholder: '/static/avatar-placeholder.png'
  51. }
  52. },
  53. methods: {
  54. nextStep() {
  55. if (this.step < 3) this.step++;
  56. else this.finishRegistration();
  57. },
  58. selectAvatar(n) { this.selectedAvatar = n; },
  59. finishRegistration() {
  60. // Here you would typically POST the data to your backend
  61. uni.showToast({ title: '注册完成!', icon: 'success' });
  62. // Navigate to child dashboard or home
  63. uni.redirectTo({ url: '/pages/index/index' });
  64. }
  65. }
  66. }
  67. </script>
  68. <style scoped>
  69. .register-child-page { padding: 16px; }
  70. .input { width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--border); margin-bottom: 12px; font-size: 1rem; }
  71. .playful-card-header { font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; }
  72. .playful-title { font-family: var(--font-display); }
  73. .avatar-grid { display: flex; gap: 10px; flex-wrap: wrap; }
  74. .avatar { width: 72px; height: 72px; border-radius: 50%; border: 2px solid #eee; cursor: pointer; }
  75. </style>