| | |
| | | </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) => { |
| | |
| | | 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"> |