罗广辉
2025-11-06 4c682e873f79d56632de723aebf81efdf90df38d
Merge remote-tracking branch 'origin/master'
1 files modified
57 ■■■■ changed files
src/subPackages/userDetail/infos/index.vue 57 ●●●● patch | view | raw | blame | history
src/subPackages/userDetail/infos/index.vue
@@ -34,13 +34,18 @@
</template>
<script setup>
    import {getEnvObj, getWebViewUrl} from "@/utils/index.js";
    import {
        getEnvObj,
        getWebViewUrl
    } from "@/utils/index.js";
    import {
        getUserInfo,
        updateInfo,
        updatePassword
    } from '@/api/user/index.js';
    import {useUserStore} from "@/store/index.js";
    import {
        useUserStore
    } from "@/store/index.js";
    const userInfo = ref({
        id: '',
        avatar: '',
@@ -100,9 +105,16 @@
        getUserInfoData();
    };
    const {VITE_API_BASE_URL} = getEnvObj()
    const {
        VITE_API_BASE_URL
    } = getEnvObj()
    function uploadUtil(options) {
      const {formData, file, url} = options
        const {
            formData,
            filePath,
            url
        } = options;
     
      return new Promise((resolve, reject) => {
        let accessToken = useUserStore()?.$state?.userInfo?.access_token;
@@ -110,8 +122,10 @@
        uni.uploadFile({
          url: `${VITE_API_BASE_URL}${url}`,
          name: 'file',
          header: {'Blade-Auth': 'bearer ' + accessToken},
          file,
                header: {
                    'Blade-Auth': 'bearer ' + accessToken
                },
                filePath: filePath,
          formData,
          success: (res) => {
            const resData = JSON.parse(res.data)
@@ -133,7 +147,21 @@
      uni.chooseImage({
        count: 1, 
        success: (res) => {
          const tempFilePaths = res.tempFiles[0];
                const tempFile = res.tempFiles[0]; // 获取文件对象
                const filePath = tempFile.path || tempFile.tempFilePath;
                if (!filePath) {
                    uni.showToast({
                        title: '获取文件路径失败',
                        icon: 'none'
                    });
                    return;
                }
                let fileName = tempFile.name;
                if (!fileName) {
                    const pathWithoutProtocol = filePath.replace(/^file:\/\//, '');
                    fileName = pathWithoutProtocol.split('/').pop() || 'unknown.png';
                }
          // 显示加载中
          uni.showLoading({
            title: '上传中...'
@@ -141,9 +169,9 @@
         
          // 上传文件
          uploadUtil({
            file: tempFilePaths,
                    filePath: filePath,
            formData: {
              fileName: tempFilePaths.name,
                        fileName: fileName,
              sn: 'avatar_upload' 
            },
            url: '/blade-resource/oss/endpoint/put-file'
@@ -181,6 +209,7 @@
                    icon: 'none',
                    duration: 2000
                });
                    getUserInfoData()
            } else {
                uni.showToast({
@@ -188,10 +217,11 @@
                    icon: 'none',
                    duration: 2000
                });
                    getUserInfoData()
            }
            
        });
        getUserInfoData()
    };
    onShow(async () => {
        getUserInfoData()
@@ -205,10 +235,7 @@
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    .avatarBox {
        width: 228rpx;
        height: 228rpx;
@@ -221,9 +248,11 @@
        background: #FFFFFF;
        border-radius: 12rpx;
        box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
        .detailCon {
            padding: 0 24rpx;
        }
        .orderRow {
            display: flex;
            justify-content: space-between;
@@ -239,6 +268,7 @@
                color: #222324;
                white-space: nowrap;
            }
            ::v-deep .u-input {
                border: none !important;
                background: transparent !important;
@@ -261,6 +291,7 @@
        position: absolute;
        bottom:150rpx;
    }
    .u-button:first-child{
        margin-right: 30rpx;
    }