diff --git a/src/App.vue b/src/App.vue
index 257d6e3..04e3793 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -5,20 +5,16 @@
diff --git a/src/components/login/Login.vue b/src/components/login/Login.vue
index 71520c1..1cf3e09 100644
--- a/src/components/login/Login.vue
+++ b/src/components/login/Login.vue
@@ -9,16 +9,23 @@
Vue Antd 是西湖区最具影响力的 Web 设计规范
-
-
+
+
-
-
+
+
+
-
-
+
+
@@ -48,14 +55,14 @@
忘记密码
- 登录
+ 登录
@@ -75,17 +82,51 @@ import AInputGroup from 'vue-antd-ui/es/input/Group'
import AButton from 'vue-antd-ui/es/button/button'
import ACol from 'vue-antd-ui/es/grid/Col'
import ACheckbox from 'vue-antd-ui/es/checkbox/Checkbox'
+import AAlert from 'vue-antd-ui/es/alert/index'
const ATabPane = ATabs.TabPane
export default {
name: 'Login',
- components: {ACheckbox, ACol, AButton, AInputGroup, AIcon, AInput, AFormItem, GloablFooter, ATabPane, ATabs, AForm},
+ components: {
+ AAlert,
+ ACheckbox,
+ ACol,
+ AButton,
+ AInputGroup,
+ AIcon,
+ AInput,
+ AFormItem,
+ GloablFooter,
+ ATabPane,
+ ATabs,
+ AForm},
+ data () {
+ return {
+ logging: false,
+ error: ''
+ }
+ },
methods: {
onSubmit (e) {
e.preventDefault()
- console.log('submit')
- this.$router.push('/')
+ this.form.validateFields((err, values) => {
+ if (!err) {
+ this.logging = true
+ this.$axios.post('/login', {
+ name: this.form.getFieldValue('name'),
+ password: this.form.getFieldValue('password')
+ }).then((res) => {
+ this.logging = false
+ const result = res.data
+ if (result.code >= 0) {
+ this.$router.push('/dashboard/workplace')
+ } else {
+ this.error = result.message
+ }
+ })
+ }
+ })
}
}
}
diff --git a/src/mock/index.js b/src/mock/index.js
index 43239fe..c37380d 100644
--- a/src/mock/index.js
+++ b/src/mock/index.js
@@ -1,6 +1,7 @@
import Mock from 'mockjs'
import '@/mock/user/current'
import '@/mock/project'
+import '@/mock/user/login'
// 设置全局延时
Mock.setup({
diff --git a/src/mock/user/login.js b/src/mock/user/login.js
new file mode 100644
index 0000000..4786b5a
--- /dev/null
+++ b/src/mock/user/login.js
@@ -0,0 +1,16 @@
+import Mock from 'mockjs'
+import '@/mock/extend'
+
+Mock.mock('/login', 'post', ({body}) => {
+ let result = {}
+ const {name, password} = JSON.parse(body)
+
+ if (name !== 'admin' || password !== '888888') {
+ result.code = -1
+ result.message = '账户名或密码错误(admin/888888)'
+ } else {
+ result.code = 0
+ result.message = '登录成功'
+ }
+ return result
+})
diff --git a/src/router/index.js b/src/router/index.js
index 09e2e41..551c7cc 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -37,6 +37,7 @@ export default new Router({
path: '/',
name: 'home',
component: MenuView,
+ redirect: '/login',
icon: 'none',
invisible: true,
children: [
@@ -50,7 +51,6 @@ export default new Router({
path: '/dashboard/workplace',
name: '工作台',
component: WorkPlace,
- alias: '/',
icon: 'none'
},
{