| | |
| | | <view class="container"> |
| | | <view class="pageBg"></view> |
| | | <div class="avatarBox"> |
| | | <u-avatar @click="uploadAvatar" :src="userInfo.avatar ? userInfo.avatar : showDefaultHeader" size="114" mode="aspectFill" /> |
| | | <u-avatar :src="userInfo.avatar ? userInfo.avatar : showDefaultHeader" size="114" mode="aspectFill" /> |
| | | <!-- <u-avatar @click="uploadAvatar" :src="userInfo.avatar ? userInfo.avatar : showDefaultHeader" size="114" mode="aspectFill" />--> |
| | | </div> |
| | | <view class="detailBox"> |
| | | <div class="detailCon"> |
| | |
| | | // 提交文件 |
| | | function afterReadFile(event) { |
| | | console.log('上传的文件:', event); |
| | | |
| | | |
| | | // 准备上传参数 |
| | | const uploadParams = { |
| | | name: event.name, // 服务器端接收文件的字段名 |
| | | file: event.file, // 传入文件对象 |
| | | filePath: event.filePath, // 文件路径 |
| | | }; |
| | | |
| | | |
| | | // 调用上传文件接口 |
| | | uploadFileApi(uploadParams).then(res => { |
| | | uni.hideLoading(); |
| | | |
| | | |
| | | console.log('上传成功结果:', res); |
| | | |
| | | |
| | | // 根据接口返回的数据结构处理结果 |
| | | if (res.data && res.data.code === 200) { |
| | | const uploadResult = res.data.data; |
| | | userInfo.value.avatar = uploadResult.fileUrl || '文件上传成功'; |
| | | |
| | | |
| | | uni.showToast({ |
| | | title: '上传成功', |
| | | icon: 'success' |
| | |
| | | const pathWithoutProtocol = filePath.replace(/^file:\/\//, ''); |
| | | fileName = pathWithoutProtocol.split('/').pop() || 'unknown.png'; |
| | | } |
| | | |
| | | |
| | | // 显示加载中 |
| | | uni.showLoading({ |
| | | title: '上传中...' |
| | |
| | | } |
| | | |
| | | }); |
| | | |
| | | |
| | | }; |
| | | onShow(async () => { |
| | | getUserInfoData() |
| | |
| | | |
| | | .custom-style { |
| | | width: 276rpx; |
| | | height: 76rpx; |
| | | height: 76rpx; |
| | | } |
| | | :deep(.u-button.data-v-461e713c){ |
| | | width: 276rpx !important; |
| | |
| | | color: #1D6FE9; |
| | | margin-top: 40rpx; |
| | | } |
| | | </style> |
| | | </style> |