feat: 支持会员编号
This commit is contained in:
@@ -212,6 +212,9 @@ export default function PersonalScreen() {
|
||||
<TouchableOpacity onPress={handleUserNamePress} activeOpacity={0.7}>
|
||||
<Text style={styles.userName}>{displayName}</Text>
|
||||
</TouchableOpacity>
|
||||
{userProfile.memberNumber && (
|
||||
<Text style={styles.userMemberNumber}>会员编号: {userProfile.memberNumber}</Text>
|
||||
)}
|
||||
</View>
|
||||
<TouchableOpacity style={styles.editButton} onPress={() => pushIfAuthedElseLogin('/profile/edit')}>
|
||||
<Text style={styles.editButtonText}>{isLoggedIn ? '编辑' : '登录'}</Text>
|
||||
@@ -480,6 +483,11 @@ const styles = StyleSheet.create({
|
||||
color: '#9370DB',
|
||||
fontWeight: '500',
|
||||
},
|
||||
userMemberNumber: {
|
||||
fontSize: 10,
|
||||
color: '#6C757D',
|
||||
marginTop: 4,
|
||||
},
|
||||
editButton: {
|
||||
backgroundColor: '#9370DB',
|
||||
paddingHorizontal: 16,
|
||||
|
||||
@@ -20,12 +20,16 @@ export async function preloadUserData() {
|
||||
AsyncStorage.getItem(STORAGE_KEYS.authToken),
|
||||
]);
|
||||
|
||||
let profile: UserProfile = {};
|
||||
let profile: UserProfile = {
|
||||
memberNumber: 0
|
||||
};
|
||||
if (profileStr) {
|
||||
try {
|
||||
profile = JSON.parse(profileStr) as UserProfile;
|
||||
} catch {
|
||||
profile = {};
|
||||
profile = {
|
||||
memberNumber: 0
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +44,11 @@ export async function preloadUserData() {
|
||||
return preloadedUserData;
|
||||
} catch (error) {
|
||||
console.error('预加载用户数据失败:', error);
|
||||
preloadedUserData = { token: null, profile: {}, privacyAgreed: false };
|
||||
preloadedUserData = {
|
||||
token: null, profile: {
|
||||
memberNumber: 0
|
||||
}, privacyAgreed: false
|
||||
};
|
||||
return preloadedUserData;
|
||||
}
|
||||
}
|
||||
@@ -57,6 +65,7 @@ export type UserProfile = {
|
||||
name?: string;
|
||||
email?: string;
|
||||
gender?: Gender;
|
||||
memberNumber: number
|
||||
birthDate?: string;
|
||||
weight?: string;
|
||||
height?: string;
|
||||
@@ -108,6 +117,7 @@ const getInitialState = (): UserState => {
|
||||
name: DEFAULT_MEMBER_NAME,
|
||||
isVip: false,
|
||||
freeUsageCount: 3,
|
||||
memberNumber: 0,
|
||||
maxUsageCount: 5,
|
||||
...preloaded.profile, // 合并预加载的用户资料
|
||||
},
|
||||
@@ -340,7 +350,9 @@ const userSlice = createSlice({
|
||||
})
|
||||
.addCase(logout.fulfilled, (state) => {
|
||||
state.token = null;
|
||||
state.profile = {};
|
||||
state.profile = {
|
||||
memberNumber: 0
|
||||
};
|
||||
})
|
||||
.addCase(setPrivacyAgreed.fulfilled, (state) => {
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user