Просмотр исходного кода

自评、复评优化、解决IOS中不能弹出提示的问题、展示优化、提交后的报错展示

ouyj 2 месяцев назад
Родитель
Сommit
36ee896f5a
2 измененных файлов с 30 добавлено и 14 удалено
  1. 19 9
      pages/score/detail/reEvaluate.uvue
  2. 11 5
      pages/score/detail/selfEvaluate.uvue

+ 19 - 9
pages/score/detail/reEvaluate.uvue

@@ -1,13 +1,13 @@
 <template>
-  <uni-navbar-lite :showLeft="true" title="工复评">
+  <uni-navbar-lite :showLeft="true" title="工复评">
     <view class="back-icon" slot="left" @click="goBack">
-      <text class="iconfont icon-back">工分复评</text>
+      <text class="iconfont icon-back">{{ orderType == '1' ? '维修工单复评' : '维保工单复评' }}</text>
     </view>
   </uni-navbar-lite>
   
   <scroll-view class="container" :scroll-y="true">
     <view class="header">
-      <text class="title">工分复评</text>
+      <text class="title"></text>
     </view>
     
     <view class="form">
@@ -1057,7 +1057,7 @@ async function loadMaintenanceTypes() {
         }
         maintenanceTypeOptions.value = options
       }
-    } else {
+    } else { 
       const msg = resultObj.get('msg') as string | null
       console.error('加载检修类型失败:', msg ?? '未知错误')
     }
@@ -1678,10 +1678,14 @@ async function submitReEvaluationForm(): Promise<void> {
     console.log('验证结果:', isValid, '消息:', validationMsg);
     if (!isValid) { 
       console.log('验证失败,显示错误:', validationMsg);
-      uni.showToast({
-        title: validationMsg,
-        icon: 'none'
-      });
+
+      // 在iOS平台中,有时需要稍作延迟才能正确显示toast
+        setTimeout(() => {
+          uni.showToast({
+            title: validationMsg,
+            icon: 'none'
+          });
+        }, 50);
       return;
     }
     
@@ -1760,8 +1764,14 @@ async function submitReEvaluationForm(): Promise<void> {
     } 
   } catch (error: any) { 
     console.error('提交复评失败:', error)  
+    let msg: string | null = null
+    if (error instanceof Error) {
+      msg = error.message
+    } else if (error instanceof UTSJSONObject && error.get('message') != null) {
+      msg = error.get('message') as string | null
+    }
     uni.showToast({
-      title: '提交失败',
+      title: msg ?? '提交失败',
       icon: 'none'
     })
   } finally {

+ 11 - 5
pages/score/detail/selfEvaluate.uvue

@@ -1,13 +1,13 @@
  <template>
-  <uni-navbar-lite :showLeft="true" title="工自评">
+  <uni-navbar-lite :showLeft="true" title="工自评">
     <view class="back-icon" slot="left" @click="goBack">
-      <text class="iconfont icon-back">工分自评</text>
+      <text class="iconfont icon-back">{{ orderType == '1' ? '维修工单自评' : '维保工单自评' }}</text>
     </view>
   </uni-navbar-lite>
   
   <scroll-view class="container" :scroll-y="true">
     <view class="header">
-      <text class="title">工分自评</text>
+      <text class="title"></text>
     </view>
     
     <view class="form">
@@ -1694,9 +1694,15 @@ async function submitSelfEvaluationForm(): Promise<void> {
       })
     } 
   } catch (error: any) { 
-    console.error('提交自评失败:', error)  
+    console.error('提交自评失败:', error) 
+    let msg: string | null = null
+    if (error instanceof Error) {
+      msg = error.message
+    } else if (error instanceof UTSJSONObject && error.get('message') != null) {
+      msg = error.get('message') as string
+    }
     uni.showToast({
-      title: '提交失败',
+      title: msg ?? '提交失败',
       icon: 'none'
     })
   } finally {