添加请求内容~
This commit is contained in:
parent
b61d6d81e7
commit
34b5c7fa1d
1
.env
1
.env
@ -3,6 +3,7 @@
|
|||||||
VITE_API_FRONT_BASE_URL = http://localhost:18081
|
VITE_API_FRONT_BASE_URL = http://localhost:18081
|
||||||
#后端接口
|
#后端接口
|
||||||
VITE_ADMIN_API_BASE_URL = http://localhost:18080
|
VITE_ADMIN_API_BASE_URL = http://localhost:18080
|
||||||
|
|
||||||
VITE_LOGIN_BG = "/login/e36341619bf8f04dcbdc6b01105a85a.png"
|
VITE_LOGIN_BG = "/login/e36341619bf8f04dcbdc6b01105a85a.png"
|
||||||
|
|
||||||
# 标题
|
# 标题
|
||||||
|
@ -15,13 +15,7 @@ export function captchaAdmin(uid: Number) {
|
|||||||
* 登录
|
* 登录
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
export function loginAdmin(uuid:String,username:String, password:String,captcha:String) {
|
export function loginAdmin(data: any) {
|
||||||
const data ={
|
|
||||||
"username": username,
|
|
||||||
"password": password,
|
|
||||||
"captcha": captcha,
|
|
||||||
"uuid": uuid
|
|
||||||
}
|
|
||||||
return adminRequest.post("/login", data)
|
return adminRequest.post("/login", data)
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
<div class="head_l">
|
<div class="head_l">
|
||||||
<!-- <img src="/icoimg.png" alt="收缩" />-->
|
<!-- <img src="/icoimg.png" alt="收缩" />-->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-dropdown>
|
<el-dropdown>
|
||||||
<div class="head_r">
|
<div class="head_r">
|
||||||
<img :src="userStore().adminUserInfo.avatar" alt="头像" class="profile" />
|
<img :src="userStore().adminUserInfo.avatar" alt="头像" class="profile" />
|
||||||
@ -24,6 +23,10 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 退出登录
|
* 退出登录
|
||||||
*/
|
*/
|
||||||
@ -70,6 +73,7 @@ const logout = () => {
|
|||||||
}
|
}
|
||||||
.head_user{
|
.head_user{
|
||||||
.head_user_name{
|
.head_user_name{
|
||||||
|
margin-top: 10px;
|
||||||
color: #333333;
|
color: #333333;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
|
@ -24,24 +24,19 @@ adminRequest.interceptors.request.use(
|
|||||||
// 添加响应拦截器
|
// 添加响应拦截器
|
||||||
adminRequest.interceptors.response.use(
|
adminRequest.interceptors.response.use(
|
||||||
function (response) {
|
function (response) {
|
||||||
|
|
||||||
if (response.data.code){
|
if (response.data.code){
|
||||||
const code = response.data.code
|
const code = response.data.code
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case 500:
|
case 500:
|
||||||
toast.error(response.data.msg)
|
toast.error(response.data.msg)
|
||||||
break
|
return Promise.reject(response.data.msg)
|
||||||
case 401:
|
case 401:
|
||||||
toast.error(response.data.msg)
|
toast.error(response.data.msg)
|
||||||
break
|
return Promise.reject(response.data.msg)
|
||||||
default:
|
default:
|
||||||
toast.error(response.data.msg)
|
return response
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (response.data) {
|
|
||||||
return response.data
|
|
||||||
}
|
|
||||||
return response
|
return response
|
||||||
},
|
},
|
||||||
function (error) {
|
function (error) {
|
||||||
|
@ -1,45 +1,72 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="login-container">
|
<div class="login-container">
|
||||||
<div class="module">
|
<div class="module">
|
||||||
<img src="/loginimg.jpg" class="module_img" />
|
<img src="/loginimg.jpg" class="module_img" />
|
||||||
<div class="module_r">
|
<div class="module_r">
|
||||||
<div class="module_mian">
|
<div class="module_mian">
|
||||||
<div class="module_title">登录帐户</div>
|
<div class="module_title">登录帐户</div>
|
||||||
<div class="module_desc">输入用户名 & 登录密码</div>
|
<div class="module_desc">输入用户名 & 登录密码</div>
|
||||||
<div class="module_m">
|
<div class="module_m">
|
||||||
<div class="module_text">用户名</div>
|
<div class="module_text">用户名</div>
|
||||||
<input class="module_input" type="text" placeholder="输入用户名" v-model="Email" />
|
<input class="module_input" type="text" placeholder="输入用户名" v-model="login.username" />
|
||||||
</div>
|
|
||||||
<div class="module_m">
|
|
||||||
<div class="module_text">密码</div>
|
|
||||||
<input class="module_input" type="password" placeholder="输入密码" v-model="Password" />
|
|
||||||
</div>
|
|
||||||
<div class="module_m">
|
|
||||||
<div class="module_text">验证码</div>
|
|
||||||
<div class="module_code">
|
|
||||||
<input class="module_code_input" type="text" placeholder="输入验证码" v-model="vftcode" />
|
|
||||||
<img class="module_code_img" :src="state.captchaUrl" @click="onCode">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- <div class="module_radio"><input type="radio"/>记住密码 </div>-->
|
|
||||||
<div class="forgetpwd" @click="router.push('/register')">没有密码吗?</div>
|
|
||||||
<button class="module_button">登录</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="module_m">
|
||||||
|
<div class="module_text">密码</div>
|
||||||
|
<input class="module_input" type="password" placeholder="输入密码" v-model="login.password" />
|
||||||
|
</div>
|
||||||
|
<div class="module_m">
|
||||||
|
<div class="module_text">验证码</div>
|
||||||
|
<div class="module_code">
|
||||||
|
<input class="module_code_input" type="text" placeholder="输入验证码" v-model="login.captcha" />
|
||||||
|
<img class="module_code_img" :src="state.captchaUrl" @click="getCaptcha">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- <div class="module_radio"><input type="radio"/>记住密码 </div>-->
|
||||||
|
<!-- <div class="forgetpwd" @click="router.push('/register')">没有密码吗?</div>-->
|
||||||
|
<button class="module_button" :disabled="state.loading" @click="onLogin">登录</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
|
import { loginAdmin } from '~/api/user/adminUserApi'
|
||||||
|
import { getUuid } from '~/utils/utils'
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
captchaUrl: '',
|
captchaUrl: '',
|
||||||
loginFrom: {}
|
loginFrom: {},
|
||||||
|
loading: false,
|
||||||
})
|
})
|
||||||
const login = reactive({ username: '18796357645', password: '18796357645', captcha: '', uuid: '' })
|
const login = reactive({ username: 'admin', password: 'admin', captcha: '', uuid: '' })
|
||||||
function init() {
|
const onLogin = () => {
|
||||||
|
state.loading = true;
|
||||||
|
loginAdmin(login).then(response =>{
|
||||||
|
state.loading = false;
|
||||||
|
ElMessage.success("登录成功");
|
||||||
|
userStore().isLogin = true
|
||||||
|
userStore().adminToken = response.data.token
|
||||||
|
router.push("/")
|
||||||
|
}).catch(()=>{
|
||||||
|
state.loading = false;
|
||||||
|
onRefreshCode()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
init()
|
/**
|
||||||
|
* 获取验证码
|
||||||
|
*/
|
||||||
|
const getCaptchaUrl = () => {
|
||||||
|
login.uuid = getUuid()
|
||||||
|
login.captcha = ""
|
||||||
|
state.captchaUrl = import.meta.env.VITE_ADMIN_API_BASE_URL + `/captcha?uuid=${login.uuid}`
|
||||||
|
};
|
||||||
|
const onRefreshCode = () => {
|
||||||
|
getCaptchaUrl();
|
||||||
|
};
|
||||||
|
onMounted(()=>{
|
||||||
|
getCaptchaUrl();
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
@ -124,18 +151,11 @@ init()
|
|||||||
height: 40px;
|
height: 40px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.module_radio{
|
|
||||||
margin: 0 auto;
|
|
||||||
width: 80%;
|
|
||||||
font-size: 14px;
|
|
||||||
color: #333333;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
.module_radio input{
|
.module_radio input{
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
}
|
}
|
||||||
|
@ -19,20 +19,24 @@ export const getFrontList = () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "/",
|
"path": "/",
|
||||||
"name": "首页",
|
"name": "时间维度",
|
||||||
"icon": "House",
|
"icon": "DataAnalysis",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "/",
|
"path": "/",
|
||||||
"name": "首页",
|
"name": "地域维度",
|
||||||
"icon": "House",
|
"icon": "DataAnalysis",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "/",
|
"path": "/",
|
||||||
"name": "首页",
|
"name": "客户维度",
|
||||||
"icon": "House",
|
"icon": "DataAnalysis",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/",
|
||||||
|
"name": "销售收入维度",
|
||||||
|
"icon": "DataAnalysis",
|
||||||
},
|
},
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
return routes;
|
return routes;
|
||||||
|
Loading…
Reference in New Issue
Block a user