缺陷优化
This commit is contained in:
@@ -133,7 +133,7 @@ const EditProfilePage: React.FC = () => {
|
||||
const tempFilePath = res.tempFilePaths[0];
|
||||
try {
|
||||
const avatar_url = await UserService.upload_avatar(tempFilePath);
|
||||
setUserInfo((prev) => ({ ...prev, avatar: avatar_url }));
|
||||
await updateUserInfo({ avatar: avatar_url });
|
||||
Taro.showToast({
|
||||
title: "头像上传成功",
|
||||
icon: "success",
|
||||
@@ -331,6 +331,22 @@ const EditProfilePage: React.FC = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const getDefaultOption = (options) => {
|
||||
if (!Array.isArray(options) || options.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const defaultOptions: string[] = [];
|
||||
let current = options[0];
|
||||
|
||||
while (current) {
|
||||
defaultOptions.push(current.text);
|
||||
current = current.children?.[0];
|
||||
}
|
||||
|
||||
return defaultOptions;
|
||||
}
|
||||
|
||||
return (
|
||||
<View className="edit_profile_page">
|
||||
{/* 导航栏 */}
|
||||
@@ -639,7 +655,7 @@ const EditProfilePage: React.FC = () => {
|
||||
]}
|
||||
visible={gender_picker_visible}
|
||||
setvisible={setGenderPickerVisible}
|
||||
value={[form_data.gender]}
|
||||
value={form_data.gender === "" ? ["0"] : [form_data.gender]}
|
||||
onChange={handle_gender_change}
|
||||
/>
|
||||
)}
|
||||
@@ -671,7 +687,7 @@ const EditProfilePage: React.FC = () => {
|
||||
options={cities}
|
||||
visible={location_picker_visible}
|
||||
setvisible={setLocationPickerVisible}
|
||||
value={[form_data.country, form_data.province, form_data.city]}
|
||||
value={form_data.country ? [form_data.country, form_data.province, form_data.city] : getDefaultOption(cities)}
|
||||
onChange={handle_location_change}
|
||||
/>
|
||||
)}
|
||||
@@ -693,10 +709,10 @@ const EditProfilePage: React.FC = () => {
|
||||
],
|
||||
]}
|
||||
type="ntrp"
|
||||
img={(user_info as UserInfoType)?.avatar_url}
|
||||
// img={(user_info as UserInfoType)?.avatar_url}
|
||||
visible={ntrp_picker_visible}
|
||||
setvisible={setNtrpPickerVisible}
|
||||
value={[form_data.ntrp_level]}
|
||||
value={form_data.ntrp_level === "0" ? ["3.0"] : [form_data.ntrp_level]}
|
||||
onChange={handle_ntrp_level_change}
|
||||
/>
|
||||
)}
|
||||
@@ -709,7 +725,7 @@ const EditProfilePage: React.FC = () => {
|
||||
options={professions}
|
||||
visible={occupation_picker_visible}
|
||||
setvisible={setOccupationPickerVisible}
|
||||
value={[...form_data.occupation.split(" ")]}
|
||||
value={form_data.occupation ? [...form_data.occupation.split(" ")] : getDefaultOption(professions)}
|
||||
onChange={handle_occupation_change}
|
||||
/>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user