zhongrj
2025-03-28 4ff3eee77b41466d08117970970d01be6e48ffe1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<template>
  <div class="login-warp">
    <div class="top-img-bg">
      <p class="title">低空无人机监测网移动应用</p>
    </div>
    <div class="user-password-box">
      <div class="username">
        <div>账号:</div>
        <el-input v-model="formState.username" placeholder="请输入登录账号"></el-input>
      </div>
      <div class="password">
        <div>密码:</div>
        <el-input type="password" v-model="formState.password" placeholder="请输入密码"></el-input>
      </div>
      <div>
        <el-button class="loginto" type="primary" :disabled="loginBtnDisabled" @click="onSubmit">登录</el-button>
      </div>
    </div>
  </div>
</template>
<script lang="ts" setup>
import { ref, onMounted, reactive, computed, UnwrapRef } from 'vue';
// import { getWorkSpaceInfo,  } from '@/api/drone/index';
// import { getSysName, loginByUsername } from '@/api/user';
import { LoginBody } from '@/api/manage'
import { ERouterName, EUserType } from '@/types'
import { getRoot } from '../../root'
import { useMyStore } from '@/store'
 
const root = getRoot()
 
const store = useMyStore()
 
const formState: UnwrapRef<LoginBody> = reactive({
    //租户ID
    tenantId: '000000',
    //部门ID
    deptId: '',
    //角色ID
    roleId: '',
    //用户名
    username: '',
    //密码
    password: '',
    //账号类型
    type: 'account',
    //验证码的值
    code: '',
    //验证码的索引
    key: '',
    //预加载白色背景
    image:
      'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
    flag: EUserType.Web,
  })
 
onMounted(() => {
  // 暂时没用到
  // getSysName(1).then(res => {
  //   console.log(res, '低调点')
  // })
})
 
const loginBtnDisabled = computed(() => {
  return !formState.username || !formState.password
})
 
const onSubmit = async () => {
  store
    .dispatch('LoginByUsername', formState)
    .then((res) => {
      root.$router.push(ERouterName.DRONEPILOTLIST)
    })
    .catch(() => {
    })
}
 
</script>
<style lang="scss" scoped>
.login-warp 
{
  width: 100%;
  height: 100vh;
  .top-img-bg {
    width: 100%;
    height: calc(100vh - 30%);
    background: url('@/assets/images/dj-bg.jpeg');
    background-size: 100% 100%;
    .title {
      text-align: center;
      font-size: 20px;
      color: #00afe9;
      padding-top: 10%;
    }
  }
  .user-password-box {
    height: calc(100vh - 70%);
    padding: 4% 6% 1% 10%;
 
    .username {
      margin-bottom: 2%;
    }
 
    ::v-deep(.el-input__wrapper) {
      box-shadow: none;
      border-radius: initial;
      border-bottom: 1px solid #eee;
      padding: 0;
    }
    .loginto {
      width: 100%;
      margin: 6% 0;
    }
  }
}
</style>