hookehuyr

fix(Profile): 将默认昵称从'用户10086'改为'用户昵称'

refactor(MyFamily): 添加计算属性控制底部按钮显示逻辑
当家庭列表不为空时才显示加入新家庭按钮

fix(EditProfile): 优化头像显示和表单验证逻辑
使用默认头像当用户未上传时
添加表单验证确保必填项不为空
将头像大小限制从10MB改为5MB
...@@ -3,8 +3,7 @@ ...@@ -3,8 +3,7 @@
3 <!-- Avatar --> 3 <!-- Avatar -->
4 <view class="flex flex-col items-center py-8" @click="changeAvatar"> 4 <view class="flex flex-col items-center py-8" @click="changeAvatar">
5 <view class="w-24 h-24 rounded-full bg-gray-100 flex items-center justify-center mb-2 overflow-hidden"> 5 <view class="w-24 h-24 rounded-full bg-gray-100 flex items-center justify-center mb-2 overflow-hidden">
6 - <image v-if="formData.avatar_url" :src="formData.avatar_url" class="w-full h-full" mode="aspectFill" /> 6 + <image :src="formData.avatar_url || defaultAvatar" class="w-full h-full" mode="aspectFill" />
7 - <My size="40" color="#888" v-else />
8 </view> 7 </view>
9 <text class="text-gray-500 text-sm">上传头像</text> 8 <text class="text-gray-500 text-sm">上传头像</text>
10 </view> 9 </view>
...@@ -87,6 +86,8 @@ import { ref, reactive, onMounted } from 'vue'; ...@@ -87,6 +86,8 @@ import { ref, reactive, onMounted } from 'vue';
87 import Taro from '@tarojs/taro'; 86 import Taro from '@tarojs/taro';
88 import { My, Date as DateIcon, Right } from '@nutui/icons-vue-taro'; 87 import { My, Date as DateIcon, Right } from '@nutui/icons-vue-taro';
89 import BASE_URL from '@/utils/config'; 88 import BASE_URL from '@/utils/config';
89 +// 默认头像
90 +const defaultAvatar = 'https://cdn.ipadbiz.cn/mlaj/images/icon_1.jpeg'
90 91
91 /** 92 /**
92 * @description 表单数据 93 * @description 表单数据
...@@ -173,9 +174,9 @@ const changeAvatar = () => { ...@@ -173,9 +174,9 @@ const changeAvatar = () => {
173 sourceType: ['album', 'camera'], 174 sourceType: ['album', 'camera'],
174 success: (res) => { 175 success: (res) => {
175 const tempFile = res.tempFiles[0]; 176 const tempFile = res.tempFiles[0];
176 - if (tempFile.size > 10 * 1024 * 1024) { 177 + if (tempFile.size > 5 * 1024 * 1024) {
177 Taro.showToast({ 178 Taro.showToast({
178 - title: '图片大小不能超过10MB', 179 + title: '图片大小不能超过5MB',
179 icon: 'none', 180 icon: 'none',
180 }); 181 });
181 return; 182 return;
...@@ -211,9 +212,51 @@ const changeAvatar = () => { ...@@ -211,9 +212,51 @@ const changeAvatar = () => {
211 212
212 // --- Save --- 213 // --- Save ---
213 /** 214 /**
215 + * @description 验证表单数据
216 + * @returns {boolean} 验证是否通过
217 + */
218 +const validateForm = () => {
219 + if (!formData.nickname.trim()) {
220 + Taro.showToast({
221 + title: '请输入昵称',
222 + icon: 'none'
223 + });
224 + return false;
225 + }
226 +
227 + if (!formData.birthday) {
228 + Taro.showToast({
229 + title: '请选择出生年月',
230 + icon: 'none'
231 + });
232 + return false;
233 + }
234 +
235 + if (formData.wheelchair === null || formData.wheelchair === undefined) {
236 + Taro.showToast({
237 + title: '请选择是否需要轮椅出行',
238 + icon: 'none'
239 + });
240 + return false;
241 + }
242 +
243 + return true;
244 +};
245 +
246 +/**
214 * @description 保存用户信息 247 * @description 保存用户信息
215 */ 248 */
216 const handleSave = () => { 249 const handleSave = () => {
250 + // 验证表单
251 + if (!validateForm()) {
252 + return;
253 + }
254 +
255 + // 如果头像为空,使用默认头像
256 + if (!formData.avatar_url) {
257 + formData.avatar_url = defaultAvatar;
258 + }
259 +
217 console.log('Saving data:', formData); 260 console.log('Saving data:', formData);
218 Taro.showLoading({ title: '保存中...' }); 261 Taro.showLoading({ title: '保存中...' });
219 // Mock save process 262 // Mock save process
......
1 <!-- 1 <!--
2 * @Date: 2022-09-19 14:11:06 2 * @Date: 2022-09-19 14:11:06
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-08-29 20:32:52 4 + * @LastEditTime: 2025-09-02 14:42:39
5 * @FilePath: /lls_program/src/pages/MyFamily/index.vue 5 * @FilePath: /lls_program/src/pages/MyFamily/index.vue
6 * @Description: 我的家庭页面 - 展示用户加入的家庭列表 6 * @Description: 我的家庭页面 - 展示用户加入的家庭列表
7 --> 7 -->
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
98 </view> 98 </view>
99 99
100 <!-- 底部固定按钮 --> 100 <!-- 底部固定按钮 -->
101 - <view class="fixed bottom-0 left-0 right-0 bg-white border-t border-gray-100 p-4 z-10"> 101 + <view v-if="isShowBtn" class="fixed bottom-0 left-0 right-0 bg-white border-t border-gray-100 p-4 z-10">
102 <view 102 <view
103 @tap="joinNewFamily" 103 @tap="joinNewFamily"
104 class="w-full bg-blue-500 text-white text-center py-3 rounded-lg font-medium" 104 class="w-full bg-blue-500 text-white text-center py-3 rounded-lg font-medium"
...@@ -112,7 +112,7 @@ ...@@ -112,7 +112,7 @@
112 </template> 112 </template>
113 113
114 <script setup> 114 <script setup>
115 -import { ref, onMounted } from 'vue'; 115 +import { ref, onMounted, computed } from 'vue';
116 import Taro, { useDidShow } from '@tarojs/taro'; 116 import Taro, { useDidShow } from '@tarojs/taro';
117 import { Home } from '@nutui/icons-vue-taro'; 117 import { Home } from '@nutui/icons-vue-taro';
118 import './index.less'; 118 import './index.less';
...@@ -163,6 +163,11 @@ const initPageData = () => { ...@@ -163,6 +163,11 @@ const initPageData = () => {
163 ]; 163 ];
164 }; 164 };
165 165
166 +// 如果家庭列表存在时, 才显示加入新家庭的按钮
167 +const isShowBtn = computed(() => {
168 + return familyList.value.length > 0;
169 +})
170 +
166 /** 171 /**
167 * 切换到指定家庭 172 * 切换到指定家庭
168 * @param {number} familyId - 家庭ID 173 * @param {number} familyId - 家庭ID
......
1 <!-- 1 <!--
2 * @Date: 2025-08-27 17:47:46 2 * @Date: 2025-08-27 17:47:46
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-08-29 20:38:36 4 + * @LastEditTime: 2025-09-02 14:55:52
5 * @FilePath: /lls_program/src/pages/Profile/index.vue 5 * @FilePath: /lls_program/src/pages/Profile/index.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -108,7 +108,7 @@ const goToEditProfile = () => { ...@@ -108,7 +108,7 @@ const goToEditProfile = () => {
108 const initPageData = () => { 108 const initPageData = () => {
109 // 获取用户信息 109 // 获取用户信息
110 userInfo.value = { 110 userInfo.value = {
111 - nickName: '用户10086', 111 + nickName: '用户昵称',
112 avatarUrl: defaultAvatar, 112 avatarUrl: defaultAvatar,
113 } 113 }
114 } 114 }
......