ZZJ
2021-12-13 d91c8da48ca76f43999220971bc540227790c1e4

3个文件已修改
139 ■■■■■ 已修改文件
src/pages/index/App.vue 127 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/index/api.ts 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
vue.config.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/index/App.vue
@@ -1,5 +1,6 @@
<template>
  <div class="init" v-if="!isWhite">
    <img class="img-test" onerror="console.log('网络故障')" />
    <div class="content">
      <div class="title">欢迎注册Smart AI 人工智能操作系统</div>
      <el-steps :active="active" finish-status="success" :align-center="true">
@@ -30,7 +31,10 @@
      <div class="control">
        <div class="pre" @click="preForm">上一步</div>
        <div class="next" @click="nextForm" v-if="active == 0">下一步</div>
        <div class="next" @click="nextForm" v-if="active == 1">跳过</div>
        <div class="next" @click="nextFormNot" v-if="active == 1">跳过</div>
        <div class="next" @click="nextForm" v-if="active == 1 && !isNet">
          下一步
        </div>
        <div class="next" @click="nextForm" v-if="active == 2">完成</div>
      </div>
    </div>
@@ -48,17 +52,49 @@
  initNetwork,
  saveRegInfo,
  getRegInfo,
  isOnNet,
} from "./api";
export default {
  async created() {},
  mounted() {
    this.getInitInfo();
    let message = "网络正常";
    function onLine(callback) {
      var img = new Image();
      //临时判断网络是否通畅
      img.src = "http://apps.smartai.com/img/icon_logo.f78688b5.png";
      img.onload = function () {
        console.log("11111");
        if (callback) callback(true);
      };
      img.onerror = function () {
        console.log("22222");
        if (callback) callback(false);
      };
    }
    onLine((flag) => {
      let message = "";
      if (flag) {
        this.isNet = true;
        message = "已有网络";
      } else {
        //网络断网效果图出来后,将此地改为跳转路径到效果图上
        message = "未配置网络";
      }
      this.$notify({
        message: message,
      });
    });
  },
  data() {
    return {
      active: 0,
      formData: {},
      isWhite: true,
      isNet: false,
    };
  },
  components: {
@@ -89,61 +125,74 @@
        }
        const res1 = await savePassword(data);
        console.log(data);
        this.active++;
        this.$refs["carousel"].next();
      }
      if (this.active == 1) {
        const data = this.$refs[`form${this.active}`].getFormData();
        initNetwork(data);
        this.active++;
        this.$refs["carousel"].next();
      }
    },
    nextFormNot() {
      this.active++;
      this.$refs["carousel"].next();
    },
    systemLogin() {
      this.nullRule = this.rules
      this.nullRule = this.rules;
      this.$nextTick(() => {
        this.$refs['ruleForm'].validate(valid => {
        this.$refs["ruleForm"].validate((valid) => {
          if (valid) {
            this.loading = this.$loading({
              lock: true,
              text: 'Loading',
              spinner: 'el-icon-loading',
              background: 'rgba(0, 0, 0, 0.7)'
            })
            this.testLogin()
              text: "Loading",
              spinner: "el-icon-loading",
              background: "rgba(0, 0, 0, 0.7)",
            });
            this.testLogin();
          } else {
            this.nullRule = {}
            this.nullRule = {};
          }
        })
        this.nullRule = {}
      })
        });
        this.nullRule = {};
      });
    },
    async testLogin() {
      // location.assign("/view/desktop/")
      tologin({ username: this.user.loginName, password: this.user.password })
        .then(json => {
        .then((json) => {
          const loginedInfo = {
            access_token: json.token_type + ' ' + json.access_token,
            refresh_token: json.refresh_token
          }
          sessionStorage.setItem('expires_in', json.expires_in)
          sessionStorage.setItem('loginedInfo', JSON.stringify(loginedInfo))
          this.loading.close()
          this.getLoginUserData()
            access_token: json.token_type + " " + json.access_token,
            refresh_token: json.refresh_token,
          };
          sessionStorage.setItem("expires_in", json.expires_in);
          sessionStorage.setItem("loginedInfo", JSON.stringify(loginedInfo));
          this.loading.close();
          this.getLoginUserData();
        })
        .catch(err => {
          this.loading.close()
        .catch((err) => {
          this.loading.close();
          this.$notify({
            title: '提示',
            type: 'error',
            message: err.msg
          })
          this.$refs.pwd.focus()
        })
            title: "提示",
            type: "error",
            message: err.msg,
          });
          this.$refs.pwd.focus();
        });
    },
    async getLoginUserData() {
      let res = await getLoginUserData()
      let res = await getLoginUserData();
      if (res.success) {
        sessionStorage.setItem('userInfo', JSON.stringify(res.data))
        this.$notify.success("登录成功!")
        sessionStorage.setItem("userInfo", JSON.stringify(res.data));
        this.$notify.success("登录成功!");
        // 获取权限
        await this.getMenuList()
        location.assign("/view/desktop/")
        return res.data
        await this.getMenuList();
        location.assign("/view/desktop/");
        return res.data;
      } else {
        this.$notify.error("登录失败!")
        this.$notify.error("登录失败!");
      }
      this.active++;
@@ -277,15 +326,12 @@
    .control {
      position: fixed;
      display: flex;
      justify-content: center;
      align-items: center;
      bottom: 258px;
      top: 770px;
      left: 0;
      right: 0;
      line-height: 40px;
      .pre {
        margin-right: 20px;
        margin: 10px auto;
        cursor: pointer;
        width: 260px;
        height: 40px;
@@ -296,6 +342,7 @@
      }
      .next {
        margin: 10px auto;
        cursor: pointer;
        width: 260px;
        height: 40px;
src/pages/index/api.ts
@@ -64,4 +64,12 @@
    method: "get",
    params: query
  });
};
export const isOnNet = (query: any) => {
  return request({
    url: "http://apps.smartai.com/data/api-u/user/login",
    method: "get",
    params: query
  });
};
vue.config.js
@@ -40,8 +40,8 @@
  // }
});
// const serverUrl = "http://192.168.20.189:7009"; // 羊五
 const serverUrl = "http://192.168.8.10:7009";
const serverUrl = "http://192.168.20.189:7009"; // 羊五//
// const serverUrl = "http://192.168.8.10:7009";
const serverUrl2 = "http://192.168.8.10:9000";
// const serverUrl = "http://192.168.20.10:7009";
// const serverUrl2 = "http://192.168.20.10:9000";