|
|
@ -76,10 +76,13 @@ import { onLoad } from '@dcloudio/uni-app' |
|
|
|
import { ref } from 'vue' |
|
|
|
import type { Gender, ProfileDetail } from '@/types/member' |
|
|
|
import { getMemberProfileAPI, putMemberProfileAPI } from '@/services/profile' |
|
|
|
import { useMemberStore } from '@/stores' |
|
|
|
|
|
|
|
// 获取屏幕边界到安全区域距离 |
|
|
|
const { safeAreaInsets } = uni.getSystemInfoSync() |
|
|
|
|
|
|
|
const memberStore = useMemberStore() |
|
|
|
|
|
|
|
// 获取个人信息,修改个人信息需提供初始值 |
|
|
|
const profile = ref({} as ProfileDetail) |
|
|
|
const getMemberProfileData = async () => { |
|
|
@ -110,6 +113,8 @@ const onAvatarChange = () => { |
|
|
|
const { avatar } = JSON.parse(res.data).result |
|
|
|
// 当前页面更新头像 |
|
|
|
profile.value!.avatar = avatar |
|
|
|
// Store头像更新 |
|
|
|
memberStore.profile!.avatar = avatar |
|
|
|
uni.showToast({ icon: 'success', title: '更新成功' }) |
|
|
|
} else { |
|
|
|
uni.showToast({ icon: 'error', title: '出现错误' }) |
|
|
@ -125,12 +130,18 @@ const onSubmit = async () => { |
|
|
|
const res = await putMemberProfileAPI({ |
|
|
|
nickname: profile.value.nickname, |
|
|
|
}) |
|
|
|
// 更新Store昵称 |
|
|
|
memberStore.profile!.nickname = res.result.nickname |
|
|
|
// 成功提示 |
|
|
|
uni.showToast({ |
|
|
|
icon: 'success', |
|
|
|
title: '保存成功', |
|
|
|
}) |
|
|
|
setTimeout(() => { |
|
|
|
uni.navigateBack() |
|
|
|
}, 400) |
|
|
|
} |
|
|
|
|
|
|
|
onLoad(() => { |
|
|
|
getMemberProfileData() |
|
|
|
}) |
|
|
|