This commit is contained in:
18796357645 2025-07-15 12:44:17 +08:00
parent e1c87cc001
commit 5160962398
2 changed files with 215 additions and 194 deletions

View File

@ -123,7 +123,7 @@ export default {
}, },
navigateToAccountSettings(path) { navigateToAccountSettings(path) {
console.log("okk")
uni.navigateTo({ uni.navigateTo({
url: path, url: path,
}); });

View File

@ -1,216 +1,237 @@
<template> <template>
<view class="contai_warp"> <view class="contai_warp">
<!-- Top Navigation Bar --> <!-- Top Navigation Bar -->
<view class="top_area_warp"> <view class="top_area_warp">
<view class="top_status_area" :style="{ height: statusBarHeight + 'px' }"></view> <view class="top_status_area" :style="{ height: statusBarHeight + 'px' }"></view>
<view class="top_nav_warp"> <view class="top_nav_warp">
<view class="back_icon" @click="goBack"> <view class="back_icon" @click="goBack">
<image src="https://online.totustec.com/upload/minePage/back.png" mode="aspectFit"></image> <image src="https://online.totustec.com/upload/minePage/back.png" mode="aspectFit"></image>
</view> </view>
<text>个人资料</text> <text>个人资料</text>
</view> </view>
</view> </view>
<!-- Profile Content --> <!-- Profile Content -->
<view class="profile_content"> <view class="profile_content">
<!-- Avatar Section --> <!-- Avatar Section -->
<view class="profile_item"> <view class="profile_item">
<text class="item_label">头像</text> <text class="item_label">头像</text>
<view class="avatar_wrapper" @click="changeAvatar"> <view class="avatar_wrapper" @click="changeAvatar">
<image class="avatar" :src="userInfo.avatar || '/static/default-avatar.png'" mode="aspectFill"></image> <image class="avatar"
<image class="edit_icon" src="https://online.totustec.com/upload/minePage/user.png" mode="aspectFit"></image> :src="userInfo.avatar || 'https://online.totustec.com/upload/minePage/user.png'"
</view> mode="aspectFill"></image>
</view> </view>
</view>
<!-- Nickname Section --> <!-- Nickname Section -->
<view class="profile_item"> <view class="profile_item">
<text class="item_label">昵称</text> <text class="item_label">昵称</text>
<input class="nickname_input" v-model="userInfo.nickname" placeholder="请输入昵称" /> <input class="nickname_input" v-model="userInfo.nickname" placeholder="请输入昵称" />
</view> </view>
<!-- Save Button -->
<!-- Save Button --> <button class="save_btn" @click="saveProfile">保存修改</button>
<button class="save_btn" @click="saveProfile">保存修改</button> </view>
</view> </view>
</view>
</template> </template>
<script> <script>
export default { export default {
data() { data() {
return { return {
statusBarHeight: 0, statusBarHeight: 0,
userInfo: { userInfo: {
avatar: '', nickname: ""
nickname: '' }
} };
}; },
}, onLoad() {
onLoad() { // Get system info for status bar height
// Get system info for status bar height const systemInfo = wx.getSystemInfoSync();
const systemInfo = wx.getSystemInfoSync(); this.statusBarHeight = systemInfo.statusBarHeight;
this.statusBarHeight = systemInfo.statusBarHeight; this.getUserInfoFromCache();
},
// Load user info methods: {
this.loadUserInfo(); getUserInfoFromCache() {
}, const userInfo = uni.getStorageSync("userInfo");
methods: { if (userInfo) {
loadUserInfo() { this.userInfo.nickname = userInfo.nikeName;
// Mock data - replace with actual data fetching this.userInfo.avatar = "https://online.totustec.com/upload" + userInfo.avatar;
this.userInfo = {
avatar: '/static/default-avatar.png', }
nickname: '微信用户' },
};
}, changeAvatar() {
changeAvatar() { uni.chooseImage({
uni.chooseImage({ count: 1,
count: 1, sizeType: ['compressed'],
sizeType: ['compressed'], sourceType: ['album', 'camera'],
sourceType: ['album', 'camera'], success: (res) => {
success: (res) => { const tempFilePaths = res.tempFilePaths;
const tempFilePaths = res.tempFilePaths; this.userInfo.avatar = tempFilePaths[0];
this.userInfo.avatar = tempFilePaths[0]; // Here you would typically upload the image to your server
// Here you would typically upload the image to your server }
} });
}); },
}, async saveProfile() {
saveProfile() { if (!this.userInfo.nickname.trim()) {
if (!this.userInfo.nickname.trim()) { uni.showToast({
uni.showToast({ title: '昵称不能为空',
title: '昵称不能为空', icon: 'none'
icon: 'none' });
}); return;
return; }
} try {
const res = await uni.request({
// Here you would typically send the updated info to your server url: "https://online.totustec.com/api/api/front/user/update",
uni.showToast({ method: "POST",
title: '保存成功', data: this.userInfo,
icon: 'success' header: {
}); "Content-Type": "application/x-www-form-urlencoded",
"Authorization": userInfo.token || ""
// Simulate API call },
setTimeout(() => { });
uni.navigateBack(); console.log(res)
}, 1500); if (res.statusCode == 200) {
}, uni.showToast({
goBack() { title: "修改成功"
uni.navigateBack(); });
} }
} } catch (error) {
}; uni.showToast({
title: "修改失败",
icon: "none"
});
}
// Here you would typically send the updated info to your server
// uni.showToast({
// title: '',
// icon: 'success'
// });
// Simulate API call
setTimeout(() => {
uni.navigateBack();
}, 1500);
},
goBack() {
uni.navigateBack();
}
}
};
</script> </script>
<style scoped> <style scoped>
.contai_warp { .contai_warp {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
font-family: PingFang SC, PingFang SC !important; font-family: PingFang SC, PingFang SC !important;
min-height: 100vh; min-height: 100vh;
background-color: #f1f6fc; /* 保持原有背景色 */ background-color: #f1f6fc;
} /* 保持原有背景色 */
}
/* Top Navigation Styles */ /* Top Navigation Styles */
.top_area_warp { .top_area_warp {
width: 100%; width: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
position: relative; position: relative;
} }
.top_status_area { .top_status_area {
width: 100%; width: 100%;
} }
.top_nav_warp { .top_nav_warp {
width: 100%; width: 100%;
height: 88rpx; height: 88rpx;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
font-family: PingFang SC, PingFang SC; font-family: PingFang SC, PingFang SC;
font-weight: 500; font-weight: 500;
font-size: 32rpx; font-size: 32rpx;
color: #000000; color: #000000;
position: relative; position: relative;
z-index: 5; z-index: 5;
} }
.back_icon { .back_icon {
position: absolute; position: absolute;
left: 20rpx; left: 20rpx;
width: 40rpx; width: 40rpx;
height: 40rpx; height: 40rpx;
} }
.back_icon image { .back_icon image {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
/* Profile Content Styles */ /* Profile Content Styles */
.profile_content { .profile_content {
width: 90%; width: 90%;
padding: 40rpx 30rpx; padding: 40rpx 30rpx;
background-color: #ffffff; background-color: #ffffff;
border-radius: 20rpx 20rpx 0 0; border-radius: 20rpx 20rpx 0 0;
margin-top: 20rpx; margin-top: 20rpx;
box-shadow: 0 2rpx 10rpx rgba(0,0,0,0.05); box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
} }
.profile_item { .profile_item {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
padding: 30rpx 0; padding: 30rpx 0;
border-bottom: 1rpx solid #f0f0f0; border-bottom: 1rpx solid #f0f0f0;
} }
.item_label { .item_label {
font-size: 28rpx; font-size: 28rpx;
color: #333; color: #333;
} }
.avatar_wrapper { .avatar_wrapper {
position: relative; position: relative;
width: 100rpx; width: 100rpx;
height: 100rpx; height: 100rpx;
} }
.avatar { .avatar {
width: 100%; width: 100%;
height: 100%; height: 100%;
border-radius: 50%; border-radius: 50%;
} }
.edit_icon {
position: absolute;
right: -10rpx;
bottom: -10rpx;
width: 100rpx;
height: 100rpx;
background: #fff;
border-radius: 50%;
padding: 5rpx;
box-shadow: 0 0 10rpx rgba(0,0,0,0.1);
}
.nickname_input { .edit_icon {
text-align: right; position: absolute;
font-size: 28rpx; right: -10rpx;
color: #333; bottom: -10rpx;
flex: 1; width: 100rpx;
margin-left: 20rpx; height: 100rpx;
} background: #fff;
border-radius: 50%;
padding: 5rpx;
box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.1);
}
.save_btn { .nickname_input {
margin-top: 60rpx; text-align: right;
background-color: #0095de; font-size: 28rpx;
color: white; color: #333;
border-radius: 50rpx; flex: 1;
font-size: 32rpx; margin-left: 20rpx;
} }
.save_btn:active { .save_btn {
background-color: #06AD56; margin-top: 60rpx;
} background-color: #0095de;
color: white;
border-radius: 50rpx;
font-size: 32rpx;
}
.save_btn:active {
background-color: #ffffff;
}
</style> </style>