Browse Source

个人信息同步头像和昵称

template
liruiqiang 2 months ago
parent
commit
dd2b77bea9
  1. 11
      src/pagesMember/profile/profile.vue

11
src/pagesMember/profile/profile.vue

@ -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()
})

Loading…
Cancel
Save