|
|
@@ -0,0 +1,181 @@
|
|
|
+<script setup lang="ts">
|
|
|
+import { ElMessage } from 'element-plus'
|
|
|
+import { useRouter,useRoute } from 'vue-router'
|
|
|
+const route = useRoute();
|
|
|
+const router = useRouter();
|
|
|
+import { ref,onMounted,reactive } from 'vue'
|
|
|
+import {Lock,User } from "@element-plus/icons-vue";
|
|
|
+import type { ComponentSize, FormInstance } from 'element-plus'
|
|
|
+import {login} from '../../request/api.js'
|
|
|
+interface RuleForm {
|
|
|
+ username: string
|
|
|
+ password: string
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+const ruleFormRef = ref<FormInstance>()
|
|
|
+const ruleForm = reactive<RuleForm>({
|
|
|
+ username: 'admin',
|
|
|
+ password: 'g350488F'
|
|
|
+})
|
|
|
+
|
|
|
+let loading=ref(false)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+const submitForm = async (formEl: FormInstance | undefined) => {
|
|
|
+ loading.value=true
|
|
|
+ login({
|
|
|
+ "clientId": "e5cd7e4891bf95d1d19206ce24a7b32e",
|
|
|
+ "grantType": "password",
|
|
|
+ "username":ruleForm.username,
|
|
|
+ "password":ruleForm.password
|
|
|
+}).then((res: any)=>{
|
|
|
+ if(res.msg=='操作成功'){
|
|
|
+ ElMessage({
|
|
|
+ message: '登陆成功',
|
|
|
+ type: 'success',
|
|
|
+ duration: 3 * 1000
|
|
|
+ });
|
|
|
+ localStorage.setItem('access_token',res.data.access_token)
|
|
|
+ loading.value=false
|
|
|
+ router.push({
|
|
|
+ path:'/'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }).catch((err: any)=>{
|
|
|
+ loading.value=false
|
|
|
+ console.log(err)
|
|
|
+ })
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+onMounted(()=>{
|
|
|
+
|
|
|
+})
|
|
|
+
|
|
|
+
|
|
|
+</script>
|
|
|
+
|
|
|
+<template>
|
|
|
+ <div class="login-wrap">
|
|
|
+
|
|
|
+ <div class="ms-login">
|
|
|
+ <div class="right">
|
|
|
+ <div class="ms-title">车辆调度管理系统</div>
|
|
|
+ <div style="padding-bottom:20px">
|
|
|
+ 请登录以继续使用
|
|
|
+ </div>
|
|
|
+ <el-form
|
|
|
+ label-position="top"
|
|
|
+ :model="ruleForm"
|
|
|
+ label-width="auto"
|
|
|
+ class="form-wrap"
|
|
|
+
|
|
|
+ status-icon
|
|
|
+ >
|
|
|
+ <el-form-item label="账号" prop="name">
|
|
|
+ <el-input :prefix-icon="User" v-model="ruleForm.username" />
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="密码" prop="name">
|
|
|
+ <el-input type="password" :prefix-icon="Lock" show-password v-model="ruleForm.password" />
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <el-form-item label="" prop="name">
|
|
|
+ <el-checkbox v-model="checked1" label="记住我" size="large" />
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item>
|
|
|
+ <el-button :loading="loading" style="width:100%;background:#2563eb;height:40px" type="primary" @click="submitForm">
|
|
|
+ {{ loading?'登录中':'登录' }}
|
|
|
+ </el-button>
|
|
|
+
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+
|
|
|
+ <div style="padding:10px 0 20px 0;">
|
|
|
+ <span style="margin-right:5px">首次使用吗?</span>
|
|
|
+ <span style="color:#326cec">联系管理员</span>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.form-wrap{
|
|
|
+ width:80%;
|
|
|
+ margin:0 auto;
|
|
|
+ border-bottom:1px solid rgba(0,0,0,0.1)
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+.bold-title{
|
|
|
+ text-align:center;
|
|
|
+ font-size:32px;
|
|
|
+ font-weight:bold;
|
|
|
+ color:#fff;
|
|
|
+ position:absolute;
|
|
|
+ top:20%;
|
|
|
+ left:0;
|
|
|
+ right:0;
|
|
|
+}
|
|
|
+
|
|
|
+.login-wrap {
|
|
|
+ text-align: center;
|
|
|
+ position: relative;
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ background:#4e6ef2;
|
|
|
+ background-size: 100% 100%;
|
|
|
+}
|
|
|
+.ms-title {
|
|
|
+ width: 100%;
|
|
|
+ padding:40px 0 10px 0;
|
|
|
+ text-align: center;
|
|
|
+ font-size: 26px;
|
|
|
+ font-weight: 700;
|
|
|
+
|
|
|
+}
|
|
|
+.ms-login {
|
|
|
+ position: absolute;
|
|
|
+ left: 50%;
|
|
|
+ z-index:10000;
|
|
|
+ top: 50%;
|
|
|
+ width: 520px;
|
|
|
+ margin: -190px 0 0 -260px;
|
|
|
+ border-radius: 5px;
|
|
|
+ background: rgba(255, 255, 255, 0.9);
|
|
|
+ overflow: hidden;
|
|
|
+ border-bottom:1px solid #edf0f2;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+.ms-content {
|
|
|
+ padding: 30px 30px;
|
|
|
+}
|
|
|
+.login-btn {
|
|
|
+ text-align: center;
|
|
|
+}
|
|
|
+.login-btn button {
|
|
|
+ width: 100%;
|
|
|
+ height: 36px;
|
|
|
+ margin-bottom: 10px;
|
|
|
+}
|
|
|
+.login-tips {
|
|
|
+ padding-left:20px;
|
|
|
+ font-size: 12px;
|
|
|
+ line-height: 30px;
|
|
|
+ color: #333;
|
|
|
+}
|
|
|
+</style>
|