Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
lls_program
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2025-09-27 16:05:07 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
58f9af3f9f08068104300369ae736a69d6d9b744
58f9af3f
1 parent
6c774b5c
fix(Welcome): 修复年龄计算逻辑并添加创建家庭条件检查
修正生日到年龄的转换逻辑,考虑月份和日期差异 添加满60岁才能创建家庭的检查
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
3 deletions
src/pages/Welcome/index.vue
src/pages/Welcome/index.vue
View file @
58f9af3
...
...
@@ -209,11 +209,29 @@ useDidShow(async () => {
wheelchair_text: null,
phone: null,
};
// userInfo.birthday 是年月日的形式需要转成年龄
userInfo.value.birthday = new Date().getFullYear() - new Date(userInfo.value.birth_date).getFullYear();
// 计算用户年龄
if (userInfo.value.birth_date) {
const birthDate = new Date(userInfo.value.birth_date);
const today = new Date();
let age = today.getFullYear() - birthDate.getFullYear();
const monthDiff = today.getMonth() - birthDate.getMonth();
// 如果还没到生日,年龄减1
if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {
age--;
}
userAge.value = age;
// 检查是否满60岁,可以创建家庭
canCreateFamily.value = age >= 60;
} else {
userAge.value = null;
canCreateFamily.value = false;
}
// 检查用户是否完善了个人信息
hasProfile.value = userInfo.value.nickname && userInfo.value.birth_date && userInfo.value.wheelchair_needed !== null;
userAge.value = userInfo.value.birthday;
}
});
...
...
Please
register
or
login
to post a comment