add
This commit is contained in:
parent
e1c87cc001
commit
5160962398
@ -123,7 +123,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
navigateToAccountSettings(path) {
|
navigateToAccountSettings(path) {
|
||||||
console.log("okk")
|
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: path,
|
url: path,
|
||||||
});
|
});
|
||||||
|
@ -17,8 +17,9 @@
|
|||||||
<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'"
|
||||||
|
mode="aspectFill"></image>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@ -27,7 +28,6 @@
|
|||||||
<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>
|
||||||
@ -40,8 +40,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
statusBarHeight: 0,
|
statusBarHeight: 0,
|
||||||
userInfo: {
|
userInfo: {
|
||||||
avatar: '',
|
nickname: ""
|
||||||
nickname: ''
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -49,18 +48,18 @@ export default {
|
|||||||
// 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
|
|
||||||
this.loadUserInfo();
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
loadUserInfo() {
|
getUserInfoFromCache() {
|
||||||
// Mock data - replace with actual data fetching
|
const userInfo = uni.getStorageSync("userInfo");
|
||||||
this.userInfo = {
|
if (userInfo) {
|
||||||
avatar: '/static/default-avatar.png',
|
this.userInfo.nickname = userInfo.nikeName;
|
||||||
nickname: '微信用户'
|
this.userInfo.avatar = "https://online.totustec.com/upload" + userInfo.avatar;
|
||||||
};
|
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
changeAvatar() {
|
changeAvatar() {
|
||||||
uni.chooseImage({
|
uni.chooseImage({
|
||||||
count: 1,
|
count: 1,
|
||||||
@ -73,7 +72,7 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
saveProfile() {
|
async saveProfile() {
|
||||||
if (!this.userInfo.nickname.trim()) {
|
if (!this.userInfo.nickname.trim()) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '昵称不能为空',
|
title: '昵称不能为空',
|
||||||
@ -81,13 +80,33 @@ export default {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
// Here you would typically send the updated info to your server
|
const res = await uni.request({
|
||||||
uni.showToast({
|
url: "https://online.totustec.com/api/api/front/user/update",
|
||||||
title: '保存成功',
|
method: "POST",
|
||||||
icon: 'success'
|
data: this.userInfo,
|
||||||
|
header: {
|
||||||
|
"Content-Type": "application/x-www-form-urlencoded",
|
||||||
|
"Authorization": userInfo.token || ""
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
console.log(res)
|
||||||
|
if (res.statusCode == 200) {
|
||||||
|
uni.showToast({
|
||||||
|
title: "修改成功"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} 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
|
// Simulate API call
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.navigateBack();
|
uni.navigateBack();
|
||||||
@ -107,7 +126,8 @@ export default {
|
|||||||
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 */
|
||||||
@ -182,6 +202,7 @@ export default {
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.edit_icon {
|
.edit_icon {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: -10rpx;
|
right: -10rpx;
|
||||||
@ -211,6 +232,6 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.save_btn:active {
|
.save_btn:active {
|
||||||
background-color: #06AD56;
|
background-color: #ffffff;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
Loading…
Reference in New Issue
Block a user