From 13313f7a3d725783e08a7e6c9727c88ca9486010 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Fri, 05 Aug 2022 11:49:59 +0800
Subject: [PATCH] 设置token,卷帘
---
src/views/login/index.vue | 66 +++++++++++++++++----------------
1 files changed, 34 insertions(+), 32 deletions(-)
diff --git a/src/views/login/index.vue b/src/views/login/index.vue
index a3113b1..7a1f77b 100644
--- a/src/views/login/index.vue
+++ b/src/views/login/index.vue
@@ -37,53 +37,54 @@
</template>
<script>
-import nprogress from "nprogress"
-import md5 from "js-md5"
-import axios from "axios"
-import { EventBus } from "../../eventBus/event-bus"
+import nprogress from 'nprogress'
+import md5 from 'js-md5'
+import axios from 'axios'
+import * as auth from '@/utils/auth'
+import { EventBus } from '../../eventBus/event-bus'
export default {
- name: "AppRegister",
+ name: 'AppRegister',
data () {
return {
user: {
- username: "",
- password: "",
+ username: '',
+ password: ''
},
rules: {
username: [
- { required: true, message: "用户名不能为空", trigger: "blur" },
+ { required: true, message: '用户名不能为空', trigger: 'blur' },
{
min: 3,
max: 10,
- message: "用户账号长度在3~10个字符之间",
- trigger: "blur",
- },
+ message: '用户账号长度在3~10个字符之间',
+ trigger: 'blur'
+ }
],
password: [
- { required: true, message: "密码不能为空", trigger: "blur" },
+ { required: true, message: '密码不能为空', trigger: 'blur' },
{
min: 3,
max: 10,
- message: "用户密码长度在3~10个字符之间",
- trigger: "blur",
- },
- ],
+ message: '用户密码长度在3~10个字符之间',
+ trigger: 'blur'
+ }
+ ]
},
errors: null,
- newAxios: null,
+ newAxios: null
}
},
created () {
var that = this
this.newAxios = axios.create({
- baseURL: "http://182.106.212.58:8013/api",
+ baseURL: 'http://182.106.212.58:8013/api',
timeout: 600000,
headers: {
- Authorization: "Basic c2FiZXI6c2FiZXJfc2VjcmV0",
- "Tenant-Id": "000000",
- },
+ Authorization: 'Basic c2FiZXI6c2FiZXJfc2VjcmV0',
+ 'Tenant-Id': '000000'
+ }
})
document.onkeydown = (e) => {
@@ -100,30 +101,31 @@
nprogress.start()
this.newAxios({
- method: "POST",
- url: "/blade-auth/oauth/token",
+ method: 'POST',
+ url: '/blade-auth/oauth/token',
params: {
username: username,
password: md5(password),
- tenantId: "000000",
- },
+ tenantId: '000000'
+ }
}).then((res) => {
if (res.data.access_token) {
- this.$store.commit("setUser", res.data)
- this.$router.push({ path: "/" })
+ this.$store.commit('setUser', res.data)
+ auth.setToken(res.data.access_token)
+ this.$router.push({ path: '/' })
} else {
this.$message({
- type: "warning",
- message: "用户名或密码不正确,请重新输入",
+ type: 'warning',
+ message: '用户名或密码不正确,请重新输入'
})
}
nprogress.done()
})
}
})
- },
- },
-};
+ }
+ }
+}
</script>
<style scoped lang="scss">
--
Gitblit v1.9.3