图书馆小程序
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.

138 lines
2.9 KiB

1 week ago
  1. <template>
  2. <view class="user-info-page">
  3. <!-- 昵称 -->
  4. <view class="form-item">
  5. <text class="label">昵称</text>
  6. <input class="input" v-model="userInfo.nickname" placeholder="请输入昵称" />
  7. <uni-icons type="right" size="18"></uni-icons>
  8. </view>
  9. <!-- 性别picker 选择 -->
  10. <view class="form-item">
  11. <text class="label">性别</text>
  12. <picker class="picker" :value="genderIndex" :range="genderList" @change="onGenderChange">
  13. <view class="picker-text">{{ userInfo.gender || "请选择" }}</view>
  14. </picker>
  15. <uni-icons type="right" size="18"></uni-icons>
  16. </view>
  17. <!-- 年龄 -->
  18. <view class="form-item">
  19. <text class="label">年龄</text>
  20. <input class="input" v-model="userInfo.age" placeholder="请输入年龄" type="number" />
  21. <uni-icons type="right" size="18"></uni-icons>
  22. </view>
  23. <!-- 职业 -->
  24. <view class="form-item">
  25. <text class="label">职业</text>
  26. <input class="input" v-model="userInfo.job" placeholder="请输入职业" />
  27. <uni-icons type="right" size="18"></uni-icons>
  28. </view>
  29. <!-- 保存按钮 -->
  30. <view class="save-box">
  31. <button class="save-btn" @click="saveUserInfo">保存</button>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. data() {
  38. return {
  39. // 用户信息
  40. userInfo: {
  41. nickname: "小图",
  42. gender: "女",
  43. age: "",
  44. job: ""
  45. },
  46. // 性别选择器
  47. genderList: ["男", "女", "保密"],
  48. genderIndex: 1 // 默认选中女
  49. };
  50. },
  51. methods: {
  52. // 性别选择改变
  53. onGenderChange(e) {
  54. const index = e.detail.value;
  55. this.genderIndex = index;
  56. this.userInfo.gender = this.genderList[index];
  57. },
  58. // 保存个人信息
  59. saveUserInfo() {
  60. console.log("要保存的信息:", this.userInfo);
  61. // 对接你的保存接口
  62. uni.showToast({
  63. title: "保存成功",
  64. icon: "success"
  65. });
  66. }
  67. }
  68. };
  69. </script>
  70. <style lang="scss" scoped>
  71. .user-info-page {
  72. background-color: #f5f5f5;
  73. min-height: 100vh;
  74. padding: 10px;
  75. box-sizing: border-box;
  76. padding-bottom: 80px;
  77. }
  78. .form-item {
  79. background-color: #fff;
  80. display: flex;
  81. justify-content: space-between;
  82. align-items: center;
  83. padding: 0 10px 0 15px;
  84. height: 50px;
  85. border-bottom: 1px solid #eee;
  86. }
  87. .label {
  88. width: 100px;
  89. font-size: 16px;
  90. color: #333;
  91. }
  92. /* 输入框样式 */
  93. .input {
  94. flex: 1;
  95. font-size: 16px;
  96. color: #333;
  97. text-align: right;
  98. margin-right: 6px;
  99. }
  100. /* 选择器样式 */
  101. .picker {
  102. flex: 1;
  103. display: flex;
  104. justify-content: flex-end;
  105. margin-right: 6px;
  106. }
  107. .picker-text {
  108. font-size: 16px;
  109. color: #333;
  110. text-align: right;
  111. }
  112. /* 保存按钮 */
  113. .save-box {
  114. position: fixed;
  115. left: 15px;
  116. right: 15px;
  117. bottom: 30px;
  118. }
  119. .save-btn {
  120. padding: 5px 0;
  121. background-color: #007aff;
  122. color: #fff;
  123. border-radius: 23px;
  124. font-size: 16px;
  125. }
  126. </style>