| | |
| | | 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 { |
| | |
| | | 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); |
| | |
| | | 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("登录成功"); |
| | | } |