Commit 106f09c1 authored by 王炽's avatar 王炽

66666

parent a1925ada
...@@ -6,12 +6,17 @@ ...@@ -6,12 +6,17 @@
:iconSelected="$baseUrl + 'my/track/icon_stage_sel.png'" :iconSelected="$baseUrl + 'my/track/icon_stage_sel.png'"
@update:selectedIndex="(val) => (wheelSelectedIndex = val)" @change="handleWheelChange" /> @update:selectedIndex="(val) => (wheelSelectedIndex = val)" @change="handleWheelChange" />
</view> </view>
<view class="bg-container" :data-log="{ <view
xcxClick: '我的页面点击', v-if="cfgStatus.isRegister"
pageName: '我的页面', class="bg-container"
buttonName: '个人信息修改', :data-log="{
}" @click="handleEditProfile"> xcxClick: '我的页面点击',
<image class="bg-img" :src="babyInfo?.content?.backgroundImg || $baseUrl + 'my/default_bg.png' pageName: '我的页面',
buttonName: '上传背景',
}"
@click="handleUploadBackground"
>
<image class="bg-img" :src="localBackgroundImg || babyInfo?.content?.backgroundImg || $baseUrl + 'my/default_bg.png'
" mode="widthFix" lazy-load="false" binderror="" bindload="" /> " mode="widthFix" lazy-load="false" binderror="" bindload="" />
<image class="banner_cover" :src="$baseUrl + 'my/cover_white.png'" mode="aspectFill" /> <image class="banner_cover" :src="$baseUrl + 'my/cover_white.png'" mode="aspectFill" />
</view> </view>
...@@ -21,14 +26,16 @@ ...@@ -21,14 +26,16 @@
<!-- 用户信息区域 --> <!-- 用户信息区域 -->
<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" @click="handleEditProfile" :data-log="{ <view class="avatar-container" :data-log="{
xcxClick: '我的页面点击', xcxClick: '我的页面点击',
pageName: '我的页面', pageName: '我的页面',
buttonName: '个人信息修改', buttonName: '个人信息修改',
}"> }">
<image class="avatar" :src="babyInfo?.content?.babyAvatar || <button class="avatar-wrapper" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
$baseUrl + 'common/default_avatar.png' <image class="avatar" :src="localAvatarUrl || babyInfo?.content?.babyAvatar ||
" mode="widthFix" /> $baseUrl + 'common/default_avatar.png'
" mode="widthFix" />
</button>
</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" />
...@@ -38,8 +45,8 @@ ...@@ -38,8 +45,8 @@
xcxClick: '我的页面点击', xcxClick: '我的页面点击',
pageName: '我的页面', pageName: '我的页面',
buttonName: '宝宝信息切换', buttonName: '宝宝信息切换',
}"> }" >
<text class="nickname" @click="handleEditProfile">{{ <text class="nickname" @click="handleEditProfile">{{
babyInfo?.babyStage === 0 babyInfo?.babyStage === 0
? "备孕" ? "备孕"
: babyInfo?.babyStage === 1 : babyInfo?.babyStage === 1
...@@ -52,7 +59,7 @@ ...@@ -52,7 +59,7 @@
</view> </view>
</view> </view>
<!-- 积分账户 --> <!-- 积分账户 -->
<view class="integral-account" @click="handleEditProfile"> <view class="integral-account" @click="handleEditProfile">
<text class="integral-account-text"> 账号: </text> <text class="integral-account-text"> 账号: </text>
<text class="integral-account-value"> <text class="integral-account-value">
{{ userStore.memberInfo?.mobile || '' }}</text> {{ userStore.memberInfo?.mobile || '' }}</text>
...@@ -106,7 +113,7 @@ ...@@ -106,7 +113,7 @@
<!-- 完成任务模块 --> <!-- 完成任务模块 -->
<view class="task-module" <view class="task-module"
v-if="cfgStatus.isRegister && (babyInfo?.allBabyBaseInfo && babyInfo.allBabyBaseInfo.length > 0)"> v-if="!cfgStatus.isRegister || (babyInfo?.allBabyBaseInfo && babyInfo.allBabyBaseInfo.length > 0)">
<image class="task-guide-bg" :src="$baseUrl + 'homepage/Q3Res/my_taskGuideBg.png'"></image> <image class="task-guide-bg" :src="$baseUrl + 'homepage/Q3Res/my_taskGuideBg.png'"></image>
<image class="task-do-btn" :src="$baseUrl + 'homepage/Q3Res/my_taskDoBtn.png'" @tap="handleTaskClick"></image> <image class="task-do-btn" :src="$baseUrl + 'homepage/Q3Res/my_taskDoBtn.png'" @tap="handleTaskClick"></image>
</view> </view>
...@@ -278,6 +285,8 @@ import { useUserStore } from "@/stores/user"; ...@@ -278,6 +285,8 @@ import { useUserStore } from "@/stores/user";
import { usePageCfgStore } from "@/stores/pageCfg"; import { usePageCfgStore } from "@/stores/pageCfg";
import { jump, JumpType } from "@/utils"; import { jump, JumpType } from "@/utils";
import { getHealthField } from "@/api/common"; import { getHealthField } from "@/api/common";
import { uploadImage } from "@/api/common";
import { updateBabyInfo } from "@/api/user";
import { hideLoading, showLoading } from "../utils"; import { hideLoading, showLoading } from "../utils";
import md from "../md.js"; import md from "../md.js";
import { onShow } from '@dcloudio/uni-app'; import { onShow } from '@dcloudio/uni-app';
...@@ -310,15 +319,13 @@ const points = ref(0); ...@@ -310,15 +319,13 @@ const points = ref(0);
const babyId = ref(0); const babyId = ref(0);
const handleTaskClick = async () => { // 本地头像 URL,用于临时显示上传后的头像
// 添加点击埋点 const localAvatarUrl = ref('');
md.sensorComponentLogTake({
xcxComponentClick: "true", // 本地背景图片 URL,用于临时显示上传后的背景图
pageName: "我的页面", const localBackgroundImg = ref('');
componentName: "做任务赚更多积分",
componentContent: "去做任务"
});
const handleTaskClick = async () => {
// 检查登录状态 // 检查登录状态
if (!cfgStatus.value.isRegister) { if (!cfgStatus.value.isRegister) {
// 未登录,跳转到登录注册页面 // 未登录,跳转到登录注册页面
...@@ -380,14 +387,6 @@ const navigateToCoupon = () => { ...@@ -380,14 +387,6 @@ const navigateToCoupon = () => {
// 需要登录的优惠券页面跳转 // 需要登录的优惠券页面跳转
const navigateToCouponWithLogin = () => { const navigateToCouponWithLogin = () => {
// 添加点击埋点
md.sensorComponentLogTake({
xcxComponentClick: "true",
pageName: "我的页面",
componentName: "拓展工具",
componentContent: "我的优惠券"
});
// 检查登录状态 // 检查登录状态
if (!cfgStatus.value.isRegister) { if (!cfgStatus.value.isRegister) {
// 未登录,跳转到登录注册页面 // 未登录,跳转到登录注册页面
...@@ -420,26 +419,6 @@ const navigateTo = (url) => { ...@@ -420,26 +419,6 @@ const navigateTo = (url) => {
const navigateToWithLogin = (url) => { const navigateToWithLogin = (url) => {
console.warn('navigateToWithLogin', url); console.warn('navigateToWithLogin', url);
console.warn('cfgStatus.value.isRegister', cfgStatus.value.isRegister); console.warn('cfgStatus.value.isRegister', cfgStatus.value.isRegister);
// 添加点击埋点 - 根据 URL 判断是哪个菜单项
let componentContent = '';
if (url.includes('/v3/orderList/orderList')) {
componentContent = '我的订单';
} else if (url.includes('/v3/addressList/addressList')) {
componentContent = '收货地址管理';
} else if (url.includes('/v3/more/index')) {
componentContent = '更多';
}
if (componentContent) {
md.sensorComponentLogTake({
xcxComponentClick: "true",
pageName: "我的页面",
componentName: "拓展工具",
componentContent: componentContent
});
}
// 检查登录状态 // 检查登录状态
if (!cfgStatus.value.isRegister) { if (!cfgStatus.value.isRegister) {
// 未登录,跳转到登录注册页面 // 未登录,跳转到登录注册页面
...@@ -553,6 +532,72 @@ const handleEditProfile = (e) => { ...@@ -553,6 +532,72 @@ const handleEditProfile = (e) => {
} }
}; };
// 选择头像
const onChooseAvatar = async (e) => {
showLoading('上传中...');
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 () => { const onRegisterConfirm = async () => {
await pageCfgStore.fetchCfg(); await pageCfgStore.fetchCfg();
// 只调用一次initData,loadMemberInfo已在initData内部处理 // 只调用一次initData,loadMemberInfo已在initData内部处理
...@@ -576,27 +621,6 @@ const handleWheelChange = (val) => { ...@@ -576,27 +621,6 @@ const handleWheelChange = (val) => {
const initExposure = () => { const initExposure = () => {
// 添加宝宝信息引导模块曝光埋点
if (cfgStatus.value.isRegister && (!babyInfo.value?.allBabyBaseInfo || babyInfo.value?.allBabyBaseInfo?.length === 0)) {
md.sensorComponentLogTake({
xcxComponentExposure: "true",
pageName: "我的页面",
componentName: "添加宝宝信息引导",
componentContent: "添加宝宝信息引导"
});
}
// 添加做任务赚更多积分模块曝光埋点
if (!cfgStatus.value.isRegister || (babyInfo.value?.allBabyBaseInfo && babyInfo.value?.allBabyBaseInfo?.length > 0)) {
md.sensorComponentLogTake({
xcxComponentExposure: "true",
pageName: "我的页面",
componentName: "做任务赚更多积分",
componentContent: "去做任务"
});
}
md.sensorComponentLogTake({ md.sensorComponentLogTake({
xcxComponentExposure: "true", xcxComponentExposure: "true",
pageName: "我的页面", pageName: "我的页面",
...@@ -642,32 +666,6 @@ const initExposure = () => { ...@@ -642,32 +666,6 @@ const initExposure = () => {
componentContent: babyInfo.value.babyStage == 2 ? "月龄滑动切换" : "孕周滑动切换" componentContent: babyInfo.value.babyStage == 2 ? "月龄滑动切换" : "孕周滑动切换"
}); });
// 添加拓展工具菜单曝光埋点
md.sensorComponentLogTake({
xcxComponentExposure: "true",
pageName: "我的页面",
componentName: "拓展工具",
componentContent: "我的订单"
});
md.sensorComponentLogTake({
xcxComponentExposure: "true",
pageName: "我的页面",
componentName: "拓展工具",
componentContent: "收货地址管理"
});
md.sensorComponentLogTake({
xcxComponentExposure: "true",
pageName: "我的页面",
componentName: "拓展工具",
componentContent: "我的优惠券"
});
md.sensorComponentLogTake({
xcxComponentExposure: "true",
pageName: "我的页面",
componentName: "拓展工具",
componentContent: "更多"
});
...@@ -678,35 +676,6 @@ onShow(async () => { ...@@ -678,35 +676,6 @@ onShow(async () => {
await userStore.loadMemberInfo(); await userStore.loadMemberInfo();
points.value = userStore.memberInfo?.points; points.value = userStore.memberInfo?.points;
console.log('userStore.memberInfo=', userStore.memberInfo) console.log('userStore.memberInfo=', userStore.memberInfo)
// 添加拓展工具菜单曝光埋点
md.sensorComponentLogTake({
xcxComponentExposure: "true",
pageName: "我的页面",
componentName: "拓展工具",
componentContent: "我的订单"
});
md.sensorComponentLogTake({
xcxComponentExposure: "true",
pageName: "我的页面",
componentName: "拓展工具",
componentContent: "收货地址管理"
});
md.sensorComponentLogTake({
xcxComponentExposure: "true",
pageName: "我的页面",
componentName: "拓展工具",
componentContent: "我的优惠券"
});
md.sensorComponentLogTake({
xcxComponentExposure: "true",
pageName: "我的页面",
componentName: "拓展工具",
componentContent: "更多"
});
console.warn("AAAAAAAA")
}) })
// 获取用户信息 // 获取用户信息
...@@ -829,13 +798,6 @@ async function onSelectBaby(baby) { ...@@ -829,13 +798,6 @@ async function onSelectBaby(baby) {
} }
function handleAddBabyInfoClick() { function handleAddBabyInfoClick() {
// 添加点击埋点
md.sensorComponentLogTake({
xcxComponentClick: "true",
pageName: "我的页面",
componentName: "添加宝宝信息引导",
componentContent: "添加宝宝信息引导"
});
// 显示RegisterLayer弹窗 // 显示RegisterLayer弹窗
showRegisterLayer.value = true; showRegisterLayer.value = true;
} }
...@@ -867,6 +829,95 @@ const handleOpenClick = () => { ...@@ -867,6 +829,95 @@ const handleOpenClick = () => {
cfgStatus.value.openBabyCardDesc = !cfgStatus.value.openBabyCardDesc; cfgStatus.value.openBabyCardDesc = !cfgStatus.value.openBabyCardDesc;
}; };
// 上传背景图片
const handleUploadBackground = async (e) => {
// 检查登录状态
if (!cfgStatus.value.isRegister) {
return;
}
md.sensorLog(e);
// 唤起图片选择器
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 () => { onMounted(async () => {
md.sensorLogTake({ md.sensorLogTake({
...@@ -1062,6 +1113,17 @@ defineExpose({}); ...@@ -1062,6 +1113,17 @@ defineExpose({});
top: 32rpx; top: 32rpx;
z-index: 1; z-index: 1;
.avatar-wrapper {
display: flex;
align-items: center;
justify-content: center;
padding: 0;
border: none;
background: transparent;
width: 100%;
height: 100%;
}
.avatar { .avatar {
width: 100%; width: 100%;
height: 100%; height: 100%;
......
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