hookehuyr

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

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

fix(EditProfile): 优化头像显示和表单验证逻辑
使用默认头像当用户未上传时
添加表单验证确保必填项不为空
将头像大小限制从10MB改为5MB
......@@ -3,8 +3,7 @@
<!-- Avatar -->
<view class="flex flex-col items-center py-8" @click="changeAvatar">
<view class="w-24 h-24 rounded-full bg-gray-100 flex items-center justify-center mb-2 overflow-hidden">
<image v-if="formData.avatar_url" :src="formData.avatar_url" class="w-full h-full" mode="aspectFill" />
<My size="40" color="#888" v-else />
<image :src="formData.avatar_url || defaultAvatar" class="w-full h-full" mode="aspectFill" />
</view>
<text class="text-gray-500 text-sm">上传头像</text>
</view>
......@@ -87,6 +86,8 @@ import { ref, reactive, onMounted } from 'vue';
import Taro from '@tarojs/taro';
import { My, Date as DateIcon, Right } from '@nutui/icons-vue-taro';
import BASE_URL from '@/utils/config';
// 默认头像
const defaultAvatar = 'https://cdn.ipadbiz.cn/mlaj/images/icon_1.jpeg'
/**
* @description 表单数据
......@@ -173,9 +174,9 @@ const changeAvatar = () => {
sourceType: ['album', 'camera'],
success: (res) => {
const tempFile = res.tempFiles[0];
if (tempFile.size > 10 * 1024 * 1024) {
if (tempFile.size > 5 * 1024 * 1024) {
Taro.showToast({
title: '图片大小不能超过10MB',
title: '图片大小不能超过5MB',
icon: 'none',
});
return;
......@@ -211,9 +212,51 @@ const changeAvatar = () => {
// --- Save ---
/**
* @description 验证表单数据
* @returns {boolean} 验证是否通过
*/
const validateForm = () => {
if (!formData.nickname.trim()) {
Taro.showToast({
title: '请输入昵称',
icon: 'none'
});
return false;
}
if (!formData.birthday) {
Taro.showToast({
title: '请选择出生年月',
icon: 'none'
});
return false;
}
if (formData.wheelchair === null || formData.wheelchair === undefined) {
Taro.showToast({
title: '请选择是否需要轮椅出行',
icon: 'none'
});
return false;
}
return true;
};
/**
* @description 保存用户信息
*/
const handleSave = () => {
// 验证表单
if (!validateForm()) {
return;
}
// 如果头像为空,使用默认头像
if (!formData.avatar_url) {
formData.avatar_url = defaultAvatar;
}
console.log('Saving data:', formData);
Taro.showLoading({ title: '保存中...' });
// Mock save process
......
<!--
* @Date: 2022-09-19 14:11:06
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-08-29 20:32:52
* @LastEditTime: 2025-09-02 14:42:39
* @FilePath: /lls_program/src/pages/MyFamily/index.vue
* @Description: 我的家庭页面 - 展示用户加入的家庭列表
-->
......@@ -98,7 +98,7 @@
</view>
<!-- 底部固定按钮 -->
<view class="fixed bottom-0 left-0 right-0 bg-white border-t border-gray-100 p-4 z-10">
<view v-if="isShowBtn" class="fixed bottom-0 left-0 right-0 bg-white border-t border-gray-100 p-4 z-10">
<view
@tap="joinNewFamily"
class="w-full bg-blue-500 text-white text-center py-3 rounded-lg font-medium"
......@@ -112,7 +112,7 @@
</template>
<script setup>
import { ref, onMounted } from 'vue';
import { ref, onMounted, computed } from 'vue';
import Taro, { useDidShow } from '@tarojs/taro';
import { Home } from '@nutui/icons-vue-taro';
import './index.less';
......@@ -163,6 +163,11 @@ const initPageData = () => {
];
};
// 如果家庭列表存在时, 才显示加入新家庭的按钮
const isShowBtn = computed(() => {
return familyList.value.length > 0;
})
/**
* 切换到指定家庭
* @param {number} familyId - 家庭ID
......
<!--
* @Date: 2025-08-27 17:47:46
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-08-29 20:38:36
* @LastEditTime: 2025-09-02 14:55:52
* @FilePath: /lls_program/src/pages/Profile/index.vue
* @Description: 文件描述
-->
......@@ -108,7 +108,7 @@ const goToEditProfile = () => {
const initPageData = () => {
// 获取用户信息
userInfo.value = {
nickName: '用户10086',
nickName: '用户昵称',
avatarUrl: defaultAvatar,
}
}
......