From 66cca2985fedd90ec2d7ecd637df8c03ae6f1bc2 Mon Sep 17 00:00:00 2001
From: lzhe <181968431@qq.com>
Date: 星期日, 24 三月 2024 09:53:03 +0800
Subject: [PATCH] 1
---
src/views/login/components/passwordForm.vue | 145 +++++++++++++++++++++++++++---------------------
1 files changed, 81 insertions(+), 64 deletions(-)
diff --git a/src/views/login/components/passwordForm.vue b/src/views/login/components/passwordForm.vue
index db1b966..924bd4b 100644
--- a/src/views/login/components/passwordForm.vue
+++ b/src/views/login/components/passwordForm.vue
@@ -1,32 +1,15 @@
<template>
- <el-form ref="loginForm" :model="form" :rules="rules" label-width="0" size="large" @keyup.enter="login">
+ <el-form ref="loginForm" :model="form" :rules="rules" label-width="0" size="large" @keyup.enter="login" class="login-form">
<el-form-item prop="user">
- <el-input v-model="form.user" prefix-icon="el-icon-user" clearable :placeholder="$t('login.userPlaceholder')">
- <template #append>
- <el-select v-model="userType" style="width: 130px;">
- <el-option :label="$t('login.admin')" value="admin"></el-option>
- <el-option :label="$t('login.user')" value="user"></el-option>
- </el-select>
- </template>
+ <el-input v-model="form.user" prefix-icon="el-icon-user" clearable :placeholder="$t('login.userPlaceholder')" class="inputHeight">
</el-input>
</el-form-item>
<el-form-item prop="password">
- <el-input v-model="form.password" prefix-icon="el-icon-lock" clearable show-password :placeholder="$t('login.PWPlaceholder')"></el-input>
- </el-form-item>
- <el-form-item style="margin-bottom: 10px;">
- <el-col :span="12">
- <el-checkbox :label="$t('login.rememberMe')" v-model="form.autologin"></el-checkbox>
- </el-col>
- <el-col :span="12" class="login-forgot">
- <router-link to="/reset_password">{{ $t('login.forgetPassword') }}锛�</router-link>
- </el-col>
+ <el-input v-model="form.password" prefix-icon="el-icon-lock" clearable show-password :placeholder="$t('login.PWPlaceholder')" class="inputHeight"></el-input>
</el-form-item>
<el-form-item>
- <el-button type="primary" style="width: 100%;" :loading="islogin" round @click="login">{{ $t('login.signIn') }}</el-button>
+ <el-button type="primary" style="width: 100%;" :loading="islogin" @click="login">{{ $t('login.signIn') }}</el-button>
</el-form-item>
- <div class="login-reg">
- {{$t('login.noAccount')}} <router-link to="/user_register">{{$t('login.createAccount')}}</router-link>
- </div>
</el-form>
</template>
@@ -63,65 +46,99 @@
}
},
mounted() {
-
+ //this.$HTTP.get('/api/blade-sync/outer-app-config/appStatus')
},
methods: {
async login(){
-
var validate = await this.$refs.loginForm.validate().catch(()=>{})
if(!validate){ return false }
-
this.islogin = true
var data = {
username: this.form.user,
- password: this.$TOOL.crypto.MD5(this.form.password)
- }
- //鑾峰彇token
- var user = await this.$API.auth.token.post(data)
- if(user.code == 200){
- this.$TOOL.cookie.set("TOKEN", user.data.token, {
- expires: this.form.autologin? 24*60*60 : 0
- })
- this.$TOOL.data.set("USER_INFO", user.data.userInfo)
- }else{
- this.islogin = false
- this.$message.warning(user.message)
- return false
+ //password: this.$TOOL.crypto.MD5(this.form.password)
+ password: this.form.password,
+ tenantId: "000000",
+ grant_type: "password",
+ scope: "all"
}
//鑾峰彇鑿滃崟
- var menu = null
- if(this.form.user == 'admin'){
- menu = await this.$API.system.menu.myMenus.get()
- }else{
- menu = await this.$API.demo.menu.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("PERMISSIONS", menu.data.permissions)
- this.$TOOL.data.set("DASHBOARDGRID", menu.data.dashboardGrid)
- }else{
- this.islogin = false
- this.$message.warning(menu.message)
- return false
- }
+ // var menu = null
+ // if(this.form.user == 'admin'){
+ // menu = await this.$API.system.menu.myMenus.get()
+ // }else{
+ // menu = await this.$API.demo.menu.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("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.$router.replace({
+ // path: '/'
+ // })
+ // this.$message.success("Login Success 鐧诲綍鎴愬姛")
+ // this.islogin = false
+
+
+
+ this.$HTTP.postJ("/api/blade-auth/oauth/token",data).then(res=> {
+ if(res.user_id) {
+ //鑾峰彇token
+ this.$TOOL.cookie.set("TOKEN", res.access_token, {
+ expires: this.form.autologin? 24*60*60 : 0
+ })
+ res.userName = res.user_name;
+ res.role = ["SA", "admin", "Auditor"];
+ res.dashboard = "0";
+ res.userId = "1";
+ this.$TOOL.data.set("USER_INFO", res);
+ //鑾峰彇鑿滃崟
+ this.$API.system.menu.myMenus.get().then(resp=> {
+ if(resp.data.menu.length==0){
+ this.islogin = false
+ this.$alert("褰撳墠鐢ㄦ埛鏃犱换浣曡彍鍗曟潈闄愶紝璇疯仈绯荤郴缁熺鐞嗗憳", "鏃犳潈闄愯闂�", {
+ type: 'error',
+ center: true
+ })
+ return false
+ }
+ this.$TOOL.data.set("MENU", resp.data.menu)
+ this.$TOOL.data.set("PERMISSIONS", resp.data.permissions)
+ this.$TOOL.data.set("DASHBOARDGRID", resp.data.dashboardGrid)
+ });
+ this.$router.replace({
+ path: '/'
+ })
+ this.$message.success("Login Success 鐧诲綍鎴愬姛")
+ this.islogin = false
+ }else {
+ this.islogin = false;
+ this.$message({
+ showClose: true,
+ message: res.error_description,
+ type: 'error'
+ });
+ }
})
- this.$message.success("Login Success 鐧诲綍鎴愬姛")
- this.islogin = false
},
}
}
</script>
<style>
+.login-form {margin: 0 auto;margin-top: 46px;width: 354px;}
+.inputHeight {height: 60px;line-height: 60px;}
</style>
--
Gitblit v1.9.3