temple hidden change nickname

This commit is contained in:
WindowBird 2025-09-09 16:52:53 +08:00
parent 4b0f9cdf34
commit 3a5b5936c8

View File

@ -22,10 +22,7 @@
</view> </view>
</view> </view>
<view class="logout-container"> <view class="logout-container">
<logout-button <logout-button @logout-success="onLogoutSuccess" @logout-error="onLogoutError" />
@logout-success="onLogoutSuccess"
@logout-error="onLogoutError"
/>
</view> </view>
</view> </view>
</template> </template>
@ -36,7 +33,7 @@ import LogoutButton from '@/components/logout-button/logout-button.vue'
export default { export default {
components: { components: {
LogoutButton LogoutButton,
}, },
data() { data() {
return { return {
@ -46,11 +43,11 @@ export default {
value: '', // URL value: '', // URL
type: 'avatar', type: 'avatar',
}, },
{ // {
label: '昵称', // label: '',
value: '昵称', // // value: '', //
type: 'nickname', // type: 'nickname',
}, // },
], ],
} }
}, },
@ -228,16 +225,16 @@ export default {
showAvatarUpload() { showAvatarUpload() {
uni.showActionSheet({ uni.showActionSheet({
itemList: ['从相册选择', '拍照'], itemList: ['从相册选择', '拍照'],
success: (res) => { success: res => {
if (res.tapIndex === 0) { if (res.tapIndex === 0) {
this.chooseImageFromAlbum() this.chooseImageFromAlbum()
} else if (res.tapIndex === 1) { } else if (res.tapIndex === 1) {
this.takePhoto() this.takePhoto()
} }
}, },
fail: (err) => { fail: err => {
console.log('用户取消选择:', err) console.log('用户取消选择:', err)
} },
}) })
}, },
@ -247,17 +244,17 @@ export default {
count: 1, count: 1,
sizeType: ['compressed'], sizeType: ['compressed'],
sourceType: ['album'], sourceType: ['album'],
success: (res) => { success: res => {
const filePath = res.tempFilePaths[0] const filePath = res.tempFilePaths[0]
this.uploadAvatar(filePath) this.uploadAvatar(filePath)
}, },
fail: (err) => { fail: err => {
console.error('选择图片失败:', err) console.error('选择图片失败:', err)
uni.showToast({ uni.showToast({
title: '选择图片失败', title: '选择图片失败',
icon: 'none' icon: 'none',
}) })
} },
}) })
}, },
@ -267,17 +264,17 @@ export default {
count: 1, count: 1,
sizeType: ['compressed'], sizeType: ['compressed'],
sourceType: ['camera'], sourceType: ['camera'],
success: (res) => { success: res => {
const filePath = res.tempFilePaths[0] const filePath = res.tempFilePaths[0]
this.uploadAvatar(filePath) this.uploadAvatar(filePath)
}, },
fail: (err) => { fail: err => {
console.error('拍照失败:', err) console.error('拍照失败:', err)
uni.showToast({ uni.showToast({
title: '拍照失败', title: '拍照失败',
icon: 'none' icon: 'none',
}) })
} },
}) })
}, },
@ -285,13 +282,13 @@ export default {
async uploadAvatar(filePath) { async uploadAvatar(filePath) {
try { try {
uni.showLoading({ uni.showLoading({
title: '上传中...' title: '上传中...',
}) })
console.log('开始上传头像:', filePath) console.log('开始上传头像:', filePath)
const response = await uploadAvatar(filePath) const response = await uploadAvatar(filePath)
uni.hideLoading() uni.hideLoading()
if (response.code === 200) { if (response.code === 200) {
@ -312,7 +309,7 @@ export default {
uni.showToast({ uni.showToast({
title: '头像上传成功', title: '头像上传成功',
icon: 'success' icon: 'success',
}) })
// //
@ -325,7 +322,7 @@ export default {
console.error('头像上传失败:', error) console.error('头像上传失败:', error)
uni.showToast({ uni.showToast({
title: error.message || '上传失败', title: error.message || '上传失败',
icon: 'none' icon: 'none',
}) })
} }
}, },