更新avue

This commit is contained in:
smallwei 2018-03-22 15:12:09 +08:00
parent 692ccb2860
commit ee1ebfa7b6
8 changed files with 45 additions and 37 deletions

View File

@ -1,3 +1,5 @@
export default {
'478': '验证码错误,请重新输入',
'401': '没有权限',
'default': '系统未知错误,请反馈给管理员'
}

View File

@ -15,6 +15,7 @@
</template>
<script>
import { fullscreenToggel } from "@/util/util";
import { validatenull } from "@/util/validate";
import { mapGetters } from "vuex";
export default {
@ -43,7 +44,7 @@ export default {
});
},
handleLock() {
if (validatenull(this.form.passwd)) {
if (validatenull(this.lockPasswd)) {
this.box = true;
return;
}

View File

@ -1,32 +1,32 @@
<template>
<el-form class="login-form" status-icon :rules="loginRules" ref="loginForm" :model="loginForm" label-width="0" >
<el-form-item prop="username">
<el-input @keyup.enter.native="handleLogin" v-model="loginForm.username" auto-complete="off" placeholder="请输入用户名"></el-input>
</el-form-item>
<el-form-item prop="password">
<el-input @keyup.enter.native="handleLogin" :type="passwordType" v-model="loginForm.password" auto-complete="off" placeholder="请输入密码">
<i class="el-icon-view el-input__icon" slot="suffix" @click="showPassword"></i>
</el-input>
</el-form-item>
<el-form-item prop="code">
<el-row :span="24">
<el-col :span="14">
<el-input @keyup.enter.native="handleLogin" :maxlength="code.len" v-model="loginForm.code" auto-complete="off" placeholder="请输入验证码"></el-input>
</el-col>
<el-col :span="10">
<div class="login-code">
<span class="login-code-img" @click="refreshCode" v-if="code.type == 'text'">{{code.value}}</span>
<img :src="code.src" class="login-code-img" @click="refreshCode" v-else/>
<i class="icon-shuaxin login-code-icon" @click="refreshCode"></i>
</div>
</el-col>
</el-row>
<el-form class="login-form" status-icon :rules="loginRules" ref="loginForm" :model="loginForm" label-width="0">
<el-form-item prop="username">
<el-input @keyup.enter.native="handleLogin" v-model="loginForm.username" auto-complete="off" placeholder="请输入用户名"></el-input>
</el-form-item>
<el-form-item prop="password">
<el-input @keyup.enter.native="handleLogin" :type="passwordType" v-model="loginForm.password" auto-complete="off" placeholder="请输入密码">
<i class="el-icon-view el-input__icon" slot="suffix" @click="showPassword"></i>
</el-input>
</el-form-item>
<el-form-item prop="code">
<el-row :span="24">
<el-col :span="14">
<el-input @keyup.enter.native="handleLogin" :maxlength="code.len" v-model="loginForm.code" auto-complete="off" placeholder="请输入验证码"></el-input>
</el-col>
<el-col :span="10">
<div class="login-code">
<span class="login-code-img" @click="refreshCode" v-if="code.type == 'text'">{{code.value}}</span>
<img :src="code.src" class="login-code-img" @click="refreshCode" v-else/>
<i class="icon-shuaxin login-code-icon" @click="refreshCode"></i>
</div>
</el-col>
</el-row>
</el-form-item>
<el-form-item>
<el-button type="primary" @click.native.prevent="handleLogin" class="login-submit">登录</el-button>
</el-form-item>
</el-form>
</el-form-item>
<el-form-item>
<el-button type="primary" @click.native.prevent="handleLogin" class="login-submit">登录</el-button>
</el-form-item>
</el-form>
</template>
<script>

View File

@ -14,7 +14,7 @@ const lockPage = '/lock'
router.addRoutes(asyncRouterMap); // 动态添加可访问路由表
router.beforeEach((to, from, next) => {
store.commit('SET_TAG', from.query.src ? from.query.src : from.path);
if (getToken()) { // determine if there has token
if (store.getters.access_token) { // determine if there has token
/* has token*/
if (store.getters.isLock && to.path != lockPage) {
next({ path: lockPage })
@ -23,8 +23,9 @@ router.beforeEach((to, from, next) => {
} else {
if (store.getters.roles.length === 0) {
store.dispatch('GetUserInfo').then(res => {
const roles = res.roles
next({ ...to, replace: true })
}).catch(error => {
}).catch(() => {
store.dispatch('FedLogOut').then(() => {
next({ path: '/login' })
})
@ -56,9 +57,10 @@ function findMenuParent(tagCurrent, tag, tagWel) {
} else if (index != -1) {//判断是否存在了
tagCurrent.splice(index, tagCurrent.length - 1);
} else {//其他操作
console.log(store.getters.menu)
let currentPathObj = store.getters.menu.filter(item => {
if (item.children.length == 1) {
return item.children[0].path === tag.value;
return item.children[0].href === tag.value;
} else {
let i = 0;
let childArr = item.children;
@ -86,4 +88,4 @@ router.afterEach((to, from) => {
setTitle(tag.label);
store.commit('SET_TAG_CURRENT', findMenuParent(tagCurrent, tag, tagWel));
}, 0);
})
})

View File

@ -39,7 +39,7 @@ axios.interceptors.response.use(data => {
let errMsg = error.toString();
let code = errMsg.substr(errMsg.indexOf('code') + 5);
Message({
message: errorCode[code] || '系统未知错误,请反馈给管理员',
message: errorCode[code] || errorCode['default'],
type: 'error'
});
return Promise.reject(new Error(error));

View File

@ -4,6 +4,7 @@ const getters = {
isCollapse: state => state.common.isCollapse,
isLock: state => state.common.isLock,
isFullScren: state => state.common.isFullScren,
lockPasswd: state => state.common.lockPasswd,
tagList: state => state.tags.tagList,
tagCurrent: state => state.tags.tagCurrent,
tagWel: state => state.tags.tagWel,

View File

@ -1,3 +1,4 @@
import { setStore, getStore, removeStore } from '@/util/store'
import { validatenull } from '@/util/validate'
import { getDic } from '@/api/admin'

View File

@ -17,7 +17,7 @@ export const setStore = (params) => {
* 获取localStorage
*/
export const getStore = (params) => {
let { name } = params;
let { name, type } = params;
let obj = {}, content;
obj = window.localStorage.getItem(name);
if (validatenull(obj)) obj = window.sessionStorage.getItem(name);
@ -37,7 +37,8 @@ export const getStore = (params) => {
/**
* 删除localStorage
*/
export const removeStore = name => {
if (!name) return;
export const removeStore = params => {
let { name } = params;
window.localStorage.removeItem(name);
}
window.sessionStorage.removeItem(name);
}