mirror of
https://gitee.com/log4j/pig-ui.git
synced 2024-12-23 05:40:20 +08:00
适配avue,菜单配置 thx@小伟
This commit is contained in:
parent
d76b46c114
commit
7164a9afbc
@ -15,6 +15,19 @@ export const loginByUsername = (username, password, code, randomStr) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function mobileLogin(mobile, code) {
|
||||||
|
var grant_type = 'mobile'
|
||||||
|
var scope = 'server'
|
||||||
|
return request({
|
||||||
|
url: '/auth/mobile/token',
|
||||||
|
headers: {
|
||||||
|
'Authorization': 'Basic cGlnOnBpZw=='
|
||||||
|
},
|
||||||
|
method: 'post',
|
||||||
|
params: { mobile, code, grant_type, scope }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export const getUserInfo = () => {
|
export const getUserInfo = () => {
|
||||||
return request({
|
return request({
|
||||||
url: '/admin/user/info',
|
url: '/admin/user/info',
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-form class="login-form" status-icon :rules="loginRules" ref="loginForm" :model="loginForm" label-width="0" >
|
<el-form class="login-form" status-icon :rules="loginRules" ref="loginForm" :model="loginForm" label-width="0" >
|
||||||
<el-form-item prop="phone">
|
<el-form-item prop="mobile">
|
||||||
<el-input @keyup.enter.native="handleLogin" v-model="loginForm.phone" auto-complete="off" placeholder="请输入手机号码"></el-input>
|
<el-input @keyup.enter.native="handleLogin" v-model="loginForm.mobile" auto-complete="off" placeholder="请输入手机号码"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item prop="code">
|
<el-form-item prop="code">
|
||||||
<el-input @keyup.enter.native="handleLogin" v-model="loginForm.code" auto-complete="off" placeholder="请输入验证码">
|
<el-input @keyup.enter.native="handleLogin" v-model="loginForm.code" auto-complete="off" placeholder="请输入验证码">
|
||||||
@ -21,6 +21,7 @@ const MSGINIT = "发送验证码",
|
|||||||
MSGTIME = 60;
|
MSGTIME = 60;
|
||||||
import { isvalidatemobile } from "@/util/validate";
|
import { isvalidatemobile } from "@/util/validate";
|
||||||
import { mapGetters } from "vuex";
|
import { mapGetters } from "vuex";
|
||||||
|
import request from '@/router/axios'
|
||||||
export default {
|
export default {
|
||||||
name: "codelogin",
|
name: "codelogin",
|
||||||
data() {
|
data() {
|
||||||
@ -43,11 +44,11 @@ export default {
|
|||||||
msgTime: MSGTIME,
|
msgTime: MSGTIME,
|
||||||
msgKey: false,
|
msgKey: false,
|
||||||
loginForm: {
|
loginForm: {
|
||||||
phone: "17547400800",
|
mobile: "17034642119",
|
||||||
code: ""
|
code: ""
|
||||||
},
|
},
|
||||||
loginRules: {
|
loginRules: {
|
||||||
phone: [{ required: true, trigger: "blur", validator: validatePhone }],
|
mobile: [{ required: true, trigger: "blur", validator: validatePhone }],
|
||||||
code: [{ required: true, trigger: "blur", validator: validateCode }]
|
code: [{ required: true, trigger: "blur", validator: validateCode }]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -61,6 +62,23 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
handleSend() {
|
handleSend() {
|
||||||
if (this.msgKey) return;
|
if (this.msgKey) return;
|
||||||
|
if (!this.loginForm.mobile) {
|
||||||
|
this.$message.error('请输入手机号码')
|
||||||
|
} else if (!(/^1[34578]\d{9}$/.test(this.loginForm.mobile))) {
|
||||||
|
this.$message.error('手机号格式不正确')
|
||||||
|
} else {
|
||||||
|
request({
|
||||||
|
url: '/admin/smsCode/' + this.loginForm.mobile,
|
||||||
|
method: 'get'
|
||||||
|
}).then(response => {
|
||||||
|
if (response.data.data) {
|
||||||
|
this.timer()
|
||||||
|
this.$message.success('验证码发送成功')
|
||||||
|
} else {
|
||||||
|
this.$message.error(response.data.msg)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
this.msgText = MSGSCUCCESS.replace("${time}", this.msgTime);
|
this.msgText = MSGSCUCCESS.replace("${time}", this.msgTime);
|
||||||
this.msgKey = true;
|
this.msgKey = true;
|
||||||
const time = setInterval(() => {
|
const time = setInterval(() => {
|
||||||
@ -78,11 +96,7 @@ export default {
|
|||||||
this.$refs.loginForm.validate(valid => {
|
this.$refs.loginForm.validate(valid => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
this.$store.dispatch("LoginByPhone", this.loginForm).then(response => {
|
this.$store.dispatch("LoginByPhone", this.loginForm).then(response => {
|
||||||
if (response.data.data) {
|
console.log(response)
|
||||||
this.$message.success('验证码发送成功')
|
|
||||||
} else {
|
|
||||||
this.$message.error(response.data.msg)
|
|
||||||
}
|
|
||||||
this.$store.commit("ADD_TAG", this.tagWel);
|
this.$store.commit("ADD_TAG", this.tagWel);
|
||||||
this.$router.push({ path: this.tagWel.value });
|
this.$router.push({ path: this.tagWel.value });
|
||||||
});
|
});
|
||||||
|
@ -77,5 +77,23 @@ export const asyncRouterMap = [
|
|||||||
component: _import('wel')
|
component: _import('wel')
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}, {
|
||||||
|
menuId: 1,
|
||||||
|
path: '/admin',
|
||||||
|
component: Layout,
|
||||||
|
name: '系统管理',
|
||||||
|
hidden: false,
|
||||||
|
redirect: '/admin/user',
|
||||||
|
meta: {
|
||||||
|
title: '系统管理',
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
{ menuId: 2, path: 'user', component: _import('admin/user/index', 'views'), name: '用户管理', meta: { title: '用户管理' } },
|
||||||
|
{ menuId: 3, path: 'menu', component: _import('admin/menu/index', 'views'), name: '菜单管理', meta: { title: '菜单管理' } },
|
||||||
|
{ menuId: 4, path: 'role', component: _import('admin/role/index', 'views'), name: '角色管理', meta: { title: '角色管理' } },
|
||||||
|
{ menuId: 5, path: 'dept', component: _import('admin/dept/index', 'views'), name: '部门管理', meta: { title: '部门管理' } },
|
||||||
|
{ menuId: 6, path: 'dict', component: _import('admin/dict/index', 'views'), name: '字典管理', meta: { title: '字典管理' } },
|
||||||
|
{ menuId: 7, path: 'log', component: _import('admin/log/index', 'views'), name: '日志管理', meta: { title: '日志管理' } }
|
||||||
|
]
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { getToken, setToken, removeToken } from '@/util/auth'
|
import { getToken, setToken, removeToken } from '@/util/auth'
|
||||||
import { setStore, getStore } from '@/util/store'
|
import { setStore, getStore } from '@/util/store'
|
||||||
import { validatenull } from '@/util/validate'
|
import { validatenull } from '@/util/validate'
|
||||||
import { loginByUsername, getUserInfo, logout } from '@/api/login'
|
import { loginByUsername, mobileLogin, getUserInfo, logout } from '@/api/login'
|
||||||
import { GetMenu } from '@/api/menu'
|
import { GetMenu } from '@/api/menu'
|
||||||
const user = {
|
const user = {
|
||||||
state: {
|
state: {
|
||||||
@ -30,16 +30,19 @@ const user = {
|
|||||||
},
|
},
|
||||||
//根据手机号登录
|
//根据手机号登录
|
||||||
LoginByPhone({ commit, state, dispatch }, userInfo) {
|
LoginByPhone({ commit, state, dispatch }, userInfo) {
|
||||||
return new Promise((resolve, reject) => {
|
const mobile = userInfo.mobile.trim()
|
||||||
loginByUsername(userInfo.phone, userInfo.code).then(res => {
|
return new Promise((resolve, reject) => {
|
||||||
const data = response.data
|
mobileLogin(mobile, userInfo.smsCode).then(response => {
|
||||||
setToken(data.access_token)
|
const data = response.data
|
||||||
commit('SET_ACCESS_TOKEN', data.access_token)
|
setToken(data.access_token)
|
||||||
commit('SET_REFRESH_TOKEN', data.refresh_token)
|
commit('SET_ACCESS_TOKEN', data.access_token)
|
||||||
commit('CLEAR_LOCK');
|
commit('SET_REFRESH_TOKEN', data.refresh_token)
|
||||||
resolve();
|
commit('CLEAR_LOCK');
|
||||||
})
|
resolve()
|
||||||
|
}).catch(error => {
|
||||||
|
reject(error)
|
||||||
})
|
})
|
||||||
|
})
|
||||||
},
|
},
|
||||||
GetTableData({ commit, state, dispatch }, page) {
|
GetTableData({ commit, state, dispatch }, page) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
@ -59,6 +59,9 @@
|
|||||||
<el-form-item label="前端组件" prop="component">
|
<el-form-item label="前端组件" prop="component">
|
||||||
<el-input v-model="form.component" :disabled="formEdit" placeholder="请输入描述"></el-input>
|
<el-input v-model="form.component" :disabled="formEdit" placeholder="请输入描述"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="前端地址" prop="component">
|
||||||
|
<el-input v-model="form.path" :disabled="formEdit" placeholder="iframe嵌套地址"></el-input>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item v-if="formStatus == 'update'">
|
<el-form-item v-if="formStatus == 'update'">
|
||||||
<el-button type="primary" @click="update">更新</el-button>
|
<el-button type="primary" @click="update">更新</el-button>
|
||||||
<el-button @click="onCancel">取消</el-button>
|
<el-button @click="onCancel">取消</el-button>
|
||||||
@ -108,7 +111,8 @@
|
|||||||
sort: undefined,
|
sort: undefined,
|
||||||
component: undefined,
|
component: undefined,
|
||||||
type: undefined,
|
type: undefined,
|
||||||
method: undefined
|
method: undefined,
|
||||||
|
path: undefined
|
||||||
},
|
},
|
||||||
currentId: -1,
|
currentId: -1,
|
||||||
menuManager_btn_add: false,
|
menuManager_btn_add: false,
|
||||||
@ -224,7 +228,8 @@
|
|||||||
sort: undefined,
|
sort: undefined,
|
||||||
component: undefined,
|
component: undefined,
|
||||||
type: undefined,
|
type: undefined,
|
||||||
method: undefined
|
method: undefined,
|
||||||
|
path: undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user