You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

149 lines
4.5 KiB

3 years ago
<template>
<div id="main" class="container">
<div class="row">
3 years ago
<div class="col">
3 years ago
<div class="card" id="card1">
<h2 class="text-center">资产系统后台管理界面</h2>
<div class="card-body d-flex justify-content-center">
<form>
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label">Name</label>
<input type="text" class="form-control" required v-model="username" id="exampleInputEmail1"
placeholder="请输入用户名">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Password</label>
<input type="password" required v-model="password" class="form-control"
id="exampleInputPassword1" placeholder="请输入密码">
</div>
3 years ago
<div class="image">
<img :src="this.codeImage" @click="getCode" style="width: 130px; height: 39px;">
<input type="text" id="imginput" style="width: 120px;" class="form-control"
placeholder="输入验证码" />
</div>
3 years ago
<div class="mb-3 form-check">
<input type="checkbox" class="form-check-input" id="exampleCheck1">
<label class="form-check-label" for="exampleCheck1">记住密码</label>
</div>
<button type="submit" class="btn" @click.prevent="login"
style="background-color: dodgerblue; color: white;">登录</button>
<button type="submit" class="btn" @click="toRegister"
style="background-color: dodgerblue; color: white;">注册</button>
</form>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
3 years ago
import { createDOMCompilerError } from '@vue/compiler-dom'
import { createApp } from 'vue'
3 years ago
import request from "../utils/axios/request"
3 years ago
import qs from "qs"
3 years ago
export default {
data() {
return {
username: '',
3 years ago
password: '',
codeImage: ''
3 years ago
}
},
3 years ago
created() {
var img = this.$data.codeImage;
request.get('/captcha', { responseType: 'blob' }).then((response) => {
console.log(response.data)
this.codeImage = window.URL.createObjectURL(response.data)
console.log(this.codeImage)
})
},
3 years ago
methods: {
login() {
3 years ago
request.post('/login',
qs.stringify({
name: this.$data.username,
password: this.$data.password
}), {
headers: {
'Content-Type': 'application/json'
}
}).then(resp => {
console.log(resp)
if (resp.status == 200) {
this.$router.push({
3 years ago
path: '/index',
name: 'access'
3 years ago
})
}
}).catch(error => console.log(error))
},
getCode() {
request.get('/captcha', { responseType: 'blob' }).then((response) => {
console.log(response.data)
this.codeImage = window.URL.createObjectURL(response.data)
console.log(this.codeImage)
3 years ago
})
},
toRegister() {
// 跳转到注册页面
this.$router.push('/register')
}
}
}
</script>
3 years ago
<style scoped>
@media (min-width: 768px) {
.container-fluid {
width: 750px;
}
}
@media (min-width: 992px) {
.container-fluid {
width: 970px;
}
}
@media (min-width: 1200px) {
.container-fluid {
width: 100vw;
}
}
#card1 {
margin: 50% 0;
border-radius: 3%;
background-color: rgba(255, 255, 255, 0.8);
box-shadow: none;
border: none;
}
.btn:focus,
.btn:active {
background-color: blue;
}
.btn {
margin: 10px;
width: 100px !important;
}
#reg {
margin-left: 24%;
}
/* 验证码样式 */
.image {
margin: 2px 0;
display: flex;
}
#imginput {
margin: 0 12px;
}
</style>