no message
This commit is contained in:
parent
b08226ed26
commit
7fc60685df
@ -1,19 +1,8 @@
|
||||
import http from "@/utils/request"
|
||||
export default {
|
||||
menu: {
|
||||
myMenus: {
|
||||
url: `/system/menu/my`,
|
||||
name: "获取我的菜单",
|
||||
get: async function() {
|
||||
return await http.get(this.url);
|
||||
}
|
||||
},
|
||||
list: {
|
||||
url: `/system/menu/lists`,
|
||||
name: "获取菜单",
|
||||
get: async function() {
|
||||
return await http.get(this.url);
|
||||
}
|
||||
index: {
|
||||
get: async function() {
|
||||
return await http.get('/system/index');
|
||||
}
|
||||
},
|
||||
dic: {
|
||||
|
@ -65,7 +65,7 @@ router.beforeEach(async (to, from, next) => {
|
||||
//加载动态/静态路由
|
||||
if (!isGetRouter) {
|
||||
// 重新获取菜单路
|
||||
api.system.menu.myMenus.get().then((response) => {
|
||||
api.system.index.get().then((response) => {
|
||||
tool.data.set("menu", response.data.menu)
|
||||
tool.data.set("userinfo", response.data.user)
|
||||
tool.data.set("permissions", response.data.permissions)
|
||||
|
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<el-form ref="loginForm" :model="form" :rules="rules" label-width="0" size="large" @keyup.enter="login">
|
||||
<el-form-item prop="user">
|
||||
<el-input v-model="form.user" prefix-icon="el-icon-user" clearable :placeholder="$t('login.userPlaceholder')">
|
||||
<el-input v-model="form.account" prefix-icon="el-icon-user" clearable :placeholder="$t('login.userPlaceholder')">
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="password">
|
||||
@ -28,14 +28,13 @@
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
userType: 'admin',
|
||||
form: {
|
||||
user: "admin",
|
||||
password: "admin",
|
||||
autologin: false
|
||||
account: "",
|
||||
password: "",
|
||||
autologin: true
|
||||
},
|
||||
rules: {
|
||||
user: [
|
||||
account: [
|
||||
{required: true, message: this.$t('login.userError'), trigger: 'blur'}
|
||||
],
|
||||
password: [
|
||||
@ -46,15 +45,7 @@
|
||||
}
|
||||
},
|
||||
watch:{
|
||||
userType(val){
|
||||
if(val == 'admin'){
|
||||
this.form.user = 'admin'
|
||||
this.form.password = 'admin'
|
||||
}else if(val == 'user'){
|
||||
this.form.user = 'user'
|
||||
this.form.password = 'user'
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
mounted() {
|
||||
|
||||
@ -66,25 +57,26 @@
|
||||
if(!validate){ return false }
|
||||
|
||||
this.islogin = true
|
||||
|
||||
var data = {
|
||||
username: this.form.user,
|
||||
password: this.$tool.crypto.MD5(this.form.password)
|
||||
account: this.form.account,
|
||||
password: this.$tool.crypto.BASE64.encrypt( this.$tool.crypto.BASE64.encrypt( this.form.password ) + this.$tool.crypto.BASE64.encrypt( this.form.account ) )
|
||||
}
|
||||
//获取token
|
||||
var user = await this.$api.auth.token.post(data)
|
||||
if(user.code == 200){
|
||||
this.$tool.cookie.set("token", user.data.token, {
|
||||
expires: 86400*360
|
||||
})
|
||||
}else{
|
||||
if(user.code !== 200){
|
||||
this.islogin = false
|
||||
this.$message.warning(user.message)
|
||||
return false
|
||||
}
|
||||
|
||||
this.$tool.cookie.set("token", user.data.token, {
|
||||
expires: 86400*360
|
||||
})
|
||||
|
||||
//获取菜单
|
||||
var menu = null
|
||||
menu = await this.$api.system.menu.myMenus.get()
|
||||
menu = await this.$api.system.index.get()
|
||||
|
||||
if(menu.code == 200){
|
||||
if(menu.data.menu.length==0){
|
||||
|
@ -36,9 +36,9 @@
|
||||
<el-tab-pane :label="$t('login.accountLogin')" lazy>
|
||||
<password-form></password-form>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('login.mobileLogin')" lazy>
|
||||
<!-- <el-tab-pane :label="$t('login.mobileLogin')" lazy>
|
||||
<phone-form></phone-form>
|
||||
</el-tab-pane>
|
||||
</el-tab-pane> -->
|
||||
</el-tabs>
|
||||
<template v-if="$config.MY_SHOW_LOGIN_OAUTH">
|
||||
<el-divider>{{ $t('login.signInOther') }}</el-divider>
|
||||
@ -52,7 +52,7 @@
|
||||
<el-dialog v-model="showWechatLogin" :title="$t('login.wechatLoginTitle')" :width="400" destroy-on-close>
|
||||
<div class="qrCodeLogin">
|
||||
<sc-qr-code class="qrCode" :text="WechatLoginCode" :size="200"></sc-qr-code>
|
||||
<p class="msg">{{$tc('login.wechatLoginMsg', 1)}}<br/>{{$tc('login.wechatLoginMsg', 2)}}</p>
|
||||
<p class="msg">{{$tc('login.wechatLoginMsg', 1)}}</p>
|
||||
<div class="qrCodeLogin-result" v-if="isWechatLoginResult">
|
||||
<el-result icon="success" :title="$tc('login.wechatLoginResult', 1)" :sub-title="$tc('login.wechatLoginResult', 2)"></el-result>
|
||||
</div>
|
||||
@ -86,6 +86,7 @@
|
||||
}
|
||||
],
|
||||
WechatLoginCode: "",
|
||||
WechatLoginuniqid: "",
|
||||
showWechatLogin: false,
|
||||
isWechatLoginResult: false
|
||||
}
|
||||
@ -123,13 +124,76 @@
|
||||
configLang(command){
|
||||
this.config.lang = command.value
|
||||
},
|
||||
wechatLogin(){
|
||||
this.showWechatLogin = true
|
||||
this.WechatLoginCode = "SCUI-823677237287236-" + new Date().getTime()
|
||||
this.isWechatLoginResult = false
|
||||
setTimeout(()=>{
|
||||
this.isWechatLoginResult = true
|
||||
},3000)
|
||||
long_contact:function(){
|
||||
|
||||
if (!this.WechatLoginuniqid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
setTimeout(async ()=>{
|
||||
var res = await this.$http.post('api/login/wechatSubmit', {uniqid:this.WechatLoginuniqid});
|
||||
|
||||
|
||||
if(res.code==201){
|
||||
this.showWechatLogin = false
|
||||
this.$message.warning(res.message)
|
||||
}else if(res.code==202){
|
||||
this.long_contact()
|
||||
|
||||
}else if(res.code==200){
|
||||
|
||||
this.showWechatLogin = false
|
||||
this.$tool.cookie.set("token", res.data.token, {
|
||||
expires: 86400*360
|
||||
})
|
||||
|
||||
//获取菜单
|
||||
var menu = null
|
||||
menu = await this.$api.system.index.get()
|
||||
|
||||
if(menu.code == 200){
|
||||
if(menu.data.menu.length==0){
|
||||
this.islogin = false
|
||||
this.$alert("当前用户无任何菜单权限,请联系系统管理员", "无权限访问", {
|
||||
type: 'error',
|
||||
center: true
|
||||
})
|
||||
return false
|
||||
}
|
||||
this.$tool.data.set("menu", menu.data.menu)
|
||||
this.$tool.data.set("userinfo", menu.data.user)
|
||||
this.$tool.data.set("permissions", menu.data.permissions)
|
||||
this.$tool.data.set("dashboardgrid", menu.data.dashboardGrid)
|
||||
}else{
|
||||
this.islogin = false
|
||||
this.$message.warning(menu.message)
|
||||
return false
|
||||
}
|
||||
|
||||
this.$router.replace({
|
||||
path: '/'
|
||||
})
|
||||
this.$message.success("Login Success 登录成功")
|
||||
this.islogin = false
|
||||
|
||||
}
|
||||
},1000)
|
||||
|
||||
},
|
||||
async wechatLogin(){
|
||||
var res = await this.$http.get('api/login/wechatQrcode');
|
||||
if (res.code==200) {
|
||||
this.showWechatLogin = true
|
||||
this.WechatLoginCode = res.data.qrcodeurl
|
||||
this.WechatLoginuniqid = res.data.uniqid
|
||||
this.long_contact();
|
||||
// 已扫码
|
||||
// this.isWechatLoginResult = true
|
||||
}else{
|
||||
this.$message.warning(res.message)
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user