15179599649
2024-01-20 2f447d2cf565cd98c17397a2cb3ea3497eef368c
src/views/login/index.vue
@@ -31,6 +31,7 @@
import { showSuccessToast, showFailToast } from "vant";
import { GetCode, Loginto } from "@/api/hfiveget/index.js";
import { setToken } from "@/utils/auth.js";
import store from "../../store/index";
export default {
  data() {
    return {
@@ -92,20 +93,20 @@
      const isValidcode = this.codecheck(this.Code);
      const isValiduser = this.usernamecheck(this.username);
      if (isValidcode && isValiduser) {
        let Data = {
          tenantId: "000000",
          grant_type: "smsCode",
          phone: this.username,
          code: this.Code
        };
        // let Data = {
        //   tenantId: "000000",
        //   username: this.username,
        //   grant_type: "password",
        //   password: "94e8cde4612b3fd390677d42e7b22002",
        //   scope: "all",
        //   type: "account"
        //   grant_type: "smsCode",
        //   phone: this.username,
        //   code: this.Code
        // };
        let Data = {
          tenantId: "000000",
          username: this.username,
          grant_type: "password",
          password: "94e8cde4612b3fd390677d42e7b22002",
          scope: "all",
          type: "account"
        };
        Loginto(Data).then(res => {
          if (res.data.code == 400) {
            this.$toast.fail(res.data.msg);
@@ -121,6 +122,22 @@
            localStorage.setItem("nick_name", res.data.nick_name); //姓名
            localStorage.setItem("dept_name", res.data.dept_name); //部门
            localStorage.setItem("post_name", res.data.post_name); //职位
            let refreshdata = {
              tenantId: res.data.tenant_id,
              refresh_token: res.data.refresh_token,
              grant_type: "refresh_token",
              scope: "all"
            };
            localStorage.setItem(
              "refreshdatabaocun",
              JSON.stringify(refreshdata)
            );
            // setTimeout(() => {
            //   Loginto(refreshdata).then(res => {
            //     console.log(res);
            //   });
            // }, 1000);
            store.commit("updaterefreshdata", refreshdata);
            setToken(res.data.access_token);
            this.$toast.success("登录成功");
          }