ADD file via upload

main
pjhmizn49 1 year ago
parent 76a0cba04c
commit 1525fb8126

@ -0,0 +1,173 @@
<template>
<div id="building">
<el-card style="background-color: rgba(255,255,255,85%)" class="login_container" shadow="always">
<el-form label-width="80px" ref="form" :model="form" :rules="rules">
<img id="im" src="@/assets/logo1.png" alt="好花">
<h3 class="login_title">欢迎登录好花网</h3>
<el-form-item label="用户名" prop="user_name" style="margin-bottom: 35px;margin-top: 60px">
<el-input v-model="form.user_name" placeholder="请输入账号"></el-input>
</el-form-item>
<el-form-item label="密码" prop="user_pwd">
<el-input type="password" v-model="form.user_pwd" placeholder="请输入密码"></el-input>
</el-form-item>
<el-form-item label="验证码" prop="identify_code">
<el-row>
<el-col :span="10">
<el-input placeholder="请输入验证码" v-model="form.identify_code"></el-input>
</el-col>
<el-col :span="13">
<div class="login-code" style="width:100%" @click="refreshCode">
<identify :identifyCode="identifyCode"></identify>
</div>
</el-col>
</el-row>
</el-form-item>
<el-form-item>
<el-button @click="submit" id="button" type="danger"> </el-button>
</el-form-item>
<el-link @click="navTo('/register')" :underline="false" style="font-weight: normal;margin-top: -15px">没有账号立即注册</el-link>
</el-form>
</el-card>
</div>
</template>
<script>
import Cookie from 'js-cookie'
import identify from "./identify.vue";
export default {
components: {
identify,
},
data(){
//
const _this = this;
const equalToIdentify = (rule, value, callback) => {
if (_this.identifyCode !== value) {
callback(new Error("验证码错误"));
} else {
callback();
}
}
return {
form:{
user_name:'',
user_pwd:'',
identify_code:''
},
identifyCodes: "1234567890abcdefjhijklinopqrsduvwxyz", //,
identifyCode: "", //
rules:{
user_name:[
{ required:true, trigger:'blur', message:'请输入用户名'}
],
user_pwd:[
{ required:true, trigger:'blur', message:'请输入密码'}
],
identify_code: [
{ required:true, trigger:'blur', message:'请输入验证码' },
{ validator: equalToIdentify, trigger: "blur" }
]
}
}
},
mounted() {
//
this.identifyCode = "";
//12
this.makeCode(this.identifyCodes, 4);
},
methods:{
//
submit(){
const _this=this
this.$refs.form.validate( (valid) => {
if(valid){
try {
axios({
method: 'post',
url: 'http://localhost:8181/user/login',
data:{
user_name:_this.form.user_name,
user_pwd:_this.form.user_pwd
}
}).then(function (response){
if (response.data.code===200) {
//
//token
const token = response.data.token
//tokencookie
Cookie.set('token',token)
//
_this.$router.push('/home')
_this.$message({message: response.data.msg, type: 'success'});
}
if (response.data.code===403) {
_this.$message.error(response.data.msg);
}
});
}catch (error)
{
_this.$message.warning('页面加载出错,请重试!')
}
}
})
},
navTo(url){
location.href = url
},
//
//
refreshCode() {
this.identifyCode = "";
this.makeCode(this.identifyCodes, 4);
},
//
makeCode(o, l) {
for (let i = 0; i < l; i++) {
//
this.identifyCode +=
this.identifyCodes[this.randomNum(0, this.identifyCodes.length)];
}
},
//
randomNum(min, max) {
return Math.floor(Math.random() * (max - min) + min);
}
}
}
</script>
<style>
#building{
background:url("@/assets/background.jpg");
width:100%;
height:100%;
position:fixed;
background-size:100% 100%;
}
.login_container{
width: 480px;
height: 450px;
border: 1px solid #eaeaea;
margin: 250px auto;
padding: 35px 50px 15px 35px;
}
.login_container #button{
margin-right:70px;
margin-top: -30px ;
width: 140px;
font-size: 16px;
font-weight: bolder;
}
.login_title{
font-size:26px;
color:#d66760;
margin-left: 30px;
margin-top: -64px;
}
#im{
height: 85px;
width: 70px;
margin-left: -300px;
margin-top: -20px;
}
</style>
Loading…
Cancel
Save