wuhb hace 3 meses
padre
commit
72a471c101

+ 2 - 2
manifest.json

@@ -2,8 +2,8 @@
 	"name": "工效通APP",
 	"appid": "__UNI__1050C07",
 	"description": "工效通任务管理平台",
-	"versionName": "1.3.4",
-	"versionCode": "134",
+	"versionName": "1.3.5",
+	"versionCode": "135",
 	"uni-app-x": {},
 	"quickapp": {},
 	"mp-weixin": {

+ 1 - 2
pages/order/detail/wbBackfillFinalize.uvue

@@ -846,8 +846,7 @@
 			if (isDealing.value || hasDealed.value) return // 双重保险
 			isDealing.value = true
 	        // 确保附件URLs是最新的逗号分隔格式
-	        attachmentUrls.value = uploadedFiles.value.map(file => file.url).join(',');
-	        
+	        attachmentUrls.value = uploadedFiles.value.map(file => file.fileName).join(',');
 	        const finishData = {
 	            id: orderId.value,
 	            orderType: orderType.value,

+ 1 - 1
pages/order/detail/wbFinalize.uvue

@@ -961,7 +961,7 @@
 			if (isDealing.value || hasDealed.value) return // 双重保险
 			isDealing.value = true
 	        // 确保附件URLs是最新的逗号分隔格式
-	        attachmentUrls.value = uploadedFiles.value.map(file => file.url).join(',');
+	        attachmentUrls.value = uploadedFiles.value.map(file => file.fileName).join(',');
 	        
 	        const finishData = {
 	            id: orderId.value,

+ 2 - 2
pages/order/detail/wxFinalize.uvue

@@ -4,7 +4,7 @@
             <!-- 工单信息 -->
             <view class="info-section">
                 <view class="section-title">
-                    <text class="section-title-text">工单信息123</text>
+                    <text class="section-title-text">工单信息</text>
                 </view>
                 <view class="info-card">
                     <view class="info-item">
@@ -961,7 +961,7 @@
 			if (isDealing.value || hasDealed.value) return // 双重保险
 			isDealing.value = true
 	        // 确保附件URLs是最新的逗号分隔格式
-	        attachmentUrls.value = uploadedFiles.value.map(file => file.url).join(',');
+	        attachmentUrls.value = uploadedFiles.value.map(file => file.fileName).join(',');
 	        
 	        const finishData = {
 	            id: orderId.value,

+ 24 - 46
utils/upload.uts

@@ -4,9 +4,7 @@
 import { getAccessToken, clearAll } from './storage'
 import type { ApiResponse } from '../types/user'
 import type { UploadResponse, UploadFileInfo } from '../types/workbench'
-
-// 基础 URL
-const BASE_URL = "http://192.168.110.40:8080"
+import { getBaseUrl } from './request'
 
 /**
  * 处理 401 未授权错误
@@ -34,7 +32,7 @@ const handle401Error = (): void => {
  * 获取文件预览地址
  */
 export const getFileViewUrl = (fileId: string): string => {
-    return `${BASE_URL}/file/view/${fileId}`
+    return getBaseUrl()+`${fileId}`
 }
 
 /**
@@ -43,15 +41,14 @@ export const getFileViewUrl = (fileId: string): string => {
  * @param businessType 业务类型模块
  */
 export const uploadFile = (filePath: string, businessType: string): Promise<UploadResponse> => {
-    return new Promise((resolve, reject) => {
+	return new Promise((resolve, reject) => {
         const token = getAccessToken()
         uni.uploadFile({
-            //url: BASE_URL + `/file/uploads?businessType=${businessType}`,
-			url: BASE_URL + `/common/upload`,
+			url: getBaseUrl() + `/common/upload`,
             filePath: filePath,
-            name: 'files',
+            name: 'file',
             header: {
-                'accesstoken': token ?? ''
+                'Authorization': 'Bearer ' + token ?? ''
             },
             success: (res) => {
                 // 提取属性(any 类型不能直接访问属性)
@@ -85,44 +82,25 @@ export const uploadFile = (filePath: string, businessType: string): Promise<Uplo
                 if (statusCode == 200) {
                     try {
                         const result = JSON.parse(resData) as UTSJSONObject
-                        const success = result['success'] as boolean | null
-                        const code = result['code'] as number | null
-                        const msg = result['msg'] as string | null
-                        const data = result['data'] as any[] | null
-
-                        // 判断是否成功
-                        if (success == true || code == 0) {
-                            if (data != null && data.length > 0) {
-                                // 获取第一个文件信息
-                                const fileInfo = data[0] as UTSJSONObject
-                                const fileId = fileInfo['fileId'] as string
-                                const fileName = fileInfo['fileName'] as string
-                                const filePath = fileInfo['filePath'] as string
-                                const fileSize = fileInfo['fileSize'] as number
-                                const fileExt = fileInfo['fileExt'] as string
-                                const businessType = fileInfo['businessType'] as string
-
-                                // 构建完整的 URL
-                                const url = getFileViewUrl(fileId)
-
-                                // 返回 UploadResponse
-                                const uploadResult: UploadResponse = {
-                                    url: url,
-                                    fileId: fileId,
-                                    fileName: fileName,
-                                    filePath: filePath,
-                                    fileSize: fileSize,
-                                    fileExt: fileExt,
-                                    businessType: businessType
-                                }
-
-                                resolve(uploadResult)
-                            } else {
-                                reject(new Error('上传成功但未返回文件信息'))
-                            }
-                        } else {
-                            reject(new Error(msg ?? '上传失败'))
+                        // 获取第一个文件信息
+                        const fileInfo = result as UTSJSONObject
+                        const fileName = fileInfo['fileName'] as string
+                        
+                        // 构建完整的 URL
+                        const url = getFileViewUrl(fileName)
+                        
+                        // 返回 UploadResponse
+                        const uploadResult: UploadResponse = {
+                            url: url,
+                            fileId: fileName,
+                            fileName: fileName,
+                            filePath: filePath,
+                            fileSize: 0,
+                            fileExt: '',
+                            businessType: businessType
                         }
+                        
+                        resolve(uploadResult)
                     } catch (e: any) {
                         console.error('响应数据解析失败:', e)
                         reject(new Error('响应数据解析失败'))