소스 검색

添加判断获取蓝信用户信息

aaa 3 년 전
부모
커밋
d14775b20f
1개의 변경된 파일25개의 추가작업 그리고 19개의 파일을 삭제
  1. 25 19
      src/views/home/index.vue

+ 25 - 19
src/views/home/index.vue

@@ -74,8 +74,6 @@ export default {
   created() {
     this.env = process.env.VUE_APP_ENV;
     this.initFun();
-    // this.getLanXinSignature();
-    this.getLanXinCode();
   },
   activated() {
     this.setLanXinNavigator();
@@ -103,25 +101,33 @@ export default {
       });
     },
     // 初始化
-    initFun() {
+    async initFun() {
       // 获取所有用户
-      this.$_http
-        .get(this.$_API.JTXT_GET_USER_ADMIN_USERS)
-        .then(res => {
-          this.$store.commit("updateUserItemStore", {
-            field: "userInfo",
-            value: res.data.content[0]
+      if (this.env === "test") {
+        // 从蓝信获取用户信息
+        // this.getLanXinSignature();
+        console.log("-从蓝信获取用户信息-");
+        this.getLanXinCode();
+      } else {
+        console.log("-从本地获取用户信息-");
+        await this.$_http
+          .get(this.$_API.JTXT_GET_USER_ADMIN_USERS)
+          .then(res => {
+            this.$store.commit("updateUserItemStore", {
+              field: "userInfo",
+              value: res.data.content[0]
+            });
+          })
+          .catch(() => {
+            this.$store.commit("toggleLoading", false);
           });
-          // 获取所有收藏
-          this.getCollection();
-          // 获取所有考试历史
-          this.getExamHistory();
-          //   查询工作信息
-          this.getEngineeringWorkList();
-        })
-        .catch(() => {
-          this.$store.commit("toggleLoading", false);
-        });
+      }
+      // 获取所有收藏
+      this.getCollection();
+      // 获取所有考试历史
+      this.getExamHistory();
+      //   查询工作信息
+      this.getEngineeringWorkList();
       this.activeTabName = 0;
       this.onChangeTabFun(this.activeTabName);
     },