From 42d5f44782c877b8788ef46bf8569767c0f1d8ea Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Tue, 28 Oct 2025 16:49:25 +0800
Subject: [PATCH] Merge branch 'master' of http://139.196.74.78:10010/r/drone/drone-app

---
 src/subPackages/userDetail/infos/index.vue |   76 +++++++++++++++++++++++++++++++++++++
 1 files changed, 75 insertions(+), 1 deletions(-)

diff --git a/src/subPackages/userDetail/infos/index.vue b/src/subPackages/userDetail/infos/index.vue
index 551b75e..bd6b4e7 100644
--- a/src/subPackages/userDetail/infos/index.vue
+++ b/src/subPackages/userDetail/infos/index.vue
@@ -1,7 +1,7 @@
 <template>
 	<view class="container">
 		<div class="avatarBox">
-			<u-avatar :src="userInfo.avatar" size="114" mode="aspectFill" />
+			<u-avatar @click="uploadAvatar" :src="userInfo.avatar" size="114" mode="aspectFill" />
 		</div>
 		<view class="detailBox">
 			<div class="orderRow">
@@ -32,11 +32,13 @@
 </template>
 
 <script setup>
+	import {getEnvObj, getWebViewUrl} from "@/utils/index.js";
 	import {
 		getUserInfo,
 		updateInfo,
 		updatePassword
 	} from '@/api/user/index.js';
+	import {useUserStore} from "@/store/index.js";
 	const userInfo = ref({
 		id: '',
 		avatar: '',
@@ -95,6 +97,78 @@
 	const reset = () => {
 		getUserInfoData();
 	};
+
+	const {VITE_API_BASE_URL} = getEnvObj()
+	function uploadUtil(options) {
+	  const {formData, file, url} = options
+	 
+	  return new Promise((resolve, reject) => {
+	    let accessToken = useUserStore()?.$state?.userInfo?.access_token;
+	   
+	    uni.uploadFile({
+	      url: `${VITE_API_BASE_URL}${url}`,
+	      name: 'file',
+	      header: {'Blade-Auth': 'bearer ' + accessToken},
+	      file,
+	      formData,
+	      success: (res) => {
+	        const resData = JSON.parse(res.data)
+	        if (resData.code === 200 || resData.code === 0) {
+	          resolve(res)
+	        } else {
+	          showToast(resData.message)
+			   
+	          reject(res)
+	        }
+	      },
+	      fail: (err) => {
+	        reject(err)
+	      }
+	    });
+	  })
+	}
+	const uploadAvatar = () => {
+	  uni.chooseImage({
+	    count: 1, 
+	    success: (res) => {
+	      const tempFilePaths = res.tempFiles[0];
+	      // 显示加载中
+	      uni.showLoading({
+	        title: '上传中...'
+	      });
+	     
+	      // 上传文件
+	      uploadUtil({
+	        file: tempFilePaths,
+	        formData: {
+	          fileName: tempFilePaths.name, 
+	          sn: 'avatar_upload' 
+	        },
+	        url: '/blade-resource/oss/endpoint/put-file'
+	      }).then(res => {
+	        const resData = JSON.parse(res.data);
+	        if (resData.code === 200 || resData.code === 0) {
+	          // 更新头像显示
+	          userInfo.value.avatar = resData.data.link || resData.data.url;
+	          uni.hideLoading();
+	          uni.showToast({
+	            title: '头像上传成功',
+	            icon: 'success'
+	          });
+	        } else {
+	          throw new Error(resData.message || '上传失败');
+			  
+	        }
+	      }).catch(err => {
+	        uni.hideLoading();
+	        uni.showToast({
+	          title: err.message || '上传失败',
+	          icon: 'none'
+	        });
+	      });
+	    }
+	  });
+	}
 	const submit = () => {
 		if (!validatePhone() || !validateEmail()) return
 		userInfo.value.name = userInfo.value.realName;

--
Gitblit v1.9.3