Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
飞
飞鹤小程序
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
FH
飞鹤小程序
Commits
5639f6e0
Commit
5639f6e0
authored
Nov 04, 2025
by
王炽
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
66666
parent
e7541c01
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
201 additions
and
9 deletions
+201
-9
My.vue
views/My.vue
+201
-9
No files found.
views/My.vue
View file @
5639f6e0
...
...
@@ -6,12 +6,14 @@
:iconSelected=
"$baseUrl + 'my/track/icon_stage_sel.png'"
@
update:selectedIndex=
"(val) => (wheelSelectedIndex = val)"
@
change=
"handleWheelChange"
/>
</view>
<view
class=
"bg-container"
:data-log=
"
{
<view
class=
"bg-container"
v-if=
"cfgStatus.isRegister"
:data-log=
"
{
xcxClick: '我的页面点击',
pageName: '我的页面',
buttonName: '个人信息修改',
}" @click="handle
EditProfile
">
<image
class=
"bg-img"
:src=
"babyInfo?.content?.backgroundImg || $baseUrl + 'my/default_bg.png'
}" @click="handle
UploadBackground
">
<image
class=
"bg-img"
:src=
"
localBackgroundImg ||
babyInfo?.content?.backgroundImg || $baseUrl + 'my/default_bg.png'
"
mode=
"widthFix"
lazy-load=
"false"
binderror=
""
bindload=
""
/>
<image
class=
"banner_cover"
:src=
"$baseUrl + 'my/cover_white.png'"
mode=
"aspectFill"
/>
</view>
...
...
@@ -21,14 +23,16 @@
<!-- 用户信息区域 -->
<view
class=
"user-info"
:style=
"
{ 'min-height': cfgStatus.showDetail ? '343rpx' : '168rpx' }">
<view
class=
"user-header"
>
<view
class=
"avatar-container"
@
click=
"handleEditProfile"
:data-log=
"
{
<view
class=
"avatar-container"
>
<button
class=
"avatar-wrapper"
:data-log=
"
{
xcxClick: '我的页面点击',
pageName: '我的页面',
buttonName: '个人信息修改',
}">
<image
class=
"avatar"
:src=
"babyInfo?.content?.babyAvatar ||
$baseUrl + 'common/default_avatar.png'
"
mode=
"widthFix"
/>
}" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
<image
class=
"avatar"
:src=
"localAvatarUrl || babyInfo?.content?.babyAvatar ||
$baseUrl + 'common/default_avatar.png'
"
mode=
"widthFix"
/>
</button>
</view>
<button
v-if=
"!cfgStatus.isRegister"
type=
"primary"
class=
"avatar-container"
@
click=
"clickRegisterShield"
/>
<image
class=
"avatar-modify"
:src=
"$baseUrl + 'my/icon_modify.png'"
mode=
"aspectFit"
lazy-load=
"false"
/>
...
...
@@ -310,6 +314,12 @@ const points = ref(0);
const
babyId
=
ref
(
0
);
// 本地头像 URL,用于临时显示上传后的头像
const
localAvatarUrl
=
ref
(
''
);
// 本地背景图片 URL,用于临时显示上传后的背景图
const
localBackgroundImg
=
ref
(
''
);
const
handleTaskClick
=
async
()
=>
{
// 添加点击埋点
md
.
sensorComponentLogTake
({
...
...
@@ -546,11 +556,85 @@ const handleEditProfile = (e) => {
if
(
type
===
"edit"
)
{
babyId
.
value
=
userStore
.
babyInfo
?.
allBabyBaseInfo
.
find
(
(
item
)
=>
item
.
selected
)?.
id
;
)?.
id
;
navigateTo
(
`/pages/person/person?type=
${
type
}
&id=
${
babyId
.
value
}
`
);
}
else
{
navigateTo
(
`/pages/person/person?type=
${
type
}
`
);
}
};
// 选择头像
const
onChooseAvatar
=
async
(
e
)
=>
{
showLoading
(
'上传中...'
);
md
.
sensorLog
(
e
);
md
.
sensorComponentLogTake
({
xcxComponentClick
:
"true"
,
pageName
:
"我的页面"
,
componentName
:
"资料编辑"
,
componentContent
:
"资料编辑"
})
try
{
const
fs
=
uni
.
getFileSystemManager
();
const
base64
=
"data:image/jpeg;base64,"
+
fs
.
readFileSync
(
e
.
detail
.
avatarUrl
,
"base64"
);
const
res
=
await
uploadImage
(
base64
);
if
(
res
.
success
)
{
// 立即更新本地显示的头像
localAvatarUrl
.
value
=
res
.
data
.
url
;
// 获取当前选中的宝宝信息并更新到服务器
const
selectedBaby
=
userStore
.
babyInfo
?.
allBabyBaseInfo
?.
find
(
(
item
)
=>
item
.
selected
);
if
(
selectedBaby
)
{
const
updateData
=
{
id
:
selectedBaby
.
id
,
babyAvatar
:
res
.
data
.
url
,
};
const
updateRes
=
await
updateBabyInfo
(
updateData
);
if
(
updateRes
.
success
)
{
// 刷新用户信息
await
userStore
.
loadBabyInfo
();
// 清空本地临时头像,使用更新后的 babyInfo
localAvatarUrl
.
value
=
''
;
uni
.
showToast
({
title
:
"头像更新成功"
,
icon
:
"success"
,
});
}
else
{
uni
.
showToast
({
title
:
updateRes
.
message
||
"更新失败"
,
icon
:
"none"
,
});
}
}
else
{
uni
.
showToast
({
title
:
"未找到宝宝信息"
,
icon
:
"none"
,
});
}
}
else
{
uni
.
showToast
({
title
:
res
.
message
,
icon
:
"none"
,
});
}
}
catch
(
error
)
{
console
.
error
(
"头像选择失败:"
,
error
);
uni
.
showToast
({
title
:
"头像选择失败"
,
icon
:
"none"
,
});
}
finally
{
hideLoading
();
}
};
const
onRegisterConfirm
=
async
()
=>
{
...
...
@@ -867,6 +951,103 @@ const handleOpenClick = () => {
cfgStatus
.
value
.
openBabyCardDesc
=
!
cfgStatus
.
value
.
openBabyCardDesc
;
};
// 上传背景图片
const
handleUploadBackground
=
async
(
e
)
=>
{
// 检查登录状态
if
(
!
cfgStatus
.
value
.
isRegister
)
{
return
;
}
md
.
sensorLog
(
e
);
md
.
sensorComponentLogTake
({
xcxComponentClick
:
"true"
,
pageName
:
"我的页面"
,
componentName
:
"资料编辑"
,
componentContent
:
"资料编辑"
})
// 唤起图片选择器
uni
.
chooseImage
({
count
:
1
,
sizeType
:
[
"original"
,
"compressed"
],
sourceType
:
[
"album"
,
"camera"
],
success
:
async
(
res
)
=>
{
showLoading
(
'上传中...'
);
try
{
const
tempFilePath
=
res
.
tempFilePaths
[
0
];
const
fs
=
uni
.
getFileSystemManager
();
const
base64
=
"data:image/jpeg;base64,"
+
fs
.
readFileSync
(
tempFilePath
,
"base64"
);
const
uploadRes
=
await
uploadImage
(
base64
);
if
(
uploadRes
.
success
)
{
// 立即更新本地显示的背景图
localBackgroundImg
.
value
=
uploadRes
.
data
.
url
;
// 获取当前选中的宝宝信息并更新到服务器
const
selectedBaby
=
userStore
.
babyInfo
?.
allBabyBaseInfo
?.
find
(
(
item
)
=>
item
.
selected
);
if
(
selectedBaby
)
{
const
updateData
=
{
id
:
selectedBaby
.
id
,
backgroundImg
:
uploadRes
.
data
.
url
,
};
const
updateRes
=
await
updateBabyInfo
(
updateData
);
if
(
updateRes
.
success
)
{
// 刷新用户信息
await
userStore
.
loadBabyInfo
();
// 清空本地临时背景图,使用更新后的 babyInfo
localBackgroundImg
.
value
=
''
;
uni
.
showToast
({
title
:
"背景更新成功"
,
icon
:
"success"
,
});
}
else
{
uni
.
showToast
({
title
:
updateRes
.
message
||
"更新失败"
,
icon
:
"none"
,
});
}
}
else
{
uni
.
showToast
({
title
:
"未找到宝宝信息"
,
icon
:
"none"
,
});
}
}
else
{
uni
.
showToast
({
title
:
uploadRes
.
message
||
"上传失败"
,
icon
:
"none"
,
});
}
}
catch
(
error
)
{
console
.
error
(
"背景图片上传失败:"
,
error
);
uni
.
showToast
({
title
:
"背景图片上传失败"
,
icon
:
"none"
,
});
}
finally
{
hideLoading
();
}
},
fail
:
(
err
)
=>
{
console
.
error
(
"选择图片失败:"
,
err
);
uni
.
showToast
({
title
:
"选择图片失败"
,
icon
:
"none"
,
});
}
});
};
// 页面加载
onMounted
(
async
()
=>
{
md
.
sensorLogTake
({
...
...
@@ -1062,6 +1243,17 @@ defineExpose({});
top: 32rpx;
z-index: 1;
.avatar-wrapper {
display: flex;
align-items: center;
justify-content: center;
padding: 0;
border: none;
background: transparent;
width: 100%;
height: 100%;
}
.avatar {
width: 100%;
height: 100%;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment