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.
|
|
|
<template>
|
|
|
|
<div class="page-container">
|
|
|
|
<div class="page-outer">
|
|
|
|
<el-form>
|
|
|
|
<el-form-item label="账号">
|
|
|
|
<el-input v-model="form.name" placeholder="账号" />
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="密码">
|
|
|
|
<el-input type="password" v-model="form.password" placeholder="密码" />
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item>
|
|
|
|
<el-button type="primary" style="width: 100%" @click="submit"
|
|
|
|
>登 录</el-button
|
|
|
|
>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { useStore } from "vuex";
|
|
|
|
import { defineComponent, reactive, getCurrentInstance } from "vue";
|
|
|
|
export default defineComponent({
|
|
|
|
name: 'v-login',
|
|
|
|
setup() {
|
|
|
|
const { proxy } = getCurrentInstance();
|
|
|
|
const store = useStore();
|
|
|
|
const form = reactive({
|
|
|
|
name: "",
|
|
|
|
password: "",
|
|
|
|
});
|
|
|
|
return {
|
|
|
|
form,
|
|
|
|
proxy,
|
|
|
|
store
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
submit() {
|
|
|
|
this.proxy.$post("/admin/login", this.form).then((res) => {
|
|
|
|
const data = res.data;
|
|
|
|
this.store.commit("setToken", data.token);
|
|
|
|
this.store.commit("setUserInfo", data);
|
|
|
|
this.$message.success("登录成功");
|
|
|
|
this.$router.push('/');
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
|
.page-container {
|
|
|
|
position: relative;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
.page-outer {
|
|
|
|
width: 400px;
|
|
|
|
transform: translate(170%, 280%);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|