login.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <div class="login-layout">
  3. <div class="login-content">
  4. <div class="header">
  5. <img src="/favicon.ico" />
  6. <p>登录多元融合</p>
  7. </div>
  8. <div class="body">
  9. <ui-input
  10. type="text"
  11. placeholder="请输入账号"
  12. v-model="username"
  13. style="width: 100%"
  14. />
  15. <br />
  16. <ui-input
  17. :type="showPwd ? 'text' : 'password'"
  18. placeholder="请输入密码"
  19. v-model="password"
  20. style="width: 100%; margin-top: 20px"
  21. >
  22. <template #icon>
  23. <ui-icon
  24. style="cursor: pointer"
  25. class="ctrl-pwd"
  26. :type="showPwd ? 'eye-s' : 'eye-n'"
  27. @click="showPwd = !showPwd"
  28. ></ui-icon>
  29. </template>
  30. </ui-input>
  31. <br />
  32. <ui-input
  33. type="checkbox"
  34. @click.stop
  35. label="记住密码"
  36. style="margin-top: 20px"
  37. :modelValue="mark"
  38. @update:modelValue="(select: any) => mark = select"
  39. />
  40. </div>
  41. <div class="bottom">
  42. <ui-button type="submit" @click="login(username, password)">登录</ui-button>
  43. </div>
  44. </div>
  45. </div>
  46. </template>
  47. <script lang="ts" setup>
  48. import { ref } from "vue";
  49. import { encodePwd } from "@/utils";
  50. import GAxios from "axios";
  51. import { fetchSetting, setToken } from "@/api";
  52. import { Message } from "bill/expose-common";
  53. import { params } from "@/env";
  54. import { GET_SETTING, UPDATE_SETTING } from "@/api/constant";
  55. import { currentLayout, RoutesName } from "@/router";
  56. const username = ref(localStorage.getItem("fuse-username") || "");
  57. const password = ref(localStorage.getItem("fuse-password") || "");
  58. const mark = ref(!!localStorage.getItem("fuse-mark"));
  59. const showPwd = ref(false);
  60. const login = (username: string, password: string) => {
  61. if (!username) {
  62. return Message.error("账号不能为空");
  63. }
  64. if (!password) {
  65. return Message.error("密码不能为空");
  66. }
  67. const isView = [RoutesName.show, RoutesName.signModel, RoutesName.error].includes(
  68. currentLayout.value!
  69. );
  70. const type = isView ? "view" : "edit";
  71. const headers = { fusionId: params.caseId, "page-type": type };
  72. GAxios.post(
  73. "/service/manage/login",
  74. {
  75. password: encodePwd(password),
  76. userName: username,
  77. username: username,
  78. },
  79. { headers }
  80. ).then(async (res) => {
  81. if (res.data.code !== 0) {
  82. return Message.error(res.data.message);
  83. }
  84. const res1 = await GAxios.get(GET_SETTING, {
  85. params: { fusionId: params.caseId },
  86. headers: { ...headers, token: res.data.data.token },
  87. });
  88. if (res1.data.code === 40111) {
  89. return Message.error("您没有权限,请联系管理员开通");
  90. }
  91. setToken(res.data.data.token);
  92. setTimeout(() => {
  93. const p = new URLSearchParams(location.search);
  94. p.delete("token");
  95. location.search = "?" + p.toString();
  96. setTimeout(() => location.reload(), 100);
  97. }, 100);
  98. if (mark.value) {
  99. localStorage.setItem("fuse-username", username);
  100. localStorage.setItem("fuse-password", password);
  101. localStorage.setItem("fuse-mark", "1");
  102. } else {
  103. localStorage.removeItem("fuse-username");
  104. localStorage.removeItem("fuse-password");
  105. localStorage.removeItem("fuse-mark");
  106. }
  107. });
  108. };
  109. if (import.meta.env.DEV) {
  110. // login("super-admin", "Aa123456");
  111. }
  112. </script>
  113. <style lang="scss" scoped>
  114. .login-layout {
  115. position: fixed;
  116. inset: 0;
  117. z-index: 99;
  118. background: url("/images/login-backimage.png") no-repeat center center;
  119. background-size: cover;
  120. display: flex;
  121. align-items: center;
  122. justify-content: center;
  123. }
  124. .login-content {
  125. width: 400px;
  126. .header {
  127. display: flex;
  128. flex-direction: column;
  129. align-items: center;
  130. justify-content: center;
  131. margin-bottom: 64px;
  132. img {
  133. width: 80px;
  134. height: 80px;
  135. margin-bottom: 10px;
  136. }
  137. p {
  138. font-weight: bold;
  139. font-size: 32px;
  140. color: #000000;
  141. line-height: 48px;
  142. letter-spacing: 12px;
  143. text-align: center;
  144. font-style: normal;
  145. text-transform: none;
  146. }
  147. }
  148. .body {
  149. margin-bottom: 48px;
  150. }
  151. }
  152. </style>
  153. <style lang="scss" scoped>
  154. .login-content {
  155. .ui-input,
  156. .ui-button {
  157. --colors-color: #d9d9d9;
  158. --base-border-color: #d9d9d9;
  159. --colors-content-color: #000000;
  160. --colors-primary-base: #d9d9d9;
  161. --colors-normal-back: #ffffff;
  162. --colors-primary-base: #0960bd;
  163. --color-main-normal: #0960bd;
  164. }
  165. .ui-button {
  166. color: #fff !important;
  167. border: 1px solid var(--color-main-normal) !important;
  168. background: var(--color-main-normal) !important;
  169. }
  170. }
  171. </style>