张含笑
2025-11-06 5d50408914c2e5afcc14865b320986fd7be8acf5
feat:兼容上传头像
1 files modified
17 ■■■■ changed files
src/subPackages/userDetail/infos/index.vue 17 ●●●● patch | view | raw | blame | history
src/subPackages/userDetail/infos/index.vue
@@ -147,12 +147,7 @@
        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({
@@ -161,15 +156,12 @@
                    });
                    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: '上传中...'
@@ -217,6 +209,7 @@
                    icon: 'none',
                    duration: 2000
                });
                    getUserInfoData()
            } else {
                uni.showToast({
@@ -224,10 +217,11 @@
                    icon: 'none',
                    duration: 2000
                });
                    getUserInfoData()
            }
        });
        getUserInfoData()
    };
    onShow(async () => {
        getUserInfoData()
@@ -241,10 +235,7 @@
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    .avatarBox {
        width: 228rpx;
        height: 228rpx;