| | |
| | | import {login, logout, getInfo, loginCheck, loginCheckFactory} from '@/api/login'
|
| | | import {login, logout, getInfo, loginCheck, loginCheckFactory,tideLogin} from '@/api/login'
|
| | | import { getToken, setToken, removeToken } from '@/utils/auth'
|
| | | import { isHttp, isEmpty } from "@/utils/validate"
|
| | | import defAva from '@/assets/images/profile.jpg'
|
| | |
| | | })
|
| | | })
|
| | | },
|
| | | getCurrentTime() {
|
| | | const now = new Date();
|
| | | const year = now.getFullYear(); // 获取年份
|
| | | const month = String(now.getMonth() + 1).padStart(2, '0'); // 月份从0开始,要+1,并补零
|
| | | const day = String(now.getDate()).padStart(2, '0'); // 日期补零
|
| | | const hours = String(now.getHours()).padStart(2, '0'); // 小时补零
|
| | | const minutes = String(now.getMinutes()).padStart(2, '0'); // 分钟补零
|
| | | const seconds = String(now.getSeconds()).padStart(2, '0'); // 秒数补零
|
| | | return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
| | | },
|
| | | // 获取用户信息
|
| | | getInfo() {
|
| | | return new Promise((resolve, reject) => {
|
| | |
| | | this.avatar = avatar
|
| | | this.currentFactoryName = user.currentFactoryName
|
| | | this.nickName = user.nickName
|
| | | this.roleName = user.roles[0].roleName
|
| | | this.currentDeptId = user.tenantId
|
| | | this.currentLoginTime = this.getCurrentTime()
|
| | | resolve(res)
|
| | | }).catch(error => {
|
| | | reject(error)
|
| | |
| | | })
|
| | | })
|
| | | },
|
| | | TideLogin({ commit }, code) {
|
| | | return new Promise((resolve, reject) => {
|
| | | tideLogin(code)
|
| | | .then((res) => {
|
| | | setToken(res.token);
|
| | | commit("SET_TOKEN", res.token);
|
| | | Vue.prototype.uploadHeader = {
|
| | | Authorization: "Bearer " + res.token,
|
| | | };
|
| | | resolve();
|
| | | })
|
| | | .catch((error) => {
|
| | | reject(error);
|
| | | });
|
| | | });
|
| | | },
|
| | | }
|
| | | })
|
| | |
|