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.

63 lines
1.5 KiB

3 years ago
<template>
<div class="page-container">
<div class="page-outer">
3 years ago
<el-form>
<el-form-item label="账号">
3 years ago
<el-input v-model="form.name" placeholder="账号" />
3 years ago
</el-form-item>
<el-form-item label="密码">
3 years ago
<el-input type="password" v-model="form.password" placeholder="密码" />
3 years ago
</el-form-item>
<el-form-item>
<el-button type="primary" style="width: 100%" @click="submit"
> </el-button
3 years ago
>
3 years ago
</el-form-item>
</el-form>
3 years ago
</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({
3 years ago
name: "",
password: "",
3 years ago
});
return {
form,
proxy,
store
};
},
methods: {
submit() {
3 years ago
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('/');
});
3 years ago
},
},
});
</script>
<style lang="less" scoped>
.page-container {
position: relative;
width: 100%;
height: 100%;
.page-outer {
width: 400px;
3 years ago
transform: translate(170%, 280%);
3 years ago
}
}
</style>