riku
2025-07-10 2cffd9c7db5c3191cf172641c800e5a328d6f3af
src/views/LoginPage.vue
@@ -1,9 +1,201 @@
<template>
  <div>LoginPage</div>
  <div class="background">
    <div class="title-content">飞羽大气环境智能走航监测系统</div>
    <div class="flexbox flex-space-around">
      <img :src="underwayPng" alt="走航监测" class="img-1" />
      <div class="input-box flexbox">
        <div class="flexbox-col align-items" style="margin: auto">
          <div class="flexbox-col input-content flex-space-between">
            <el-form
              :model="formObj"
              ref="formRef"
              :rules="rules"
              label-position="top"
            >
              <el-form-item label="用户名" prop="userName">
                <el-input
                  size="default"
                  v-model="formObj.userName"
                  placeholder="用户名"
                  style="width: 200px"
                />
              </el-form-item>
              <el-form-item label="密码" prop="password">
                <el-input
                  size="default"
                  type="password"
                  show-password
                  v-model="formObj.password"
                  placeholder="密码"
                  style="width: 200px"
                />
              </el-form-item>
            </el-form>
          </div>
          <div class="btn-login" @click="login">登录</div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import underwayPng2 from '@/assets/mipmap/underway-2.png';
import underwayPng from '@/assets/mipmap/underway.png';
import { ElMessage } from 'element-plus';
export default {
  name: 'LoginPage'
  data() {
    return {
      formObj: {},
      rules: {
        userName: [
          {
            required: true,
            message: '请输入用户名',
            trigger: 'blur'
          }
        ],
        password: [
          {
            required: true,
            message: '请输入密码',
            trigger: 'blur'
          }
        ]
      }
    };
  },
  computed: {
    underwayPng() {
      if (import.meta.env.VITE_DATA_MODE == 'jingan') {
        return underwayPng2;
      } else {
        return underwayPng;
      }
    }
  },
  methods: {
    login() {
      this.$refs.formRef.validate((valid) => {
        if (valid) {
          if (
            (this.formObj.userName == 'jingan' &&
              this.formObj.password == 'jingan123') ||
            (this.formObj.userName == 'feiyu' &&
              this.formObj.password == 'fyhb123')
          ) {
            this.$router.replace('/index/hmode');
          } else {
            ElMessage({
              message: '用户名或密码错误',
              type: 'error'
            });
          }
        }
      });
    }
  }
};
</script>
<style scoped>
.background {
  background-color: #002378;
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  min-height: 768px;
  min-width: 1366px;
}
.title-content {
  /* position: absolute; */
  width: 100%;
  height: 200px;
  padding: 3vh 0 0 0;
  /* top: 80px;
    left: 0;
    right: 0; */
  color: white;
  font-size: 1.4rem;
  display: flex;
  justify-content: center;
  background-image: url('@/assets/mipmap/title_bg.png');
  background-size: contain;
  background-repeat: no-repeat;
}
.img-1 {
  min-height: 500px;
  height: 60vh;
  /* margin-left: 6vw; */
}
.input-box {
  width: 400px;
  height: 420px;
  /* background-color: aquamarine; */
  background-image: url('@/assets/mipmap/border.png');
  background-size: 100% 100%;
  color: white;
}
.input-content {
}
.input-content .text-box {
  width: 220px;
  height: 28px;
  font-size: 12px;
  border-radius: 6px;
}
.btn-login {
  margin-top: 20px;
  border-radius: 6px;
  padding: 8px 60px;
  box-shadow: 10px 10px 10px rgba(39, 39, 39, 0.473);
  background: -moz-linear-gradient(
    left,
    rgb(109, 213, 231),
    rgb(80, 166, 202),
    rgb(65, 141, 186),
    rgb(33, 90, 154),
    rgb(13, 56, 133),
    rgb(11, 53, 131)
  );
  background: -ms-linear-gradient(
    left,
    rgb(109, 213, 231),
    rgb(80, 166, 202),
    rgb(65, 141, 186),
    rgb(33, 90, 154),
    rgb(13, 56, 133),
    rgb(11, 53, 131)
  );
  background: -o-linear-gradient(
    left,
    rgb(109, 213, 231),
    rgb(80, 166, 202),
    rgb(65, 141, 186),
    rgb(33, 90, 154),
    rgb(13, 56, 133),
    rgb(11, 53, 131)
  );
  background: -webkit-linear-gradient(
    left,
    rgb(109, 213, 231),
    rgb(80, 166, 202),
    rgb(65, 141, 186),
    rgb(33, 90, 154),
    rgb(13, 56, 133),
    rgb(11, 53, 131)
  );
  cursor: pointer;
}
</style>