parent
54d57a8fc7
commit
aa4dccf074
@ -0,0 +1,118 @@
|
||||
<template>
|
||||
<div id="building">
|
||||
<el-card style="background-color: rgba(255,255,255,0.8)" class="login_container" shadow="always">
|
||||
<el-form label-width="80px" :model="form" :rules="rules">
|
||||
<img id="im" src="@/assets/logo.png" alt="好花">
|
||||
<h3 class="login_title">后台管理系统</h3>
|
||||
<el-form-item label="用户名" prop="staff_name" style="margin-bottom: 35px;margin-top: 60px">
|
||||
<el-input v-model="form.staff_name" placeholder="请输入账号"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="密码" prop="staff_pwd">
|
||||
<el-input type="password" v-model="form.staff_pwd" placeholder="请输入密码"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="submit" id="button" type="danger">登 录</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import axios from "axios";
|
||||
import Cookie from 'js-cookie'
|
||||
export default {
|
||||
data(){
|
||||
return {
|
||||
form:{
|
||||
staff_name:'',
|
||||
staff_pwd:''
|
||||
},
|
||||
rules:{
|
||||
staff_name:[
|
||||
{ required:true, trigger:'blur', message:'请输入用户名'}
|
||||
],
|
||||
staff_pwd:[
|
||||
{ required:true, trigger:'blur', message:'请输入密码'}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
methods:{
|
||||
//登录
|
||||
submit(){
|
||||
const _this=this
|
||||
try {
|
||||
axios({
|
||||
method: 'post',
|
||||
url: 'http://localhost:8181/staff/login',
|
||||
data:{
|
||||
staff_name:_this.form.staff_name,
|
||||
staff_pwd:_this.form.staff_pwd
|
||||
}
|
||||
}).then(function (response){
|
||||
if (response.data.code===200) {
|
||||
//登录成功
|
||||
//token信息
|
||||
const token = response.data.token
|
||||
//将token信息存入cookie用于不同页面的通信
|
||||
Cookie.set('token',token)
|
||||
//获取菜单数据,存入store中
|
||||
_this.$store.commit('setMenu',response.data.data.menu)
|
||||
//注册路由
|
||||
_this.$store.commit('addMenu',_this.$router)
|
||||
|
||||
const menu = [
|
||||
{}
|
||||
];
|
||||
|
||||
//跳转到首页
|
||||
_this.$router.push('/statistic')
|
||||
_this.$message({message: response.data.msg, type: 'success'});
|
||||
}
|
||||
if (response.data.code===403) {
|
||||
_this.$message.error(response.data.msg);
|
||||
}
|
||||
});
|
||||
}catch (error)
|
||||
{
|
||||
_this.$message.warning('页面加载出错,请重试!')
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
#building{
|
||||
background:url("@/assets/background.png");
|
||||
width:100%;
|
||||
height:100%;
|
||||
position:fixed;
|
||||
background-size:100% 100%;
|
||||
}
|
||||
.login_container{
|
||||
width: 480px;
|
||||
height: 380px;
|
||||
border: 1px solid #eaeaea;
|
||||
margin: 300px auto;
|
||||
padding: 35px 50px 15px 35px;
|
||||
}
|
||||
#button{
|
||||
margin-right:70px;
|
||||
margin-top: 28px ;
|
||||
width: 140px;
|
||||
font-size: 16px;
|
||||
font-weight: bolder;
|
||||
}
|
||||
.login_title{
|
||||
font-size:24px;
|
||||
color:#d66760;
|
||||
margin-left: 180px;
|
||||
margin-top: -64px;
|
||||
}
|
||||
#im{
|
||||
height: 80px;width: 190px;margin-left: -180px
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in new issue