缺陷优化
This commit is contained in:
@@ -26,7 +26,7 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 76px;
|
width: 76px;
|
||||||
background: #00000008;
|
background: #00000008;
|
||||||
border: 0.5px solid #0000001F;
|
border: 1.5px solid #e5e5e5;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
padding: 12px 0;
|
padding: 12px 0;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React, { useState, useEffect, useCallback } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import CommonPopup from "@/components/CommonPopup";
|
import CommonPopup from "@/components/CommonPopup";
|
||||||
import { View, Text, Image } from "@tarojs/components";
|
import { View } from "@tarojs/components";
|
||||||
import Picker from "./Picker";
|
import Picker from "./Picker";
|
||||||
import {
|
import {
|
||||||
renderYearMonth,
|
renderYearMonth,
|
||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
} from "./PickerData";
|
} from "./PickerData";
|
||||||
import NTRPTestEntryCard from "../NTRPTestEntryCard";
|
import NTRPTestEntryCard from "../NTRPTestEntryCard";
|
||||||
import { EvaluateScene } from "@/store/evaluateStore";
|
import { EvaluateScene } from "@/store/evaluateStore";
|
||||||
import imgs from "@/config/images";
|
// import imgs from "@/config/images";
|
||||||
import styles from "./index.module.scss";
|
import styles from "./index.module.scss";
|
||||||
interface PickerOption {
|
interface PickerOption {
|
||||||
text: string | number;
|
text: string | number;
|
||||||
@@ -27,7 +27,7 @@ interface PickerProps {
|
|||||||
options?: PickerOption[][] | PickerOption[];
|
options?: PickerOption[][] | PickerOption[];
|
||||||
value?: (string | number)[];
|
value?: (string | number)[];
|
||||||
type?: "month" | "day" | "hour" | "ntrp" | null;
|
type?: "month" | "day" | "hour" | "ntrp" | null;
|
||||||
img?: string;
|
// img?: string;
|
||||||
onConfirm?: (options: PickerOption[], values: (string | number)[]) => void;
|
onConfirm?: (options: PickerOption[], values: (string | number)[]) => void;
|
||||||
onChange?: (value: (string | number)[]) => void;
|
onChange?: (value: (string | number)[]) => void;
|
||||||
style?: React.CSSProperties;
|
style?: React.CSSProperties;
|
||||||
@@ -42,7 +42,7 @@ const PopupPicker = ({
|
|||||||
visible,
|
visible,
|
||||||
setvisible,
|
setvisible,
|
||||||
value = [],
|
value = [],
|
||||||
img,
|
// img,
|
||||||
onConfirm,
|
onConfirm,
|
||||||
onChange,
|
onChange,
|
||||||
options = [],
|
options = [],
|
||||||
@@ -54,7 +54,6 @@ const PopupPicker = ({
|
|||||||
const changePicker = (options: any[], values: any, columnIndex: number) => {
|
const changePicker = (options: any[], values: any, columnIndex: number) => {
|
||||||
if (onChange) {
|
if (onChange) {
|
||||||
console.log("picker onChange", columnIndex, values, options);
|
console.log("picker onChange", columnIndex, values, options);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
type === "day" &&
|
type === "day" &&
|
||||||
JSON.stringify(defaultValue) !== JSON.stringify(values)
|
JSON.stringify(defaultValue) !== JSON.stringify(values)
|
||||||
@@ -79,7 +78,6 @@ const PopupPicker = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleConfirm = () => {
|
const handleConfirm = () => {
|
||||||
console.log(defaultValue, "defaultValue");
|
|
||||||
onChange(defaultValue);
|
onChange(defaultValue);
|
||||||
setvisible(false);
|
setvisible(false);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ export const UserInfoCard: React.FC<UserInfoCardProps> = ({
|
|||||||
useState(false);
|
useState(false);
|
||||||
|
|
||||||
// 表单状态
|
// 表单状态
|
||||||
const [form_data, setFormData] = useState<Partial<UserInfoType>>({
|
const [form_data] = useState<Partial<UserInfoType>>({
|
||||||
...user_info,
|
...user_info,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -143,12 +143,14 @@ export const UserInfoCard: React.FC<UserInfoCardProps> = ({
|
|||||||
const update_data = { [editing_field]: value };
|
const update_data = { [editing_field]: value };
|
||||||
await UserService.update_user_info(update_data);
|
await UserService.update_user_info(update_data);
|
||||||
|
|
||||||
|
await updateUserInfo({ [editing_field]: value });
|
||||||
|
|
||||||
// 更新本地状态
|
// 更新本地状态
|
||||||
setFormData((prev) => {
|
// setFormData((prev) => {
|
||||||
const updated = { ...prev, [editing_field]: value };
|
// const updated = { ...prev, [editing_field]: value };
|
||||||
typeof set_user_info === "function" && set_user_info(updated);
|
// typeof set_user_info === "function" && set_user_info(updated);
|
||||||
return updated;
|
// return updated;
|
||||||
});
|
// });
|
||||||
|
|
||||||
// 关闭弹窗
|
// 关闭弹窗
|
||||||
setEditModalVisible(false);
|
setEditModalVisible(false);
|
||||||
@@ -180,14 +182,14 @@ export const UserInfoCard: React.FC<UserInfoCardProps> = ({
|
|||||||
) {
|
) {
|
||||||
await updateUserInfo({ ...field });
|
await updateUserInfo({ ...field });
|
||||||
// 更新本地状态
|
// 更新本地状态
|
||||||
setFormData((prev) => ({ ...prev, ...field }));
|
// setFormData((prev) => ({ ...prev, ...field }));
|
||||||
// setUserInfo((prev) => ({ ...prev, ...field }));
|
// setUserInfo((prev) => ({ ...prev, ...field }));
|
||||||
} else {
|
} else {
|
||||||
// 调用更新用户信息接口,只传递修改的字段
|
// 调用更新用户信息接口,只传递修改的字段
|
||||||
const update_data = { [field as string]: value };
|
const update_data = { [field as string]: value };
|
||||||
await updateUserInfo(update_data);
|
await updateUserInfo(update_data);
|
||||||
// 更新本地状态
|
// 更新本地状态
|
||||||
setFormData((prev) => ({ ...prev, [field as string]: value }));
|
// setFormData((prev) => ({ ...prev, [field as string]: value }));
|
||||||
// setUserInfo((prev) => ({ ...prev, [field as string]: value }));
|
// setUserInfo((prev) => ({ ...prev, [field as string]: value }));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,6 +261,22 @@ export const UserInfoCard: React.FC<UserInfoCardProps> = ({
|
|||||||
// 主办和参加暂时不处理,可以后续扩展
|
// 主办和参加暂时不处理,可以后续扩展
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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 (
|
return (
|
||||||
<View className="user_info_card">
|
<View className="user_info_card">
|
||||||
{/* 头像和基本信息 */}
|
{/* 头像和基本信息 */}
|
||||||
@@ -385,7 +403,7 @@ export const UserInfoCard: React.FC<UserInfoCardProps> = ({
|
|||||||
<Text>选择性别</Text>
|
<Text>选择性别</Text>
|
||||||
</View>
|
</View>
|
||||||
) : null}
|
) : null}
|
||||||
{user_info.ntrp_level ? (
|
{user_info.ntrp_level !== "0" ? (
|
||||||
<View className="tag_item">
|
<View className="tag_item">
|
||||||
<Text className="tag_text">{`NTRP ${user_info.ntrp_level}`}</Text>
|
<Text className="tag_text">{`NTRP ${user_info.ntrp_level}`}</Text>
|
||||||
</View>
|
</View>
|
||||||
@@ -472,7 +490,7 @@ export const UserInfoCard: React.FC<UserInfoCardProps> = ({
|
|||||||
]}
|
]}
|
||||||
visible={gender_picker_visible}
|
visible={gender_picker_visible}
|
||||||
setvisible={setGenderPickerVisible}
|
setvisible={setGenderPickerVisible}
|
||||||
value={[form_data.gender || ""]}
|
value={form_data.gender === "" ? ["0"] : [form_data.gender]}
|
||||||
onChange={handle_gender_change}
|
onChange={handle_gender_change}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -484,11 +502,7 @@ export const UserInfoCard: React.FC<UserInfoCardProps> = ({
|
|||||||
options={cities}
|
options={cities}
|
||||||
visible={location_picker_visible}
|
visible={location_picker_visible}
|
||||||
setvisible={setLocationPickerVisible}
|
setvisible={setLocationPickerVisible}
|
||||||
value={[
|
value={form_data.country ? [form_data.country, form_data.province, form_data.city] : getDefaultOption(cities)}
|
||||||
form_data.country || "",
|
|
||||||
form_data.province || "",
|
|
||||||
form_data.city || "",
|
|
||||||
]}
|
|
||||||
onChange={handle_location_change}
|
onChange={handle_location_change}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -512,7 +526,7 @@ export const UserInfoCard: React.FC<UserInfoCardProps> = ({
|
|||||||
img={user_info.avatar_url || ""}
|
img={user_info.avatar_url || ""}
|
||||||
visible={ntrp_picker_visible}
|
visible={ntrp_picker_visible}
|
||||||
setvisible={setNtrpPickerVisible}
|
setvisible={setNtrpPickerVisible}
|
||||||
value={[form_data.ntrp_level || ""]}
|
value={form_data.ntrp_level === "0" ? ["3.0"] : [form_data.ntrp_level]}
|
||||||
onChange={handle_ntrp_level_change}
|
onChange={handle_ntrp_level_change}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -524,7 +538,7 @@ export const UserInfoCard: React.FC<UserInfoCardProps> = ({
|
|||||||
options={professions}
|
options={professions}
|
||||||
visible={occupation_picker_visible}
|
visible={occupation_picker_visible}
|
||||||
setvisible={setOccupationPickerVisible}
|
setvisible={setOccupationPickerVisible}
|
||||||
value={[...(form_data.occupation || "").split(" ")]}
|
value={form_data.occupation ? [...form_data.occupation.split(" ")] : getDefaultOption(professions)}
|
||||||
onChange={handle_occupation_change}
|
onChange={handle_occupation_change}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -665,9 +679,8 @@ export const GameTabs: React.FC<GameTabsProps> = ({
|
|||||||
<Text className="tab_text">{hosted_text}</Text>
|
<Text className="tab_text">{hosted_text}</Text>
|
||||||
</View>
|
</View>
|
||||||
<View
|
<View
|
||||||
className={`tab_item ${
|
className={`tab_item ${active_tab === "participated" ? "active" : ""
|
||||||
active_tab === "participated" ? "active" : ""
|
}`}
|
||||||
}`}
|
|
||||||
onClick={() => on_tab_change("participated")}
|
onClick={() => on_tab_change("participated")}
|
||||||
>
|
>
|
||||||
<Text className="tab_text">{participated_text}</Text>
|
<Text className="tab_text">{participated_text}</Text>
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ const EditProfilePage: React.FC = () => {
|
|||||||
const tempFilePath = res.tempFilePaths[0];
|
const tempFilePath = res.tempFilePaths[0];
|
||||||
try {
|
try {
|
||||||
const avatar_url = await UserService.upload_avatar(tempFilePath);
|
const avatar_url = await UserService.upload_avatar(tempFilePath);
|
||||||
setUserInfo((prev) => ({ ...prev, avatar: avatar_url }));
|
await updateUserInfo({ avatar: avatar_url });
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: "头像上传成功",
|
title: "头像上传成功",
|
||||||
icon: "success",
|
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 (
|
return (
|
||||||
<View className="edit_profile_page">
|
<View className="edit_profile_page">
|
||||||
{/* 导航栏 */}
|
{/* 导航栏 */}
|
||||||
@@ -639,7 +655,7 @@ const EditProfilePage: React.FC = () => {
|
|||||||
]}
|
]}
|
||||||
visible={gender_picker_visible}
|
visible={gender_picker_visible}
|
||||||
setvisible={setGenderPickerVisible}
|
setvisible={setGenderPickerVisible}
|
||||||
value={[form_data.gender]}
|
value={form_data.gender === "" ? ["0"] : [form_data.gender]}
|
||||||
onChange={handle_gender_change}
|
onChange={handle_gender_change}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -671,7 +687,7 @@ const EditProfilePage: React.FC = () => {
|
|||||||
options={cities}
|
options={cities}
|
||||||
visible={location_picker_visible}
|
visible={location_picker_visible}
|
||||||
setvisible={setLocationPickerVisible}
|
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}
|
onChange={handle_location_change}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -693,10 +709,10 @@ const EditProfilePage: React.FC = () => {
|
|||||||
],
|
],
|
||||||
]}
|
]}
|
||||||
type="ntrp"
|
type="ntrp"
|
||||||
img={(user_info as UserInfoType)?.avatar_url}
|
// img={(user_info as UserInfoType)?.avatar_url}
|
||||||
visible={ntrp_picker_visible}
|
visible={ntrp_picker_visible}
|
||||||
setvisible={setNtrpPickerVisible}
|
setvisible={setNtrpPickerVisible}
|
||||||
value={[form_data.ntrp_level]}
|
value={form_data.ntrp_level === "0" ? ["3.0"] : [form_data.ntrp_level]}
|
||||||
onChange={handle_ntrp_level_change}
|
onChange={handle_ntrp_level_change}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -709,7 +725,7 @@ const EditProfilePage: React.FC = () => {
|
|||||||
options={professions}
|
options={professions}
|
||||||
visible={occupation_picker_visible}
|
visible={occupation_picker_visible}
|
||||||
setvisible={setOccupationPickerVisible}
|
setvisible={setOccupationPickerVisible}
|
||||||
value={[...form_data.occupation.split(" ")]}
|
value={form_data.occupation ? [...form_data.occupation.split(" ")] : getDefaultOption(professions)}
|
||||||
onChange={handle_occupation_change}
|
onChange={handle_occupation_change}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -62,10 +62,10 @@ const SetTransactionPassword: React.FC = () => {
|
|||||||
const { new_password, confirm_password, sms_code } = formData;
|
const { new_password, confirm_password, sms_code } = formData;
|
||||||
if (handleType === "set") {
|
if (handleType === "set") {
|
||||||
setValid(
|
setValid(
|
||||||
!!sms_code && new_password.length === 6 && confirm_password.length === 6
|
(sms_code !== "") && (new_password.length === 6) && (confirm_password.length === 6)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
setValid(new_password.length === 6 && confirm_password.length === 6);
|
setValid((new_password.length === 6) && (confirm_password.length === 6));
|
||||||
}
|
}
|
||||||
}, [formData]);
|
}, [formData]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user