|
@@ -55,7 +55,8 @@
|
|
|
|
|
|
<script>
|
|
|
import { ElMessage } from "element-plus";
|
|
|
-import { loginApi, apiGetCodeByToken, apiGetUserMsg, apiGetPrivilegesOfCurrentUserAll } from '../api/api'
|
|
|
+import JSEncrypt from 'jsencrypt'
|
|
|
+import { loginApi, apiGetCodeByToken, apiGetUserMsg, apiGetPrivilegesOfCurrentUserAll, apigetPublicKey } from '../api/api'
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
@@ -120,19 +121,27 @@ export default {
|
|
|
getLogin(userName, password) {
|
|
|
// setToken('userMsg', params)
|
|
|
let that = this
|
|
|
- loginApi(userName, password).then(datas=>{
|
|
|
- if (datas) {
|
|
|
- if (datas.success) {
|
|
|
- // setToken('token', datas.data.access_token)
|
|
|
- window.localStorage.setItem('token', datas.data.access_token)
|
|
|
- that.getTokenCode(datas.data.access_token)
|
|
|
- } else {
|
|
|
- ElMessage.error(datas.message);
|
|
|
- that.loginLoading = false
|
|
|
- }
|
|
|
+ apigetPublicKey().then(request =>{
|
|
|
+ if (request && request.data) {
|
|
|
+ let publicKeyStr = request.data
|
|
|
+ const jsRsa = new JSEncrypt()
|
|
|
+ jsRsa.setPublicKey(publicKeyStr)
|
|
|
+ let passwordRsa = jsRsa.encrypt(password)
|
|
|
+ loginApi(userName, passwordRsa).then(datas=>{
|
|
|
+ if (datas) {
|
|
|
+ if (datas.success) {
|
|
|
+ // setToken('token', datas.data.access_token)
|
|
|
+ window.localStorage.setItem('token', datas.data.access_token)
|
|
|
+ that.getTokenCode(datas.data.access_token)
|
|
|
+ } else {
|
|
|
+ ElMessage.error(datas.message);
|
|
|
+ that.loginLoading = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).catch(e =>{
|
|
|
+ that.loading = false
|
|
|
+ })
|
|
|
}
|
|
|
- }).catch(e =>{
|
|
|
- that.loading = false
|
|
|
})
|
|
|
},
|
|
|
// 根据token获取code
|