diff --git a/pages/set/set.vue b/pages/set/set.vue index 33a76b0..dae847e 100644 --- a/pages/set/set.vue +++ b/pages/set/set.vue @@ -22,10 +22,7 @@ - + @@ -36,7 +33,7 @@ import LogoutButton from '@/components/logout-button/logout-button.vue' export default { components: { - LogoutButton + LogoutButton, }, data() { return { @@ -46,11 +43,11 @@ export default { value: '', // 头像URL,从个人中心传递过来 type: 'avatar', }, - { - label: '昵称', - value: '昵称', // 默认占位文字,实际应为用户昵称 - type: 'nickname', - }, + // { + // label: '昵称', + // value: '昵称', // 默认占位文字,实际应为用户昵称 + // type: 'nickname', + // }, ], } }, @@ -228,16 +225,16 @@ export default { showAvatarUpload() { uni.showActionSheet({ itemList: ['从相册选择', '拍照'], - success: (res) => { + success: res => { if (res.tapIndex === 0) { this.chooseImageFromAlbum() } else if (res.tapIndex === 1) { this.takePhoto() } }, - fail: (err) => { + fail: err => { console.log('用户取消选择:', err) - } + }, }) }, @@ -247,17 +244,17 @@ export default { count: 1, sizeType: ['compressed'], sourceType: ['album'], - success: (res) => { + success: res => { const filePath = res.tempFilePaths[0] this.uploadAvatar(filePath) }, - fail: (err) => { + fail: err => { console.error('选择图片失败:', err) uni.showToast({ title: '选择图片失败', - icon: 'none' + icon: 'none', }) - } + }, }) }, @@ -267,17 +264,17 @@ export default { count: 1, sizeType: ['compressed'], sourceType: ['camera'], - success: (res) => { + success: res => { const filePath = res.tempFilePaths[0] this.uploadAvatar(filePath) }, - fail: (err) => { + fail: err => { console.error('拍照失败:', err) uni.showToast({ title: '拍照失败', - icon: 'none' + icon: 'none', }) - } + }, }) }, @@ -285,13 +282,13 @@ export default { async uploadAvatar(filePath) { try { uni.showLoading({ - title: '上传中...' + title: '上传中...', }) console.log('开始上传头像:', filePath) - + const response = await uploadAvatar(filePath) - + uni.hideLoading() if (response.code === 200) { @@ -312,7 +309,7 @@ export default { uni.showToast({ title: '头像上传成功', - icon: 'success' + icon: 'success', }) // 通知其他页面更新头像 @@ -325,7 +322,7 @@ export default { console.error('头像上传失败:', error) uni.showToast({ title: error.message || '上传失败', - icon: 'none' + icon: 'none', }) } },