吉安感知网项目-前端
chenyao
2026-04-08 7aaca71bd1a51c9f9fe4d646595cb8f65e08df35
uniapps/work-wx/src/subPackages/userDetail/infos/index.vue
@@ -3,7 +3,8 @@
   <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">
@@ -142,25 +143,25 @@
   // 提交文件
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'
@@ -198,7 +199,7 @@
               const pathWithoutProtocol = filePath.replace(/^file:\/\//, '');
               fileName = pathWithoutProtocol.split('/').pop() || 'unknown.png';
            }
            // 显示加载中
            uni.showLoading({
               title: '上传中...'
@@ -234,7 +235,7 @@
         }
      });
   };
   onShow(async () => {
      getUserInfoData()
@@ -321,7 +322,7 @@
   .custom-style {
      width: 276rpx;
      height: 76rpx;
      height: 76rpx;
   }
   :deep(.u-button.data-v-461e713c){
      width: 276rpx !important;
@@ -336,4 +337,4 @@
      color: #1D6FE9;
      margin-top: 40rpx;
   }
</style>
</style>