优化
This commit is contained in:
@@ -32,7 +32,8 @@ const EditModal: React.FC<EditModalProps> = ({
|
|||||||
const [value, setValue] = useState(initialValue);
|
const [value, setValue] = useState(initialValue);
|
||||||
const [isValid, setIsValid] = useState(true);
|
const [isValid, setIsValid] = useState(true);
|
||||||
const [isIllegal, setIsIllegal] = useState(false);
|
const [isIllegal, setIsIllegal] = useState(false);
|
||||||
|
const [hasIllegal, setHasIllegal] = useState(true);
|
||||||
|
const [canEdit, setCanEdit] = useState(true);
|
||||||
// 使用全局键盘状态
|
// 使用全局键盘状态
|
||||||
const {
|
const {
|
||||||
keyboardHeight,
|
keyboardHeight,
|
||||||
@@ -64,19 +65,18 @@ const EditModal: React.FC<EditModalProps> = ({
|
|||||||
}, [visible, initialValue]);
|
}, [visible, initialValue]);
|
||||||
|
|
||||||
const createExcludeRegex = (chars: string) => {
|
const createExcludeRegex = (chars: string) => {
|
||||||
// 转义正则表达式特殊字符
|
|
||||||
const escapedChars = chars.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
const escapedChars = chars.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||||
|
|
||||||
// 构建负向字符类正则表达式
|
|
||||||
// ^[^...]*$ 匹配不包含任何指定字符的完整字符串
|
|
||||||
const pattern = `[${escapedChars}]`;
|
const pattern = `[${escapedChars}]`;
|
||||||
|
|
||||||
return new RegExp(pattern);
|
return new RegExp(pattern);
|
||||||
};
|
};
|
||||||
const handle_input_change = (e: any) => {
|
const handle_input_change = (e: any) => {
|
||||||
const new_value = e.detail.value;
|
const new_value = e.detail.value;
|
||||||
setValue(new_value);
|
setValue(new_value);
|
||||||
|
let ishasIllegal = false;
|
||||||
|
if (type === "nickname") {
|
||||||
|
ishasIllegal = createExcludeRegex(invalidCharacters).test(new_value);
|
||||||
|
setHasIllegal(ishasIllegal);
|
||||||
|
}
|
||||||
const illegal =
|
const illegal =
|
||||||
/\b(SELECT|INSERT|UPDATE|DELETE|DROP|UNION|ALTER|CREATE|EXEC|DECLARE)\b|('|--|\/\*|\*\/|;|#)|(=|'|"|`|\\|\|\|&&)|\bOR\s+['"]?[\w]+['"]?\s*=\s*['"]?[\w]+['"]?|\bUNION\s+SELECT\b|\bDROP\s+TABLE\b|\bINSERT\s+INTO\b|\bUPDATE\s+[\w]+\s+SET\b|\bDELETE\s+FROM\b/i.test(
|
/\b(SELECT|INSERT|UPDATE|DELETE|DROP|UNION|ALTER|CREATE|EXEC|DECLARE)\b|('|--|\/\*|\*\/|;|#)|(=|'|"|`|\\|\|\|&&)|\bOR\s+['"]?[\w]+['"]?\s*=\s*['"]?[\w]+['"]?|\bUNION\s+SELECT\b|\bDROP\s+TABLE\b|\bINSERT\s+INTO\b|\bUPDATE\s+[\w]+\s+SET\b|\bDELETE\s+FROM\b/i.test(
|
||||||
new_value
|
new_value
|
||||||
@@ -86,22 +86,32 @@ const EditModal: React.FC<EditModalProps> = ({
|
|||||||
const valid =
|
const valid =
|
||||||
new_value.length >= 2 &&
|
new_value.length >= 2 &&
|
||||||
new_value.length <= maxLength &&
|
new_value.length <= maxLength &&
|
||||||
!createExcludeRegex(invalidCharacters).test(new_value);
|
!ishasIllegal &&
|
||||||
|
!illegal &&
|
||||||
|
canEdit;
|
||||||
setIsValid(valid);
|
setIsValid(valid);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handle_save = () => {
|
const handle_save = () => {
|
||||||
if (!isValid) {
|
if (isIllegal) {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: validationMessage || `请填写 2-${maxLength} 个字符`,
|
title: "输入的字符非法",
|
||||||
icon: "none",
|
icon: "none",
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isIllegal) {
|
if (hasIllegal) {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: "输入的字符非法",
|
title: "内容不能包含@<>/等无效字符",
|
||||||
|
icon: "none",
|
||||||
|
duration: 2000,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!isValid) {
|
||||||
|
Taro.showToast({
|
||||||
|
title: validationMessage || `请填写 2-${maxLength} 个字符`,
|
||||||
icon: "none",
|
icon: "none",
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
});
|
});
|
||||||
@@ -171,7 +181,14 @@ const EditModal: React.FC<EditModalProps> = ({
|
|||||||
</View>
|
</View>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<View style={{display: "flex", flexDirection: "column", width: "100%", height: "120px"}}>
|
<View
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
width: "100%",
|
||||||
|
height: "120px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Textarea
|
<Textarea
|
||||||
className="text_input profile"
|
className="text_input profile"
|
||||||
value={value}
|
value={value}
|
||||||
@@ -196,7 +213,12 @@ const EditModal: React.FC<EditModalProps> = ({
|
|||||||
</View>
|
</View>
|
||||||
|
|
||||||
{/* 验证提示 */}
|
{/* 验证提示 */}
|
||||||
{isIllegal ? (
|
<View className="validation_message">
|
||||||
|
<Text className="validation_text">
|
||||||
|
{validationMessage || `请填写 2-${maxLength} 个字符`}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
{/* {isIllegal ? (
|
||||||
<View className="validation_message">
|
<View className="validation_message">
|
||||||
<Text className="validation_text illegal">输入的字符非法</Text>
|
<Text className="validation_text illegal">输入的字符非法</Text>
|
||||||
</View>
|
</View>
|
||||||
@@ -208,13 +230,13 @@ const EditModal: React.FC<EditModalProps> = ({
|
|||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
)}
|
)} */}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{/* 底部按钮 */}
|
{/* 底部按钮 */}
|
||||||
<View className="modal_footer">
|
<View className="modal_footer">
|
||||||
<View
|
<View
|
||||||
className={`save_button ${!isValid || isIllegal ? "disabled" : ""}`}
|
className={`save_button ${!isValid ? "disabled" : ""}`}
|
||||||
onClick={handle_save}
|
onClick={handle_save}
|
||||||
>
|
>
|
||||||
<Text className="save_text">保存</Text>
|
<Text className="save_text">保存</Text>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import Picker from "../Picker/Picker";
|
|||||||
import CloseIcon from "@/static/ntrp/ntrp_popup_close.svg";
|
import CloseIcon from "@/static/ntrp/ntrp_popup_close.svg";
|
||||||
import styles from "./index.module.scss";
|
import styles from "./index.module.scss";
|
||||||
|
|
||||||
const ntrpLevels = ["1.5", "2.0", "2.5", "3.0", "3.5", "4.0", "4.5"];
|
const ntrpLevels = ["1.5", "2.0", "2.5", "3.0", "3.5", "4.0", "4.5", "4.5+"];
|
||||||
const options = [
|
const options = [
|
||||||
ntrpLevels.map((item) => ({
|
ntrpLevels.map((item) => ({
|
||||||
text: item,
|
text: item,
|
||||||
|
|||||||
@@ -1,19 +1,23 @@
|
|||||||
import React, { useState, useCallback, useEffect } from 'react'
|
import React, { useState, useCallback, useEffect } from "react";
|
||||||
import { Picker, ConfigProvider } from '@nutui/nutui-react-taro'
|
import { Picker, ConfigProvider } from "@nutui/nutui-react-taro";
|
||||||
import { View } from '@tarojs/components'
|
import { View } from "@tarojs/components";
|
||||||
import styles from './index.module.scss'
|
import styles from "./index.module.scss";
|
||||||
|
|
||||||
interface PickerOption {
|
interface PickerOption {
|
||||||
text: string | number
|
text: string | number;
|
||||||
value: string | number
|
value: string | number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PickerProps {
|
interface PickerProps {
|
||||||
visible: boolean
|
visible: boolean;
|
||||||
options?: PickerOption[][]
|
options?: PickerOption[][];
|
||||||
defaultValue?: (string | number)[]
|
defaultValue?: (string | number)[];
|
||||||
onConfirm?: (options: PickerOption[], values: (string | number)[]) => void
|
onConfirm?: (options: PickerOption[], values: (string | number)[]) => void;
|
||||||
onChange?: (options: PickerOption[], values: (string | number)[], columnIndex: number) => void
|
onChange?: (
|
||||||
|
options: PickerOption[],
|
||||||
|
values: (string | number)[],
|
||||||
|
columnIndex: number
|
||||||
|
) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CustomPicker = ({
|
const CustomPicker = ({
|
||||||
@@ -21,60 +25,64 @@ const CustomPicker = ({
|
|||||||
options = [],
|
options = [],
|
||||||
defaultValue = [],
|
defaultValue = [],
|
||||||
onConfirm,
|
onConfirm,
|
||||||
onChange
|
onChange,
|
||||||
}: PickerProps) => {
|
}: PickerProps) => {
|
||||||
// 使用内部状态管理当前选中的值
|
// 使用内部状态管理当前选中的值
|
||||||
const [currentValue, setCurrentValue] = useState<(string | number)[]>(defaultValue)
|
const [currentValue, setCurrentValue] =
|
||||||
|
useState<(string | number)[]>(defaultValue);
|
||||||
|
|
||||||
// 当外部 defaultValue 变化时,同步更新内部状态
|
// 当外部 defaultValue 变化时,同步更新内部状态
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
handleValuesChange(defaultValue);
|
handleValuesChange(defaultValue);
|
||||||
}, [defaultValue])
|
}, [defaultValue]);
|
||||||
|
|
||||||
const confirmPicker = (
|
const confirmPicker = (
|
||||||
options: PickerOption[],
|
options: PickerOption[],
|
||||||
values: (string | number)[]
|
values: (string | number)[]
|
||||||
) => {
|
) => {
|
||||||
let description = ''
|
let description = "";
|
||||||
options.forEach((option: any) => {
|
options.forEach((option: any) => {
|
||||||
description += ` ${option.text}`
|
description += ` ${option.text}`;
|
||||||
})
|
});
|
||||||
|
|
||||||
if (onConfirm) {
|
if (onConfirm) {
|
||||||
onConfirm(options, values)
|
onConfirm(options, values);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleValuesChange = (valuesList) => {
|
const handleValuesChange = (valuesList) => {
|
||||||
const isSame =
|
const isSame =
|
||||||
Array.isArray(valuesList) &&
|
Array.isArray(valuesList) &&
|
||||||
Array.isArray(currentValue) &&
|
Array.isArray(currentValue) &&
|
||||||
valuesList.length === currentValue.length &&
|
valuesList.length === currentValue.length &&
|
||||||
valuesList.every((v: any, idx: number) => v === currentValue[idx])
|
valuesList.every((v: any, idx: number) => v === currentValue[idx]);
|
||||||
if (!isSame) {
|
if (!isSame) {
|
||||||
setCurrentValue(valuesList)
|
setCurrentValue(valuesList);
|
||||||
}
|
}
|
||||||
return isSame;
|
return isSame;
|
||||||
}
|
};
|
||||||
|
|
||||||
const changePicker = useCallback((options: any[], values: any, columnIndex: number) => {
|
const changePicker = useCallback(
|
||||||
|
(options: any[], values: any, columnIndex: number) => {
|
||||||
// 值相同则不触发更新,避免受控/非受控同步造成的回流循环
|
// 值相同则不触发更新,避免受控/非受控同步造成的回流循环
|
||||||
|
|
||||||
const isSame = handleValuesChange(values)
|
const isSame = handleValuesChange(values);
|
||||||
if (onChange && !isSame) {
|
if (onChange && !isSame) {
|
||||||
onChange(options, values, columnIndex)
|
onChange(options, values, columnIndex);
|
||||||
}
|
}
|
||||||
}, [onChange, currentValue])
|
},
|
||||||
|
[onChange, currentValue]
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<View className={styles['picker-container']}>
|
<View className={styles["picker-container"]}>
|
||||||
<ConfigProvider
|
<ConfigProvider
|
||||||
theme={{
|
theme={{
|
||||||
nutuiPickerItemHeight: '48px',
|
nutuiPickerItemHeight: "48px",
|
||||||
nutuiPickerItemActiveLineBorder: 'none',
|
nutuiPickerItemActiveLineBorder: "none",
|
||||||
nutuiPickerItemTextColor: '#000',
|
nutuiPickerItemTextColor: "#000",
|
||||||
nutuiPickerItemFontSize: '20px',
|
nutuiPickerItemFontSize: "20px",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Picker
|
<Picker
|
||||||
@@ -92,7 +100,7 @@ const CustomPicker = ({
|
|||||||
</ConfigProvider>
|
</ConfigProvider>
|
||||||
</View>
|
</View>
|
||||||
</>
|
</>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default CustomPicker
|
export default CustomPicker;
|
||||||
|
|||||||
@@ -152,25 +152,6 @@ const PopupPicker = ({
|
|||||||
<View className={styles.evaluateCardWrap}>
|
<View className={styles.evaluateCardWrap}>
|
||||||
<NTRPTestEntryCard type={EvaluateScene.userEdit} />
|
<NTRPTestEntryCard type={EvaluateScene.userEdit} />
|
||||||
</View>
|
</View>
|
||||||
// <View className={`${styles["examination-btn"]}}`}>
|
|
||||||
// <View className={`${styles["text-container"]}}`}>
|
|
||||||
// <View className={`${styles["text-title"]}}`}>
|
|
||||||
// 不知道自己的<Text>(NTRP)</Text>水平
|
|
||||||
// </View>
|
|
||||||
// <View className={`${styles["text-btn"]}}`}>
|
|
||||||
// <Text>快速测试</Text>
|
|
||||||
// <Image src={imgs.ICON_ARROW_GREEN} className={`${styles["icon-arrow"]}`}></Image>
|
|
||||||
// </View>
|
|
||||||
// </View>
|
|
||||||
// <View className={`${styles["img-container"]}}`}>
|
|
||||||
// <View className={`${styles["img-box"]}`}>
|
|
||||||
// <Image src={img!}></Image>
|
|
||||||
// </View>
|
|
||||||
// <View className={`${styles["img-box"]}`}>
|
|
||||||
// <Image src={imgs.ICON_EXAMINATION}></Image>
|
|
||||||
// </View>
|
|
||||||
// </View>
|
|
||||||
// </View>
|
|
||||||
)}
|
)}
|
||||||
<Picker
|
<Picker
|
||||||
visible={visible}
|
visible={visible}
|
||||||
|
|||||||
@@ -607,7 +607,7 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
|
|||||||
onCancel={handle_edit_modal_cancel}
|
onCancel={handle_edit_modal_cancel}
|
||||||
validationMessage={
|
validationMessage={
|
||||||
editing_field === "nickname"
|
editing_field === "nickname"
|
||||||
? "请填写 2-24 个字符,不包括 @<>/等无效字符"
|
? "请填写 2-24 个字符,不包括 @<>/等无效字符。30 天内可修改 4 次昵称,12.5 前还可修改 4 次。"
|
||||||
: "请填写 2-100 个字符"
|
: "请填写 2-100 个字符"
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
@@ -663,7 +663,6 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
|
|||||||
title="选择 NTRP 自评水平"
|
title="选择 NTRP 自评水平"
|
||||||
ntrpTested={ntrpTested}
|
ntrpTested={ntrpTested}
|
||||||
options={[
|
options={[
|
||||||
[
|
|
||||||
{ text: "1.5", value: "1.5" },
|
{ text: "1.5", value: "1.5" },
|
||||||
{ text: "2.0", value: "2.0" },
|
{ text: "2.0", value: "2.0" },
|
||||||
{ text: "2.5", value: "2.5" },
|
{ text: "2.5", value: "2.5" },
|
||||||
@@ -672,17 +671,12 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
|
|||||||
{ text: "4.0", value: "4.0" },
|
{ text: "4.0", value: "4.0" },
|
||||||
{ text: "4.5", value: "4.5" },
|
{ text: "4.5", value: "4.5" },
|
||||||
{ text: "4.5+", value: "4.5+" },
|
{ text: "4.5+", value: "4.5+" },
|
||||||
],
|
|
||||||
]}
|
]}
|
||||||
type="ntrp"
|
type="ntrp"
|
||||||
img={user_info.avatar_url || ""}
|
img={user_info.avatar_url || ""}
|
||||||
visible={ntrp_picker_visible}
|
visible={ntrp_picker_visible}
|
||||||
setvisible={setNtrpPickerVisible}
|
setvisible={setNtrpPickerVisible}
|
||||||
value={
|
value={[form_data.ntrp_level || "2.5"]}
|
||||||
!form_data.ntrp_level || form_data.ntrp_level === "0"
|
|
||||||
? ["2.5"]
|
|
||||||
: [form_data.ntrp_level]
|
|
||||||
}
|
|
||||||
onChange={handle_ntrp_level_change}
|
onChange={handle_ntrp_level_change}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -251,6 +251,9 @@
|
|||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
|
&.placeholder {
|
||||||
|
color: rgba(60, 60, 67, 0.3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.bio_textarea {
|
.bio_textarea {
|
||||||
|
|||||||
@@ -27,10 +27,10 @@ const EditProfilePage: React.FC = () => {
|
|||||||
nickname: info?.nickname ?? "",
|
nickname: info?.nickname ?? "",
|
||||||
personal_profile: info?.personal_profile ?? "",
|
personal_profile: info?.personal_profile ?? "",
|
||||||
occupation: info?.occupation ?? "",
|
occupation: info?.occupation ?? "",
|
||||||
ntrp_level: info?.ntrp_level ?? "2.5",
|
ntrp_level: info?.ntrp_level ?? "",
|
||||||
phone: info?.phone ?? "",
|
phone: info?.phone ?? "",
|
||||||
gender: info?.gender ?? "",
|
gender: info?.gender ?? "",
|
||||||
birthday: info?.birthday ?? "2000-01-01",
|
birthday: info?.birthday ?? "",
|
||||||
country: info?.country ?? "",
|
country: info?.country ?? "",
|
||||||
province: info?.province ?? "",
|
province: info?.province ?? "",
|
||||||
city: info?.city ?? "",
|
city: info?.city ?? "",
|
||||||
@@ -68,10 +68,10 @@ const EditProfilePage: React.FC = () => {
|
|||||||
nickname: info?.nickname ?? "",
|
nickname: info?.nickname ?? "",
|
||||||
personal_profile: info?.personal_profile ?? "",
|
personal_profile: info?.personal_profile ?? "",
|
||||||
occupation: info?.occupation ?? "",
|
occupation: info?.occupation ?? "",
|
||||||
ntrp_level: info?.ntrp_level ?? "2.5",
|
ntrp_level: info?.ntrp_level ?? "",
|
||||||
phone: info?.phone ?? "",
|
phone: info?.phone ?? "",
|
||||||
gender: info?.gender ?? "",
|
gender: info?.gender ?? "",
|
||||||
birthday: info?.birthday ?? "2000-01-01",
|
birthday: info?.birthday ?? "",
|
||||||
country: info?.country ?? "",
|
country: info?.country ?? "",
|
||||||
province: info?.province ?? "",
|
province: info?.province ?? "",
|
||||||
city: info?.city ?? "",
|
city: info?.city ?? "",
|
||||||
@@ -350,15 +350,15 @@ const EditProfilePage: React.FC = () => {
|
|||||||
|
|
||||||
// 处理NTRP水平选择
|
// 处理NTRP水平选择
|
||||||
const handle_ntrp_level_change = (e: any) => {
|
const handle_ntrp_level_change = (e: any) => {
|
||||||
if (!Array.isArray(e) || e.length === 0 || e[0] === undefined) {
|
// if (!Array.isArray(e) || e.length === 0 || e[0] === undefined) {
|
||||||
Taro.showToast({
|
// Taro.showToast({
|
||||||
title: "请选择NTRP水平",
|
// title: "请选择NTRP水平",
|
||||||
icon: "none",
|
// icon: "none",
|
||||||
});
|
// });
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
const ntrp_level_value = e[0];
|
const ntrp_level_value = e[0];
|
||||||
handle_field_edit("ntrp_level", String(ntrp_level_value));
|
handle_field_edit("ntrp_level", ntrp_level_value);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 处理职业选择
|
// 处理职业选择
|
||||||
@@ -543,7 +543,11 @@ const EditProfilePage: React.FC = () => {
|
|||||||
<Text className="item_label">性别</Text>
|
<Text className="item_label">性别</Text>
|
||||||
</View>
|
</View>
|
||||||
<View className="item_right">
|
<View className="item_right">
|
||||||
<Text className="item_value">
|
<Text
|
||||||
|
className={`item_value ${
|
||||||
|
form_data.gender ? "" : "placeholder"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
{convert_db_gender_to_display(form_data.gender)}
|
{convert_db_gender_to_display(form_data.gender)}
|
||||||
</Text>
|
</Text>
|
||||||
<Image
|
<Image
|
||||||
@@ -572,7 +576,13 @@ const EditProfilePage: React.FC = () => {
|
|||||||
<Text className="item_label">生日</Text>
|
<Text className="item_label">生日</Text>
|
||||||
</View>
|
</View>
|
||||||
<View className="item_right">
|
<View className="item_right">
|
||||||
<Text className="item_value">{form_data.birthday}</Text>
|
<Text
|
||||||
|
className={`item_value ${
|
||||||
|
form_data.birthday ? "" : "placeholder"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{form_data.birthday || "选择生日"}
|
||||||
|
</Text>
|
||||||
<Image
|
<Image
|
||||||
className="arrow_icon"
|
className="arrow_icon"
|
||||||
src={require("@/static/list/icon-list-right-arrow.svg")}
|
src={require("@/static/list/icon-list-right-arrow.svg")}
|
||||||
@@ -597,7 +607,11 @@ const EditProfilePage: React.FC = () => {
|
|||||||
<Text className="item_label">简介</Text>
|
<Text className="item_label">简介</Text>
|
||||||
</View>
|
</View>
|
||||||
<View className="item_right">
|
<View className="item_right">
|
||||||
<Text className="item_value">
|
<Text
|
||||||
|
className={`item_value ${
|
||||||
|
form_data.personal_profile ? "" : "placeholder"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
{form_data.personal_profile.replace(/\n/g, " ") ||
|
{form_data.personal_profile.replace(/\n/g, " ") ||
|
||||||
"介绍一下自己"}
|
"介绍一下自己"}
|
||||||
</Text>
|
</Text>
|
||||||
@@ -626,7 +640,19 @@ const EditProfilePage: React.FC = () => {
|
|||||||
<Text className="item_label">地区</Text>
|
<Text className="item_label">地区</Text>
|
||||||
</View>
|
</View>
|
||||||
<View className="item_right">
|
<View className="item_right">
|
||||||
<Text className="item_value">{`${form_data.country} ${form_data.province} ${form_data.city}`}</Text>
|
<Text
|
||||||
|
className={`item_value ${
|
||||||
|
form_data.country ||
|
||||||
|
form_data.province ||
|
||||||
|
form_data.city
|
||||||
|
? ""
|
||||||
|
: "placehoder"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{form_data.country || form_data.province || form_data.city
|
||||||
|
? `${form_data.country} ${form_data.province} ${form_data.city}`
|
||||||
|
: "选择所在地区"}
|
||||||
|
</Text>
|
||||||
<Image
|
<Image
|
||||||
className="arrow_icon"
|
className="arrow_icon"
|
||||||
src={require("@/static/list/icon-list-right-arrow.svg")}
|
src={require("@/static/list/icon-list-right-arrow.svg")}
|
||||||
@@ -648,7 +674,13 @@ const EditProfilePage: React.FC = () => {
|
|||||||
<Text className="item_label">NTRP 水平</Text>
|
<Text className="item_label">NTRP 水平</Text>
|
||||||
</View>
|
</View>
|
||||||
<View className="item_right">
|
<View className="item_right">
|
||||||
<Text className="item_value">{form_data.ntrp_level}</Text>
|
<Text
|
||||||
|
className={`item_value ${
|
||||||
|
form_data.ntrp_level ? "" : "placeholder"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{form_data.ntrp_level || "测测你的 NTRP 水平"}
|
||||||
|
</Text>
|
||||||
<Image
|
<Image
|
||||||
className="arrow_icon"
|
className="arrow_icon"
|
||||||
src={require("@/static/list/icon-list-right-arrow.svg")}
|
src={require("@/static/list/icon-list-right-arrow.svg")}
|
||||||
@@ -669,8 +701,18 @@ const EditProfilePage: React.FC = () => {
|
|||||||
/>
|
/>
|
||||||
<Text className="item_label">职业</Text>
|
<Text className="item_label">职业</Text>
|
||||||
</View>
|
</View>
|
||||||
<View className="item_right">
|
<View
|
||||||
<Text className="item_value">{form_data.occupation}</Text>
|
className={`item_right ${
|
||||||
|
form_data.occupation ? "" : "placeholder"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<Text
|
||||||
|
className={`item_value ${
|
||||||
|
form_data.occupation ? "" : "placeholder"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{form_data.occupation || "填写你的职业"}
|
||||||
|
</Text>
|
||||||
<Image
|
<Image
|
||||||
className="arrow_icon"
|
className="arrow_icon"
|
||||||
src={require("@/static/list/icon-list-right-arrow.svg")}
|
src={require("@/static/list/icon-list-right-arrow.svg")}
|
||||||
@@ -769,7 +811,7 @@ const EditProfilePage: React.FC = () => {
|
|||||||
onCancel={handle_edit_modal_cancel}
|
onCancel={handle_edit_modal_cancel}
|
||||||
validationMessage={
|
validationMessage={
|
||||||
editing_field === "nickname"
|
editing_field === "nickname"
|
||||||
? "请填写 2-24 个字符,不包括 @<>/等无效字符"
|
? "请填写 2-24 个字符,不包括 @<>/等无效字符。30 天内可修改 4 次昵称,12.5 前还可修改 4 次。"
|
||||||
: "请填写 2-100 个字符"
|
: "请填写 2-100 个字符"
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
@@ -803,9 +845,9 @@ const EditProfilePage: React.FC = () => {
|
|||||||
visible={birthday_picker_visible}
|
visible={birthday_picker_visible}
|
||||||
setvisible={setBirthdayPickerVisible}
|
setvisible={setBirthdayPickerVisible}
|
||||||
value={[
|
value={[
|
||||||
new Date(form_data.birthday).getFullYear(),
|
new Date(form_data.birthday || Date.now()).getFullYear(),
|
||||||
new Date(form_data.birthday).getMonth() + 1,
|
new Date(form_data.birthday || Date.now()).getMonth() + 1,
|
||||||
new Date(form_data.birthday).getDate(),
|
new Date(form_data.birthday || Date.now()).getDate(),
|
||||||
]}
|
]}
|
||||||
type="day"
|
type="day"
|
||||||
onChange={handle_birthday_change}
|
onChange={handle_birthday_change}
|
||||||
@@ -836,7 +878,6 @@ const EditProfilePage: React.FC = () => {
|
|||||||
confirmText="保存"
|
confirmText="保存"
|
||||||
ntrpTested={ntrpTested}
|
ntrpTested={ntrpTested}
|
||||||
options={[
|
options={[
|
||||||
[
|
|
||||||
{ text: "1.5", value: "1.5" },
|
{ text: "1.5", value: "1.5" },
|
||||||
{ text: "2.0", value: "2.0" },
|
{ text: "2.0", value: "2.0" },
|
||||||
{ text: "2.5", value: "2.5" },
|
{ text: "2.5", value: "2.5" },
|
||||||
@@ -845,13 +886,12 @@ const EditProfilePage: React.FC = () => {
|
|||||||
{ text: "4.0", value: "4.0" },
|
{ text: "4.0", value: "4.0" },
|
||||||
{ text: "4.5", value: "4.5" },
|
{ text: "4.5", value: "4.5" },
|
||||||
{ text: "4.5+", value: "4.5+" },
|
{ text: "4.5+", value: "4.5+" },
|
||||||
],
|
|
||||||
]}
|
]}
|
||||||
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 === "" ? ["2.5"] : [form_data.ntrp_level]}
|
value={[form_data.ntrp_level || "2.5"]}
|
||||||
onChange={handle_ntrp_level_change}
|
onChange={handle_ntrp_level_change}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -182,7 +182,7 @@
|
|||||||
padding: 12px 16px 12px 12px;
|
padding: 12px 16px 12px 12px;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
background: #000000;
|
background: #000000;
|
||||||
border: 0.5px solid rgba(0, 0, 0, 0.06);
|
border: 0.5pt solid rgba(0, 0, 0, 0.06);
|
||||||
border-radius: 999px;
|
border-radius: 999px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: all 0.3s ease;
|
transition: all 0.3s ease;
|
||||||
|
|||||||
@@ -12,14 +12,14 @@
|
|||||||
*/
|
*/
|
||||||
export const convert_db_gender_to_display = (db_gender: string): string => {
|
export const convert_db_gender_to_display = (db_gender: string): string => {
|
||||||
switch (db_gender) {
|
switch (db_gender) {
|
||||||
case '0':
|
case "0":
|
||||||
return '男';
|
return "男";
|
||||||
case '1':
|
case "1":
|
||||||
return '女';
|
return "女";
|
||||||
case '2':
|
case "2":
|
||||||
return '保密';
|
return "保密";
|
||||||
default:
|
default:
|
||||||
return '未知';
|
return "选择性别";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -28,16 +28,18 @@ export const convert_db_gender_to_display = (db_gender: string): string => {
|
|||||||
* @param display_gender 页面显示文本 ('男' | '女')
|
* @param display_gender 页面显示文本 ('男' | '女')
|
||||||
* @returns 数据库性别值 ('0' | '1')
|
* @returns 数据库性别值 ('0' | '1')
|
||||||
*/
|
*/
|
||||||
export const convert_display_gender_to_db = (display_gender: string): string => {
|
export const convert_display_gender_to_db = (
|
||||||
|
display_gender: string
|
||||||
|
): string => {
|
||||||
switch (display_gender) {
|
switch (display_gender) {
|
||||||
case '男':
|
case "男":
|
||||||
return '0';
|
return "0";
|
||||||
case '女':
|
case "女":
|
||||||
return '1';
|
return "1";
|
||||||
case '保密':
|
case "保密":
|
||||||
return '2';
|
return "2";
|
||||||
default:
|
default:
|
||||||
return '0'; // 默认返回男性
|
return "0"; // 默认返回男性
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -49,11 +51,11 @@ export const convert_display_gender_to_db = (display_gender: string): string =>
|
|||||||
export const convert_wechat_gender_to_db = (wechat_gender: number): string => {
|
export const convert_wechat_gender_to_db = (wechat_gender: number): string => {
|
||||||
switch (wechat_gender) {
|
switch (wechat_gender) {
|
||||||
case 1: // 微信:1 = 男
|
case 1: // 微信:1 = 男
|
||||||
return '0'; // 数据库:'0' = 男
|
return "0"; // 数据库:'0' = 男
|
||||||
case 2: // 微信:2 = 女
|
case 2: // 微信:2 = 女
|
||||||
return '1'; // 数据库:'1' = 女
|
return "1"; // 数据库:'1' = 女
|
||||||
default: // 微信:0 = 未知
|
default: // 微信:0 = 未知
|
||||||
return '0'; // 默认返回男性
|
return "0"; // 默认返回男性
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -64,9 +66,9 @@ export const convert_wechat_gender_to_db = (wechat_gender: number): string => {
|
|||||||
*/
|
*/
|
||||||
export const convert_db_gender_to_wechat = (db_gender: string): number => {
|
export const convert_db_gender_to_wechat = (db_gender: string): number => {
|
||||||
switch (db_gender) {
|
switch (db_gender) {
|
||||||
case '0':
|
case "0":
|
||||||
return 1; // 微信:1 = 男
|
return 1; // 微信:1 = 男
|
||||||
case '1':
|
case "1":
|
||||||
return 2; // 微信:2 = 女
|
return 2; // 微信:2 = 女
|
||||||
default:
|
default:
|
||||||
return 1; // 默认返回男性
|
return 1; // 默认返回男性
|
||||||
|
|||||||
Reference in New Issue
Block a user