From a61f9fb2e1b9777f8d3ee281510504c23709654e Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 31 三月 2026 10:56:54 +0800
Subject: [PATCH] 酒泉app 1.巡检上传上传图片和视频失败

---
 src/pages/inspectionUpload/index.vue |  131 ++++++++++++++++++++++++++-----------------
 1 files changed, 79 insertions(+), 52 deletions(-)

diff --git a/src/pages/inspectionUpload/index.vue b/src/pages/inspectionUpload/index.vue
index e1ee016..6ad7d83 100644
--- a/src/pages/inspectionUpload/index.vue
+++ b/src/pages/inspectionUpload/index.vue
@@ -359,9 +359,7 @@
 
 // 璁$畻涓婁紶URL
 const uploadFileUrl = computed(() => {
-	const baseUrl = 'https://1181ybjh99334.vicp.fun';
-
-  return baseUrl + uploadConfig.action;
+  return config.baseUrl + uploadConfig.action;
 })
 
 // 璁$畻璇锋眰澶�
@@ -709,6 +707,18 @@
 // 鎻愪氦涓婁紶
 const submitUpload = async () => {
   try {
+    // 妫�鏌ョ綉缁滆繛鎺�
+    const hasNetwork = await checkNetworkConnection();
+    if (!hasNetwork) {
+      uni.showModal({
+        title: '缃戠粶閿欒',
+        content: '缃戠粶杩炴帴涓嶅彲鐢紝璇锋鏌ョ綉缁滆缃悗閲嶈瘯',
+        showCancel: false,
+        confirmText: '鐭ラ亾浜�'
+      });
+      return;
+    }
+
     // 妫�鏌ユ槸鍚﹂�夋嫨浜嗗紓甯哥姸鎬�
     if (hasException.value === null) {
       uni.showToast({
@@ -757,6 +767,7 @@
     // 娣诲姞寮傚父鐘舵�佷俊鎭�
     infoData.value.hasException = hasException.value;
     infoData.value.tempFileIds = tempFileIds;
+
     const result = await uploadInspectionTask({ ...infoData.value });
 
     // 妫�鏌ユ彁浜ょ粨鏋�
@@ -780,10 +791,13 @@
     } else {
       // 鎻愪氦澶辫触
       closeToast();
-      uni.showToast({
-        title: result?.msg || result?.message || '鎻愪氦澶辫触',
-        icon: 'error'
-      })
+      const failMsg = result?.msg || result?.message || '鏈嶅姟鍣ㄨ繑鍥為敊璇�';
+      uni.showModal({
+        title: '鎻愪氦澶辫触',
+        content: failMsg,
+        showCancel: false,
+        confirmText: '鐭ラ亾浜�'
+      });
     }
 
   } catch (error) {
@@ -799,10 +813,13 @@
       errorMessage = error;
     }
 
-    uni.showToast({
-      title: errorMessage,
-      icon: 'error'
-    })
+    // 浣跨敤寮圭獥鏄剧ず璇︾粏閿欒淇℃伅
+    uni.showModal({
+      title: '鎻愪氦澶辫触',
+      content: errorMessage,
+      showCancel: false,
+      confirmText: '鐭ラ亾浜�'
+    });
   }
 }
 
@@ -996,8 +1013,13 @@
 // 鎷嶇収/鎷嶈棰戯紙鐪熸満浼樺厛鐢� chooseMedia锛涗笉鏀寔鍒欓檷绾э級
 const chooseMedia = (type) => {
   if (getCurrentFiles().length >= uploadConfig.limit) {
-    uni.showToast({ title: `鏈�澶氬彧鑳介�夋嫨${uploadConfig.limit}涓枃浠禶, icon: 'none' })
-    return
+    uni.showModal({
+      title: '鏁伴噺闄愬埗',
+      content: `鏈�澶氬彧鑳戒笂浼� ${uploadConfig.limit} 涓枃浠讹紝璇峰厛鍒犻櫎閮ㄥ垎鏂囦欢鍚庡啀涓婁紶`,
+      showCancel: false,
+      confirmText: '鐭ラ亾浜�'
+    });
+    return;
   }
 
   const remaining = uploadConfig.limit - getCurrentFiles().length
@@ -1031,16 +1053,31 @@
             handleBeforeUpload(file)
           })
         } catch (e) {
-          console.error('澶勭悊鎷嶆憚缁撴灉澶辫触:', e)
-          uni.showToast({ title: '澶勭悊鏂囦欢澶辫触', icon: 'error' })
+          console.error('澶勭悊鎷嶆憚缁撴灉澶辫触:', e);
+          uni.showModal({
+            title: '澶勭悊澶辫触',
+            content: '鏂囦欢澶勭悊澶辫触锛�' + (e.message || '鏈煡閿欒'),
+            showCancel: false,
+            confirmText: '鐭ラ亾浜�'
+          });
         }
       },
       fail: (err) => {
-        console.error('鎷嶆憚澶辫触:', err)
-        uni.showToast({ title: '鎷嶆憚澶辫触', icon: 'error' })
+        console.error('鎷嶆憚澶辫触:', err);
+        const msg = err.errMsg || '鏈煡閿欒';
+        if (msg.includes('cancel')) {
+          // 鐢ㄦ埛鍙栨秷锛屼笉鎻愮ず
+          return;
+        }
+        uni.showModal({
+          title: '鎷嶆憚澶辫触',
+          content: '閿欒淇℃伅锛�' + msg,
+          showCancel: false,
+          confirmText: '鐭ラ亾浜�'
+        });
       }
     })
-    return
+    return;
   }
 
   // 闄嶇骇锛歝hooseImage / chooseVideo
@@ -1241,9 +1278,11 @@
       );
 
       if (!isAllowed) {
-        uni.showToast({
-          title: `鏂囦欢鏍煎紡涓嶆敮鎸侊紝璇锋媿鎽� ${expectedTypes.join('/')} 鏍煎紡鐨勬枃浠禶,
-          icon: 'none'
+        uni.showModal({
+          title: '鏍煎紡涓嶆敮鎸�',
+          content: `褰撳墠鏍煎紡涓� .${fileExtension}锛岃鎷嶆憚 ${expectedTypes.join('/')} 鏍煎紡鐨勬枃浠禶,
+          showCancel: false,
+          confirmText: '鐭ラ亾浜�'
         });
         return false;
       }
@@ -1264,7 +1303,7 @@
   // 纭繚token瀛樺湪
   const token = getToken();
   if (!token) {
-    handleUploadError('鐢ㄦ埛鏈櫥褰�');
+    handleUploadError('鐢ㄦ埛鏈櫥褰曪紝璇烽噸鏂扮櫥褰曞悗鍐嶈瘯');
     return;
   }
 
@@ -1276,7 +1315,7 @@
 // 浣跨敤uni.uploadFile涓婁紶锛堥潪H5鐜鎴朒5鍥為��鏂规锛�
 const uploadWithUniUploadFile = (file, filePath, typeValue, token) => {
   if (!filePath) {
-    handleUploadError('鏂囦欢璺緞涓嶅瓨鍦�');
+    handleUploadError('鏂囦欢璺緞涓嶅瓨鍦紝璇烽噸鏂版媿鎽�');
     return;
   }
 
@@ -1301,31 +1340,29 @@
               icon: 'success'
             });
           } else {
-            handleUploadError(response.msg || '鏈嶅姟鍣ㄨ繑鍥為敊璇�');
+            handleUploadError(response.msg || `鏈嶅姟鍣ㄨ繑鍥為敊璇� (code: ${response.code})`);
           }
         } else {
-          handleUploadError(`鏈嶅姟鍣ㄩ敊璇紝鐘舵�佺爜: ${res.statusCode}`);
+          handleUploadError(`鏈嶅姟鍣ㄩ敊璇紝鐘舵�佺爜: ${res.statusCode}锛岃绋嶅悗閲嶈瘯鎴栬仈绯荤鐞嗗憳`);
         }
       } catch (e) {
         console.error('瑙f瀽鍝嶅簲澶辫触:', e);
         console.error('鍘熷鍝嶅簲鏁版嵁:', res.data);
-        handleUploadError('鍝嶅簲鏁版嵁瑙f瀽澶辫触: ' + e.message);
+        handleUploadError('鏈嶅姟鍣ㄥ搷搴旇В鏋愬け璐ワ紝璇疯仈绯荤鐞嗗憳');
       }
     },
     fail: (err) => {
-      console.error('涓婁紶澶辫触:', err.errMsg || err);
+      console.error('涓婁紶澶辫触:', err);
       number.value--; // 涓婁紶澶辫触鏃跺噺灏戣鏁�
 
       let errorMessage = '涓婁紶澶辫触';
       if (err.errMsg) {
-        if (err.errMsg.includes('statusCode: null')) {
-          errorMessage = '缃戠粶杩炴帴澶辫触锛岃妫�鏌ョ綉缁滆缃�';
+        if (err.errMsg.includes('statusCode: null') || err.errMsg.includes('fail')) {
+          errorMessage = '缃戠粶杩炴帴澶辫触锛岃妫�鏌ョ綉缁滆缃悗閲嶈瘯';
         } else if (err.errMsg.includes('timeout')) {
-          errorMessage = '涓婁紶瓒呮椂锛岃閲嶈瘯';
-        } else if (err.errMsg.includes('fail')) {
-          errorMessage = '涓婁紶澶辫触锛岃妫�鏌ョ綉缁滆繛鎺�';
+          errorMessage = '涓婁紶瓒呮椂锛岃妫�鏌ョ綉缁滃悗閲嶈瘯';
         } else {
-          errorMessage = err.errMsg;
+          errorMessage = '涓婁紶澶辫触锛�' + err.errMsg;
         }
       }
 
@@ -1346,26 +1383,16 @@
 }
 
 // 涓婁紶澶辫触澶勭悊
-const handleUploadError = (message = '涓婁紶鏂囦欢澶辫触', showRetry = false) => {
+const handleUploadError = (message = '涓婁紶鏂囦欢澶辫触') => {
   uploading.value = false;
   uploadProgress.value = 0;
-  
-  if (showRetry) {
-    uni.showModal({
-      title: '涓婁紶澶辫触',
-      content: message + '锛屾槸鍚﹂噸璇曪紵',
-      success: (res) => {
-        if (res.confirm) {
-          // 鐢ㄦ埛閫夋嫨閲嶈瘯锛岃繖閲屽彲浠ラ噸鏂拌Е鍙戜笂浼�
-        }
-      }
-    });
-  } else {
-    uni.showToast({
-      title: message,
-      icon: 'error'
-    });
-  }
+
+  uni.showModal({
+    title: '涓婁紶澶辫触',
+    content: message,
+    showCancel: false,
+    confirmText: '鐭ラ亾浜�'
+  });
 }
 
 // 涓婁紶鎴愬姛鍥炶皟
@@ -1379,7 +1406,7 @@
   if (!uploadedFile) {
     console.error('鏃犳硶瑙f瀽涓婁紶鍝嶅簲鏁版嵁:', res);
     number.value--; // 涓婁紶澶辫触鏃跺噺灏戣鏁�
-    handleUploadError('涓婁紶鍝嶅簲鏁版嵁鏍煎紡閿欒', false);
+    handleUploadError('涓婁紶鍝嶅簲鏁版嵁鏍煎紡閿欒');
     return;
   }
 

--
Gitblit v1.9.3