From 769c967f7c6ca9bbd2464b0b4d42df1764e415d1 Mon Sep 17 00:00:00 2001 From: liruiqiang <3151805288@qq.com> Date: Thu, 21 Aug 2025 15:01:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=BF=A1=E6=81=AF=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=98=B5=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pagesMember/profile/profile.vue | 21 ++++++++++++++++----- src/services/profile.ts | 14 +++++++++++++- src/types/member.d.ts | 13 +++++++++++++ 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/src/pagesMember/profile/profile.vue b/src/pagesMember/profile/profile.vue index f1c0a52..35cd517 100644 --- a/src/pagesMember/profile/profile.vue +++ b/src/pagesMember/profile/profile.vue @@ -22,7 +22,7 @@ 昵称 - + 性别 @@ -66,7 +66,7 @@ - + @@ -75,13 +75,13 @@ import { onLoad } from '@dcloudio/uni-app' import { ref } from 'vue' import type { Gender, ProfileDetail } from '@/types/member' -import { getMemberProfileAPI } from '@/services/profile' +import { getMemberProfileAPI, putMemberProfileAPI } from '@/services/profile' // 获取屏幕边界到安全区域距离 const { safeAreaInsets } = uni.getSystemInfoSync() -// 获取个人信息 -const profile = ref() +// 获取个人信息,修改个人信息需提供初始值 +const profile = ref({} as ProfileDetail) const getMemberProfileData = async () => { const res = await getMemberProfileAPI() profile.value = res.result @@ -120,6 +120,17 @@ const onAvatarChange = () => { }) } +const onSubmit = async () => { + //修改个人信息 + const res = await putMemberProfileAPI({ + nickname: profile.value.nickname, + }) + // 成功提示 + uni.showToast({ + icon: 'success', + title: '保存成功', + }) +} onLoad(() => { getMemberProfileData() }) diff --git a/src/services/profile.ts b/src/services/profile.ts index eb224f0..eb6d200 100644 --- a/src/services/profile.ts +++ b/src/services/profile.ts @@ -1,4 +1,4 @@ -import type { ProfileDetail } from '@/types/member' +import type { ProfileDetail, ProfileParams } from '@/types/member' import { http } from '@/utils/http' /** @@ -10,3 +10,15 @@ export const getMemberProfileAPI = () => { url: '/member/profile', }) } + +/** + * 修改个人信息 + * @param data 请求体参数 + */ +export const putMemberProfileAPI = (data: ProfileParams) => { + return http({ + method: 'PUT', + url: '/member/profile', + data, + }) +} diff --git a/src/types/member.d.ts b/src/types/member.d.ts index 85dda74..a31fc0f 100644 --- a/src/types/member.d.ts +++ b/src/types/member.d.ts @@ -31,3 +31,16 @@ export type ProfileDetail = BaseProfile & { } /** 性别 */ export type Gender = '女' | '男' + +/** 个人信息 修改请求体参数 */ +export type ProfileParams = Pick< + ProfileDetail, + 'nickname' | 'gender' | 'birthday' | 'profession' +> & { + /** 省份编码 */ + provinceCode?: string + /** 城市编码 */ + cityCode?: string + /** 区/县编码 */ + countyCode?: string +}