From 9497fbad9254f75460110e4e77768111e78a5403 Mon Sep 17 00:00:00 2001
From: cqf
Date: 星期四, 16 六月 2022 15:12:53 +0800
Subject: [PATCH] 换取登录账号
---
src/api/login.js | 15 +++++++++++++--
src/api/sgyhpczl/auth.js | 8 +++++++-
src/api/sgyhpczl/careabout.js | 4 +---
src/api/sgyhpczl/majorHidden.js | 4 +---
src/views/login/index.vue | 22 +++++++++++++++++++++-
src/views/hiddenDangerRegistration/index.vue | 5 ++---
6 files changed, 45 insertions(+), 13 deletions(-)
diff --git a/src/api/login.js b/src/api/login.js
index ab903dc..8182cb6 100644
--- a/src/api/login.js
+++ b/src/api/login.js
@@ -1,6 +1,17 @@
import request from '@/utils/request'
import { getToken } from '@/utils/auth'
+const LOGIN_SYSTEM_URL = "http://localhost:8008";
+
+export function getAccount(data) {
+ return request({
+ url: LOGIN_SYSTEM_URL + '/auth/getAccount',
+ method: 'post',
+ data
+ })
+}
+
+
export function loginByUsername(data) {
return request({
headers: {
@@ -22,14 +33,14 @@
})
}
-export function getUserInfo(token) {
+export function getUserInfo() {
return request({
headers: {
'Authorization': getToken()
},
url: process.env.BASE_API + '/auth/verify',
method: 'get',
- data: { 'token': token, 'action': 'getUserInfo' }
+ data: { 'token': getToken(), 'action': 'getUserInfo' }
})
}
diff --git a/src/api/sgyhpczl/auth.js b/src/api/sgyhpczl/auth.js
index bb29b02..2fb2fe5 100644
--- a/src/api/sgyhpczl/auth.js
+++ b/src/api/sgyhpczl/auth.js
@@ -4,6 +4,9 @@
const hiddenDangerToken = 'hiddenDangerToken'
const hiddenDangerVerify = 'hiddenDangerVerify'
+const hiddenDangerUsername = 'hiddenDangerUsername'
+const hiddenDangerPassword = 'hiddenDangerPassword'
+
export function getTokenAndVerify() {
let token=Cookies.get(hiddenDangerToken)
let verify=Cookies.get(hiddenDangerVerify)
@@ -18,8 +21,11 @@
}
export function setTokenAndVerify() {
+ let username=Cookies.get(hiddenDangerUsername) ? Cookies.get(hiddenDangerUsername) : baseInfo.username
+ let password=Cookies.get(hiddenDangerPassword) ? Cookies.get(hiddenDangerPassword) : baseInfo.password
$.ajax({
- url: "/taboi/account/login_do?username="+baseInfo.username+"&password="+baseInfo.password+"&key="+baseInfo.key,
+ // url: "/taboi/account/login_do?username="+baseInfo.username+"&password="+baseInfo.password+"&key="+baseInfo.key,
+ url: "/taboi/account/login_do?username="+username+"&password="+password+"&key="+baseInfo.key,
type: "GET",
contentType: "multipart/form-data",
async: false,
diff --git a/src/api/sgyhpczl/careabout.js b/src/api/sgyhpczl/careabout.js
index 2e871ad..97e2d3c 100644
--- a/src/api/sgyhpczl/careabout.js
+++ b/src/api/sgyhpczl/careabout.js
@@ -1,5 +1,5 @@
import request from '@/utils/request';
-import {getTokenAndVerify,getUsernameAndPassword} from "@/api/sgyhpczl/auth";
+import {getTokenAndVerify} from "@/api/sgyhpczl/auth";
export function getPageList(data) {
@@ -69,8 +69,6 @@
headers:{
'token': getTokenAndVerify().token,
'verify':getTokenAndVerify().verify,
- 'username': getUsernameAndPassword.username,
- 'password':getUsernameAndPassword().password
},
url: "/taboi/danger/focus_list",
contentType: "application/json",
diff --git a/src/api/sgyhpczl/majorHidden.js b/src/api/sgyhpczl/majorHidden.js
index 6edcb8f..1e16e96 100644
--- a/src/api/sgyhpczl/majorHidden.js
+++ b/src/api/sgyhpczl/majorHidden.js
@@ -1,5 +1,5 @@
import request from '@/utils/request';
-import {getTokenAndVerify,getUsernameAndPassword} from "@/api/sgyhpczl/auth";
+import {getTokenAndVerify} from "@/api/sgyhpczl/auth";
export function getPageList(data) {
@@ -79,8 +79,6 @@
headers:{
'token': getTokenAndVerify().token,
'verify':getTokenAndVerify().verify,
- 'username': getUsernameAndPassword.username,
- 'password':getUsernameAndPassword().password
},
url: "/taboi/danger/major_list",
contentType: "application/json",
diff --git a/src/views/hiddenDangerRegistration/index.vue b/src/views/hiddenDangerRegistration/index.vue
index 42005dc..a49cc21 100644
--- a/src/views/hiddenDangerRegistration/index.vue
+++ b/src/views/hiddenDangerRegistration/index.vue
@@ -468,11 +468,10 @@
},
beforeUpload(file) {
var FileExt = file.name.replace(/.+\./, "");
- //.jpg,.gif,.bmp,.png,.doc,.docx,.pdf,.ppt,.pptx,.xls,.xlsx,.rar,.zip
- if (['jpg', 'png', 'bmp', 'gif', 'jpeg','doc','docx','pdf','ppt','xls','pptx','xls','xlsx','rar','zip'].indexOf(FileExt.toLowerCase()) === -1) {
+ if (['xls','xlsx'].indexOf(FileExt.toLowerCase()) === -1) {
this.$message({
type: 'warning',
- message: '请上传后缀名为jpg,gif,bmp,png,doc,docx,pdf,ppt,pptx,xls,xlsx,rar,zip的图片!'
+ message: '请上传后缀名为xls,xlsx的图片!'
});
return false;
}
diff --git a/src/views/login/index.vue b/src/views/login/index.vue
index 3a0e544..f13ab50 100644
--- a/src/views/login/index.vue
+++ b/src/views/login/index.vue
@@ -35,7 +35,7 @@
</template>
<script>
- import { loginByUsername } from '@/api/login'
+ import { getAccount,loginByUsername,getUserInfo } from '@/api/login'
import { getToken, setToken, removeToken } from '@/utils/auth'
import Cookies from 'js-cookie'
import { initRouter } from '@/utils/router'
@@ -133,6 +133,26 @@
Cookies.set('token_expired_at', data.tokenexpired)
_this.$store.commit('SET_NAME', data.realname)
_this.$store.commit('SET_USER_TYPE', data.type)
+ //换取账号密码
+ getUserInfo().then(res => {
+ if (res.data.code == 200) {
+ // loginForm.department = res.data.result.department
+ loginForm.department = "公司领导"
+ getAccount(loginForm).then(res => {
+ if (res.data.code == "00000") {
+ //缓存账号密码
+ Cookies.set("hiddenDangerUsername",res.data.data.username)
+ Cookies.set("hiddenDangerPassword",res.data.data.password)
+ } else {
+ this.$message({type: 'error', message: res.data.msg, duration: 3000})
+ }
+ })
+
+ } else {
+ this.$message({type: 'error', message: "用户信息获取失败!请重试", duration: 3000})
+ }
+ })
+
// 加载菜单
initRouter(_this)
_this.$router.replace('/')
--
Gitblit v1.9.2