yanghao 2 тижнів тому
батько
коміт
c8dad03df9
1 змінених файлів з 35 додано та 12 видалено
  1. 35 12
      src/views/flow/index.vue

+ 35 - 12
src/views/flow/index.vue

@@ -196,7 +196,7 @@ import * as echarts from "echarts";
 import { useRouter } from "vue-router";
 import dd from "dingtalk-jsapi";
 const router = useRouter();
-
+import { ElLoading, ElMessage } from "element-plus";
 const userStore = useUserStore();
 
 const lineChartInstance = ref(null);
@@ -493,34 +493,57 @@ const go = async (item) => {
       const res = await ssoLogin({
         username: userStore.getUser.username,
       });
-
       if (res) {
         const ua = window.navigator.userAgent.toLowerCase();
+
         if (ua.includes("dingtalk") || ua.includes("dingtalkwork")) {
-          console.log(
-            "现在是钉钉。。。。。。。。。。。。。。。。。。。。。。。。。",
-          );
+          // 钉钉环境
+          const loading = ElLoading.service({
+            lock: true,
+            text: "正在跳转,请稍候...",
+            background: "rgba(0, 0, 0, 0.7)",
+          });
+
           const targetUrl1 = item.indexUrl + "?ssoToken=" + res + "#/main";
           const targetUrl2 = item.flowUrl;
+
           dd.biz.util.openLink({
-            url: targetUrl1, // 先跳你的 SSO 链接
+            url: targetUrl1,
             onSuccess: () => {
-              // 延迟跳目标业务地址(和你原来 setTimeout 逻辑一致)
               setTimeout(() => {
-                dd.biz.util.openLink({ url: targetUrl2 });
-              }, 100);
+                dd.biz.util.openLink({
+                  url: targetUrl2,
+                  onSuccess: () => {
+                    loading.close();
+                  },
+                  onFail: (err) => {
+                    loading.close();
+                    ElMessage.error("跳转失败,请重试");
+                  },
+                });
+              }, 2000);
             },
             onFail: (err) => {
-              console.log("钉钉err>>>>>>>>>>>>>>>>>>>>> ", err);
+              loading.close();
+              ElMessage.error("打开链接失败,请重试");
             },
           });
         } else {
-          const newTab = window.open("", "_blank");
+          // 浏览器环境
+          const loading = ElLoading.service({
+            lock: true,
+            text: "正在跳转,请稍候...",
+            background: "rgba(0, 0, 0, 0.7)",
+          });
 
+          const newTab = window.open("", "_blank");
           newTab.location.href = item.indexUrl + "?ssoToken=" + res + "#/main";
 
-          setTimeout(function () {
+          setTimeout(() => {
             newTab.location.href = item.flowUrl;
+            setTimeout(() => {
+              loading.close();
+            }, 500);
           }, 100);
         }
       }