| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- <template>
- <div class="login-layout">
- <div class="login-content">
- <div class="header">
- <!-- <img src="/favicon.ico" /> -->
- <p>登录多元融合</p>
- </div>
- <div class="body">
- <ui-input
- type="text"
- placeholder="请输入账号"
- v-model="username"
- style="width: 100%"
- />
- <br />
- <ui-input
- :type="showPwd ? 'text' : 'password'"
- placeholder="请输入密码"
- v-model="password"
- style="width: 100%; margin-top: 20px"
- >
- <template #icon>
- <ui-icon
- style="cursor: pointer"
- class="ctrl-pwd"
- :type="showPwd ? 'eye-s' : 'eye-n'"
- @click="showPwd = !showPwd"
- ></ui-icon>
- </template>
- </ui-input>
- <br />
- <div class="code-row">
- <ui-input
- class="code-input"
- type="text"
- placeholder="请输入验证码"
- v-model="code"
- />
- <img :src="codeImg" class="code-img" @click="refer" />
- </div>
- <br />
- <ui-input
- type="checkbox"
- @click.stop
- label="记住密码"
- style="margin-top: 20px"
- :modelValue="mark"
- @update:modelValue="(select: any) => mark = select"
- />
- </div>
- <div class="bottom">
- <ui-button type="submit" @click="login(username, password, code)">登录</ui-button>
- </div>
- </div>
- </div>
- </template>
- <script lang="ts" setup>
- import { ref, computed } from "vue";
- import { encodePwd } from "@/utils";
- import GAxios from "axios";
- import { setToken } from "@/api";
- import { Message } from "bill/expose-common";
- import { params } from "@/env";
- import { GET_SETTING, getCode } from "@/api/constant";
- import { currentLayout, RoutesName } from "@/router";
- const username = ref(localStorage.getItem("fuse-username") || "");
- const password = ref(localStorage.getItem("fuse-password") || "");
- const code = ref("");
- const mark = ref(!!localStorage.getItem("fuse-mark"));
- const showPwd = ref(false);
- const guid = () => {
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
- let r = (Math.random() * 16) | 0,
- v = c == "x" ? r : (r & 0x3) | 0x8;
- return v.toString(16);
- });
- };
- // 图片验证码
- let baseURL = "https://test-mix3d.4dkankan.com";
- const imgKey = ref(guid());
- const refer = () => (imgKey.value = guid());
- if (window.location.href.indexOf("localhost") !== -1) {
- baseURL = "https://test-mix3d.4dkankan.com";
- } else if (window.location.href.indexOf("test") !== -1) {
- baseURL = "https://test-mix3d.4dkankan.com";
- } else {
- baseURL = "https://mix3d.4dkankan.com";
- }
- const codeImg = computed(() => baseURL + getCode + "?key=" + imgKey.value);
- const getDeptId = () => {
- const fromRoute = params.fromRoute;
- if (fromRoute === "fire") return "1";
- if (fromRoute === "cjzfire") return "DEP000011734134901809483776";
- if (fromRoute === "xmfire") return "3";
- if (fromRoute === "criminal") return "2";
- return "";
- };
- const login = (username: string, password: string, code: string) => {
- if (!username) {
- return Message.error("账号不能为空");
- }
- if (!password) {
- return Message.error("密码不能为空");
- }
- if (!code && !import.meta.env.DEV) {
- return Message.error("验证码不能为空");
- }
- const isView = [RoutesName.show, RoutesName.signModel, RoutesName.error].includes(
- currentLayout.value!
- );
- const type = isView ? "view" : "edit";
- const headers = { fusionId: params.caseId, "page-type": type };
- GAxios.post(
- "/fusion/fdLogin",
- {
- password: encodePwd(password),
- userName: username,
- phoneNum: username,
- code: code,
- deptId: getDeptId(),
- },
- { headers }
- ).then(async (res) => {
- if (res.data.code !== 0) {
- return Message.error(res.data.message);
- }
- const res1 = await GAxios.get(GET_SETTING, {
- params: { fusionId: params.caseId },
- headers: { ...headers, token: res.data.data.token },
- });
- if (res1.data.code === 40111) {
- return Message.error("您没有权限,请联系管理员开通");
- }
- setToken(res.data.data.token);
- setTimeout(() => {
- const p = new URLSearchParams(location.search);
- p.delete("token");
- location.search = "?" + p.toString();
- setTimeout(() => location.reload(), 100);
- }, 100);
- if (mark.value) {
- localStorage.setItem("fuse-username", username);
- localStorage.setItem("fuse-password", password);
- localStorage.setItem("fuse-mark", "1");
- } else {
- localStorage.removeItem("fuse-username");
- localStorage.removeItem("fuse-password");
- localStorage.removeItem("fuse-mark");
- }
- });
- };
- // if (import.meta.env.DEV) {
- // login("super-admin", "Aa123456", "");
- // }
- </script>
- <style lang="scss" scoped>
- .login-layout {
- position: fixed;
- inset: 0;
- z-index: 99;
- background: url("/images/login-backimage.png") no-repeat center center;
- background-size: cover;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .login-content {
- width: 400px;
- .header {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- margin-bottom: 64px;
- img {
- width: 80px;
- height: 80px;
- margin-bottom: 10px;
- }
- p {
- font-weight: bold;
- font-size: 32px;
- color: #000000;
- line-height: 48px;
- letter-spacing: 12px;
- text-align: center;
- font-style: normal;
- text-transform: none;
- }
- }
- .body {
- margin-bottom: 48px;
- }
- }
- </style>
- <style lang="scss" scoped>
- .login-content {
- .ui-input,
- .ui-button {
- --colors-color: #d9d9d9;
- --base-border-color: #d9d9d9;
- --colors-content-color: #000000;
- --colors-primary-base: #d9d9d9;
- --colors-normal-back: #ffffff;
- --colors-primary-base: #0960bd;
- --color-main-normal: #0960bd;
- }
- .ui-button {
- color: #fff !important;
- border: 1px solid var(--color-main-normal) !important;
- background: var(--color-main-normal) !important;
- }
- .code-row {
- display: flex;
- align-items: center;
- gap: 12px;
- margin-top: 20px;
- }
- .code-input {
- flex: 1;
- }
- .code-img {
- width: 120px;
- height: 40px;
- cursor: pointer;
- user-select: none;
- flex: none;
- }
- }
- </style>
|