玛尔挡水温监测系统
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. <template>
  2. <div class="login">
  3. <!-- 顶部标题区域 -->
  4. <div class="login-header">
  5. <h1 class="main-title">{{ title }}</h1>
  6. </div>
  7. <!-- 登录表单区域 -->
  8. <div class="login-container">
  9. <el-form ref="loginRef" :model="loginForm" :rules="loginRules" class="login-form">
  10. <h3 class="form-title">用户登录</h3>
  11. <el-form-item prop="username">
  12. <el-input v-model="loginForm.username" type="text" size="large" auto-complete="off" placeholder="请输入用户名">
  13. <template #prefix><svg-icon icon-class="user" class="el-input__icon input-icon" /></template>
  14. </el-input>
  15. </el-form-item>
  16. <el-form-item prop="password">
  17. <el-input v-model="loginForm.password" type="password" size="large" auto-complete="off" placeholder="请输入密码" @keyup.enter="handleLogin">
  18. <template #prefix><svg-icon icon-class="password" class="el-input__icon input-icon" /></template>
  19. </el-input>
  20. </el-form-item>
  21. <el-form-item v-if="captchaEnabled" prop="code">
  22. <el-input v-model="loginForm.code" size="large" auto-complete="off" placeholder="验证码" style="width: 63%" @keyup.enter="handleLogin">
  23. <template #prefix><svg-icon icon-class="validCode" class="el-input__icon input-icon" /></template>
  24. </el-input>
  25. <div class="login-code">
  26. <img :src="codeUrl" class="login-code-img" @click="getCode">
  27. </div>
  28. </el-form-item>
  29. <el-checkbox v-model="loginForm.rememberMe" style="margin:0px 0px 25px 0px;">记住密码</el-checkbox>
  30. <el-form-item style="width:100%;">
  31. <el-button type="primary" style="width:100%;" :loading="loading" size="large" @click.prevent="handleLogin">
  32. <span v-if="!loading">进入监测系统</span>
  33. <span v-else>登录中...</span>
  34. </el-button>
  35. <!-- <div v-if="register" class="register-link">
  36. <router-link class="link-type" :to="'/register'">立即注册</router-link>
  37. </div> -->
  38. </el-form-item>
  39. </el-form>
  40. </div>
  41. <!-- 底部信息 -->
  42. <div class="el-login-footer">
  43. <span>Copyright © 2025 四川中水成勘院测绘工程有限责任公司 All Rights Reserved.</span>
  44. </div>
  45. </div>
  46. </template>
  47. <script setup>
  48. import { getCaptcha } from '@/api/login'
  49. import Cookies from 'js-cookie'
  50. import { encrypt, decrypt } from '@/utils/jsencrypt'
  51. import { title } from '@/store/modules/settings'
  52. import useUserStore from '@/store/modules/user'
  53. const userStore = useUserStore()
  54. const router = useRouter()
  55. const { proxy } = getCurrentInstance()
  56. const loginForm = ref({
  57. username: '',
  58. password: '',
  59. rememberMe: false,
  60. code: '',
  61. uuid: ''
  62. })
  63. const loginRules = {
  64. username: [
  65. { required: true, message: '请输入您的账号', trigger: 'blur' }
  66. ],
  67. password: [
  68. { required: true, message: '请输入您的密码', trigger: 'blur' }
  69. ],
  70. code: [
  71. { required: true, message: '请输入验证码', trigger: 'change' }
  72. ]
  73. }
  74. const codeUrl = ref('')
  75. const loading = ref(false)
  76. // 验证码开关
  77. const captchaEnabled = ref(true)
  78. // 注册开关
  79. const register = ref(false)
  80. const redirect = ref(undefined)
  81. function handleLogin() {
  82. proxy.$refs.loginRef.validate(valid => {
  83. if (valid) {
  84. loading.value = true
  85. // 勾选了需要记住密码设置在 cookie 中设置记住用户名和密码
  86. if (loginForm.value.rememberMe) {
  87. Cookies.set('username', loginForm.value.username, { expires: 30 })
  88. Cookies.set('password', encrypt(loginForm.value.password), { expires: 30 })
  89. Cookies.set('rememberMe', loginForm.value.rememberMe, { expires: 30 })
  90. } else {
  91. // 否则移除
  92. Cookies.remove('username')
  93. Cookies.remove('password')
  94. Cookies.remove('rememberMe')
  95. }
  96. // 调用action的登录方法
  97. userStore.login(loginForm.value).then(() => {
  98. router.push({ path: redirect.value || '/index' })
  99. }).catch(() => {
  100. loading.value = false
  101. // 重新获取验证码
  102. if (captchaEnabled.value) {
  103. getCode()
  104. }
  105. })
  106. }
  107. })
  108. }
  109. function getCode() {
  110. getCaptcha().then(res => {
  111. captchaEnabled.value = res.captchaEnabled === undefined ? true : res.captchaEnabled
  112. if (captchaEnabled.value) {
  113. codeUrl.value = 'data:image/gif;base64,' + res.img
  114. loginForm.value.uuid = res.uuid
  115. }
  116. register.value = res.register === undefined ? true : res.register
  117. })
  118. }
  119. function getCookie() {
  120. const username = Cookies.get('username')
  121. const password = Cookies.get('password')
  122. const rememberMe = Cookies.get('rememberMe')
  123. loginForm.value = {
  124. username: username === undefined ? loginForm.value.username : username,
  125. password: password === undefined ? loginForm.value.password : decrypt(password),
  126. rememberMe: rememberMe === undefined ? false : Boolean(rememberMe)
  127. }
  128. }
  129. getCode()
  130. getCookie()
  131. </script>
  132. <style lang='scss' scoped>
  133. .login {
  134. display: flex;
  135. flex-direction: column;
  136. justify-content: top;
  137. align-items: center;
  138. height: 100%;
  139. background-image: url('@/assets/images/loginBg.jpeg');
  140. background-size: cover;
  141. background-position: center;
  142. position: relative;
  143. }
  144. .login-header {
  145. text-align: center;
  146. left: 70%;
  147. top: 8%;
  148. position: absolute;
  149. z-index: 2;
  150. .main-title {
  151. font-size: 26px;
  152. font-weight: 700;
  153. color: #ffffff;
  154. margin-bottom: 10px;
  155. text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  156. letter-spacing: 2px;
  157. }
  158. .sub-title {
  159. font-size: 18px;
  160. color: rgba(255, 255, 255, 0.9);
  161. font-weight: 300;
  162. letter-spacing: 1px;
  163. text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  164. }
  165. }
  166. .login-container {
  167. background: rgba(255, 255, 255, 0.5);
  168. backdrop-filter: blur(20px);
  169. -webkit-backdrop-filter: blur(20px);
  170. border-radius: 16px;
  171. padding: 40px;
  172. box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
  173. width: 500px;
  174. position: absolute;
  175. bottom: 30%;
  176. left: 70%;
  177. z-index: 2;
  178. border: 1px solid rgba(255, 255, 255, 0.3);
  179. transition: all 0.3s ease;
  180. .login-form {
  181. .form-title {
  182. text-align: center;
  183. margin-bottom: 30px;
  184. font-size: 26px;
  185. font-weight: 600;
  186. color: #2c3e50;
  187. position: relative;
  188. &::after {
  189. content: '';
  190. position: absolute;
  191. bottom: -10px;
  192. left: 50%;
  193. transform: translateX(-50%);
  194. width: 50px;
  195. height: 3px;
  196. background: linear-gradient(135deg, #409eff, #36a3f7);
  197. border-radius: 2px;
  198. }
  199. }
  200. .el-input {
  201. height: 48px;
  202. margin-bottom: 8px;
  203. input {
  204. height: 48px;
  205. border-radius: 8px;
  206. border: 2px solid #e8eaec;
  207. transition: all 0.3s ease;
  208. font-size: 14px;
  209. &:focus {
  210. border-color: #409eff;
  211. box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.1);
  212. }
  213. &::placeholder {
  214. color: #a0a0a0;
  215. }
  216. }
  217. }
  218. .input-icon {
  219. height: 46px;
  220. width: 18px;
  221. margin-left: 0px;
  222. color: #409eff;
  223. }
  224. .el-button {
  225. border-radius: 8px;
  226. height: 48px;
  227. font-size: 16px;
  228. font-weight: 600;
  229. background: linear-gradient(135deg, #409eff 0%, #36a3f7 100%);
  230. border: none;
  231. transition: all 0.3s ease;
  232. &:hover {
  233. transform: translateY(-1px);
  234. box-shadow: 0 6px 20px rgba(64, 158, 255, 0.3);
  235. }
  236. &:active {
  237. transform: translateY(0);
  238. }
  239. }
  240. .el-checkbox {
  241. .el-checkbox__label {
  242. color: #606266;
  243. font-size: 14px;
  244. }
  245. .el-checkbox__input.is-checked .el-checkbox__inner {
  246. background-color: #409eff;
  247. border-color: #409eff;
  248. }
  249. }
  250. }
  251. .login-tip {
  252. font-size: 13px;
  253. text-align: center;
  254. color: #bfbfbf;
  255. }
  256. .login-code {
  257. width: 33%;
  258. height: 48px;
  259. float: right;
  260. img {
  261. cursor: pointer;
  262. vertical-align: middle;
  263. border-radius: 6px;
  264. border: 2px solid #e8eaec;
  265. transition: all 0.3s ease;
  266. &:hover {
  267. border-color: #409eff;
  268. transform: scale(1.02);
  269. }
  270. }
  271. }
  272. .register-link {
  273. margin-left: auto;
  274. margin-bottom: -10px;
  275. margin-top: 20px;
  276. text-align: center;
  277. .link-type {
  278. color: #409eff;
  279. text-decoration: none;
  280. font-size: 14px;
  281. font-weight: 500;
  282. transition: all 0.3s ease;
  283. &:hover {
  284. color: #36a3f7;
  285. text-decoration: underline;
  286. }
  287. }
  288. }
  289. }
  290. .el-login-footer {
  291. height: 40px;
  292. line-height: 40px;
  293. position: fixed;
  294. bottom: 0;
  295. width: 100%;
  296. text-align: center;
  297. color: rgba(255, 255, 255, 0.9);
  298. font-family: Arial;
  299. font-size: 12px;
  300. letter-spacing: 1px;
  301. z-index: 2;
  302. text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  303. }
  304. .login-code-img {
  305. height: 48px;
  306. margin-left: 12px;
  307. }
  308. </style>