Commit d781fa83 authored by 王炽's avatar 王炽

66666

parent 5639f6e0
...@@ -74,3 +74,10 @@ export const getExchangeList = (params = {}) => api.get('/c/user/exchange/list', ...@@ -74,3 +74,10 @@ export const getExchangeList = (params = {}) => api.get('/c/user/exchange/list',
* @returns * @returns
*/ */
export const getOrderDetail = (data) => api.get('/c/order/detail', data); export const getOrderDetail = (data) => api.get('/c/order/detail', data);
/**
* 保存宝宝额外信息
* @param {Object} data - 宝宝额外信息
* @returns {Promise} 接口响应
*/
export const saveBabyExtra = (data) => api.post('/c/user/saveBabyExtra', data);
\ No newline at end of file
{
"code": "aliqua dolor",
"message": "ullamco veniam sunt nostrud aute",
"ok": true,
"success": false,
"data": "dolor ipsum elit"
}
...@@ -24,15 +24,33 @@ ...@@ -24,15 +24,33 @@
<view class="user-info" :style="{ 'min-height': cfgStatus.showDetail ? '343rpx' : '168rpx' }"> <view class="user-info" :style="{ 'min-height': cfgStatus.showDetail ? '343rpx' : '168rpx' }">
<view class="user-header"> <view class="user-header">
<view class="avatar-container"> <view class="avatar-container">
<button class="avatar-wrapper" :data-log="{ <button
v-if="canChooseAvatar"
class="avatar-wrapper"
:data-log="{
xcxClick: '我的页面点击', xcxClick: '我的页面点击',
pageName: '我的页面', pageName: '我的页面',
buttonName: '个人信息修改', buttonName: '个人信息修改',
}" open-type="chooseAvatar" @chooseavatar="onChooseAvatar"> }"
open-type="chooseAvatar"
@chooseavatar="onChooseAvatar">
<image class="avatar" :src="localAvatarUrl || babyInfo?.content?.babyAvatar || <image class="avatar" :src="localAvatarUrl || babyInfo?.content?.babyAvatar ||
$baseUrl + 'common/default_avatar.png' $baseUrl + 'common/default_avatar.png'
" mode="widthFix" /> " mode="widthFix" />
</button> </button>
<view
v-else
class="avatar-wrapper"
:data-log="{
xcxClick: '我的页面点击',
pageName: '我的页面',
buttonName: '个人信息修改',
}"
@click="handleAvatarClick">
<image class="avatar" :src="localAvatarUrl || babyInfo?.content?.babyAvatar ||
$baseUrl + 'common/default_avatar.png'
" mode="widthFix" />
</view>
</view> </view>
<button v-if="!cfgStatus.isRegister" type="primary" class="avatar-container" @click="clickRegisterShield" /> <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" /> <image class="avatar-modify" :src="$baseUrl + 'my/icon_modify.png'" mode="aspectFit" lazy-load="false" />
...@@ -287,6 +305,8 @@ import md from "../md.js"; ...@@ -287,6 +305,8 @@ import md from "../md.js";
import { onShow } from '@dcloudio/uni-app'; import { onShow } from '@dcloudio/uni-app';
import { useIntegralStore } from "../stores/integral.js"; import { useIntegralStore } from "../stores/integral.js";
import { useGlobalStore } from "../stores/global.js"; import { useGlobalStore } from "../stores/global.js";
import { uploadImage } from "../api/common.js";
import { saveBabyExtra } from "../api/user.js";
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
const $baseUrl = proxy.$baseUrl; const $baseUrl = proxy.$baseUrl;
...@@ -307,6 +327,13 @@ const toolList = computed(() => pageCfgStore?.toolList || []); ...@@ -307,6 +327,13 @@ const toolList = computed(() => pageCfgStore?.toolList || []);
const babyInfo = computed(() => userStore?.babyInfo || {}); const babyInfo = computed(() => userStore?.babyInfo || {});
// 判断是否可以使用选择头像功能
const canChooseAvatar = computed(() => {
return cfgStatus.value.isRegister &&
userStore.babyInfo?.allBabyBaseInfo &&
userStore.babyInfo?.allBabyBaseInfo?.length > 0;
});
const showRegisterLayer = ref(false); const showRegisterLayer = ref(false);
const showBabySwitcher = ref(false); const showBabySwitcher = ref(false);
...@@ -532,9 +559,7 @@ const handleToolClick = async (item) => { ...@@ -532,9 +559,7 @@ const handleToolClick = async (item) => {
const handleEditProfile = (e) => { const handleEditProfile = (e) => {
if ( if (!userStore.userInfo ||
!cfgStatus.value.isRegister ||
!userStore.userInfo ||
JSON.stringify(userStore.userInfo) === "{}" JSON.stringify(userStore.userInfo) === "{}"
) { ) {
return; return;
...@@ -548,6 +573,21 @@ const handleEditProfile = (e) => { ...@@ -548,6 +573,21 @@ const handleEditProfile = (e) => {
componentContent: "资料编辑" componentContent: "资料编辑"
}) })
// 检查登录状态
if (!cfgStatus.value.isRegister) {
// 未登录,跳转到登录注册页面
jump({
type: JumpType.INNER,
url: "/pages/activity/register",
});
return;
}
if(!userStore.babyInfo?.allBabyBaseInfo || userStore.babyInfo?.allBabyBaseInfo?.length === 0) {
navigateTo("/pages/person/person?type=add");
return;
}
const type = userStore.babyInfo?.allBabyBaseInfo?.length == 0 ? "add" : "edit"; const type = userStore.babyInfo?.allBabyBaseInfo?.length == 0 ? "add" : "edit";
babyId.value = userStore.babyInfo?.allBabyBaseInfo?.find( babyId.value = userStore.babyInfo?.allBabyBaseInfo?.find(
(item) => item.selected (item) => item.selected
...@@ -564,8 +604,35 @@ const handleEditProfile = (e) => { ...@@ -564,8 +604,35 @@ const handleEditProfile = (e) => {
}; };
// 头像点击事件(当不满足选择头像条件时)
const handleAvatarClick = (e) => {
md.sensorLog(e);
md.sensorComponentLogTake({
xcxComponentClick: "true",
pageName: "我的页面",
componentName: "资料编辑",
componentContent: "资料编辑"
})
// 检查登录状态
if (!cfgStatus.value.isRegister) {
// 未登录,跳转到登录注册页面
jump({
type: JumpType.INNER,
url: "/pages/activity/register",
});
return;
}
if(!userStore.babyInfo?.allBabyBaseInfo || userStore.babyInfo?.allBabyBaseInfo?.length === 0) {
navigateTo("/pages/person/person?type=add");
return;
}
};
// 选择头像 // 选择头像
const onChooseAvatar = async (e) => { const onChooseAvatar = async (e) => {
showLoading('上传中...'); showLoading('上传中...');
md.sensorLog(e); md.sensorLog(e);
md.sensorComponentLogTake({ md.sensorComponentLogTake({
...@@ -575,6 +642,8 @@ const onChooseAvatar = async (e) => { ...@@ -575,6 +642,8 @@ const onChooseAvatar = async (e) => {
componentContent: "资料编辑" componentContent: "资料编辑"
}) })
try { try {
const fs = uni.getFileSystemManager(); const fs = uni.getFileSystemManager();
const base64 = const base64 =
...@@ -590,13 +659,23 @@ const onChooseAvatar = async (e) => { ...@@ -590,13 +659,23 @@ const onChooseAvatar = async (e) => {
(item) => item.selected (item) => item.selected
); );
console.log("selectedBaby-===", selectedBaby);
if (selectedBaby) { if (selectedBaby) {
// const updateData = {
// id: selectedBaby.id,
// babyAvatar: res.data.url,
// };
// const updateRes = await updateBabyInfo(updateData);
console.log("userStore.babyInfo?.content?.id====", userStore.babyInfo?.content);
const updateData = { const updateData = {
id: selectedBaby.id, id: userStore.babyInfo?.content?.id,
babyAvatar: res.data.url, babyAvatar: res.data.url
}; }
const updateRes = await updateBabyInfo(updateData); const updateRes = await saveBabyExtra(updateData);
if (updateRes.success) { if (updateRes.success) {
// 刷新用户信息 // 刷新用户信息
...@@ -953,11 +1032,6 @@ const handleOpenClick = () => { ...@@ -953,11 +1032,6 @@ const handleOpenClick = () => {
// 上传背景图片 // 上传背景图片
const handleUploadBackground = async (e) => { const handleUploadBackground = async (e) => {
// 检查登录状态
if (!cfgStatus.value.isRegister) {
return;
}
md.sensorLog(e); md.sensorLog(e);
...@@ -968,6 +1042,22 @@ const handleUploadBackground = async (e) => { ...@@ -968,6 +1042,22 @@ const handleUploadBackground = async (e) => {
componentContent: "资料编辑" componentContent: "资料编辑"
}) })
// 检查登录状态
if (!cfgStatus.value.isRegister) {
// 未登录,跳转到登录注册页面
jump({
type: JumpType.INNER,
url: "/pages/activity/register",
});
return;
}
if(!userStore.babyInfo?.allBabyBaseInfo || userStore.babyInfo?.allBabyBaseInfo?.length === 0) {
navigateTo("/pages/person/person?type=add");
return;
}
// 唤起图片选择器 // 唤起图片选择器
uni.chooseImage({ uni.chooseImage({
count: 1, count: 1,
...@@ -993,12 +1083,19 @@ const handleUploadBackground = async (e) => { ...@@ -993,12 +1083,19 @@ const handleUploadBackground = async (e) => {
); );
if (selectedBaby) { if (selectedBaby) {
// const updateData = {
// id: selectedBaby.id,
// backgroundImg: uploadRes.data.url,
// };
// const updateRes = await updateBabyInfo(updateData);
console.log("userStore.babyInfo?.content?.id====", userStore.babyInfo);
const updateData = { const updateData = {
id: selectedBaby.id, id:userStore.babyInfo?.content?.id,
backgroundImg: uploadRes.data.url, backgroundImg: res.data.url
}; }
const updateRes = await updateBabyInfo(updateData); const updateRes = await saveBabyExtra(updateData);
if (updateRes.success) { if (updateRes.success) {
// 刷新用户信息 // 刷新用户信息
...@@ -1252,6 +1349,7 @@ defineExpose({}); ...@@ -1252,6 +1349,7 @@ defineExpose({});
background: transparent; background: transparent;
width: 100%; width: 100%;
height: 100%; height: 100%;
cursor: pointer;
} }
.avatar { .avatar {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment