| | |
| | | uni.chooseImage({ |
| | | count: 1, |
| | | success: (res) => { |
| | | |
| | | // const tempFilePaths = res.tempFiles[0]; |
| | | // const a = tempFilePaths.name? tempFilePaths.name : tempFilePaths.path |
| | | |
| | | const tempFile = res.tempFiles[0]; // 获取文件对象 |
| | | // 1. 获取文件路径(兼容不同端的路径字段) |
| | | const filePath = tempFile.path || tempFile.tempFilePath; |
| | | if (!filePath) { |
| | | uni.showToast({ |
| | |
| | | }); |
| | | return; |
| | | } |
| | | |
| | | |
| | | let fileName = tempFile.name; |
| | | if (!fileName) { |
| | | |
| | | const pathWithoutProtocol = filePath.replace(/^file:\/\//, ''); |
| | | fileName = pathWithoutProtocol.split('/').pop() || 'unknown.png'; |
| | | } |
| | | console.log('filePath', filePath) |
| | | |
| | | // 显示加载中 |
| | | uni.showLoading({ |
| | | title: '上传中...' |
| | |
| | | icon: 'none', |
| | | duration: 2000 |
| | | }); |
| | | getUserInfoData() |
| | | |
| | | } else { |
| | | uni.showToast({ |
| | |
| | | icon: 'none', |
| | | duration: 2000 |
| | | }); |
| | | getUserInfoData() |
| | | } |
| | | |
| | | }); |
| | | getUserInfoData() |
| | | |
| | | }; |
| | | onShow(async () => { |
| | | getUserInfoData() |
| | |
| | | display: flex; |
| | | flex-direction: column; |
| | | align-items: center; |
| | | |
| | | |
| | | } |
| | | |
| | | .avatarBox { |
| | | width: 228rpx; |
| | | height: 228rpx; |