You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 lines
16 KiB

{"ast":null,"code":"import { createElementVNode as _createElementVNode, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, resolveComponent as _resolveComponent, normalizeClass as _normalizeClass, withCtx as _withCtx, createVNode as _createVNode, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, createElementBlock as _createElementBlock } from \"vue\";\nconst _hoisted_1 = {\n class: \"login-container\"\n};\nconst _hoisted_2 = {\n class: \"login-box\"\n};\nconst _hoisted_3 = {\n class: \"title\"\n};\nconst _hoisted_4 = {\n class: \"toggle-buttons\"\n};\nexport function render(_ctx, _cache, $props, $setup, $data, $options) {\n const _component_el_button = _resolveComponent(\"el-button\");\n const _component_el_input = _resolveComponent(\"el-input\");\n const _component_el_form_item = _resolveComponent(\"el-form-item\");\n const _component_el_form = _resolveComponent(\"el-form\");\n return _openBlock(), _createElementBlock(\"div\", _hoisted_1, [_cache[7] || (_cache[7] = _createElementVNode(\"div\", {\n class: \"system-title\"\n }, \"物流管理系统\", -1 /* HOISTED */)), _createElementVNode(\"div\", _hoisted_2, [_createElementVNode(\"h2\", _hoisted_3, _toDisplayString($setup.isRegister ? '用户注册' : '欢迎登录'), 1 /* TEXT */), _createElementVNode(\"div\", _hoisted_4, [_createVNode(_component_el_button, {\n class: _normalizeClass(['toggle-btn', !$setup.isRegister && 'active']),\n onClick: _cache[0] || (_cache[0] = $event => $setup.isRegister = false)\n }, {\n default: _withCtx(() => _cache[5] || (_cache[5] = [_createTextVNode(\"登录\")])),\n _: 1 /* STABLE */\n }, 8 /* PROPS */, [\"class\"]), _createVNode(_component_el_button, {\n class: _normalizeClass(['toggle-btn', $setup.isRegister && 'active']),\n onClick: _cache[1] || (_cache[1] = $event => $setup.isRegister = true)\n }, {\n default: _withCtx(() => _cache[6] || (_cache[6] = [_createTextVNode(\"注册\")])),\n _: 1 /* STABLE */\n }, 8 /* PROPS */, [\"class\"])]), _createVNode(_component_el_form, {\n ref: \"formRef\",\n model: $setup.form,\n rules: $setup.rules,\n \"label-width\": \"0\",\n class: \"login-form\"\n }, {\n default: _withCtx(() => [_createVNode(_component_el_form_item, {\n prop: \"username\"\n }, {\n default: _withCtx(() => [_createVNode(_component_el_input, {\n modelValue: $setup.form.username,\n \"onUpdate:modelValue\": _cache[2] || (_cache[2] = $event => $setup.form.username = $event),\n placeholder: \"请输入用户名\",\n \"prefix-icon\": \"User\"\n }, null, 8 /* PROPS */, [\"modelValue\"])]),\n _: 1 /* STABLE */\n }), _createVNode(_component_el_form_item, {\n prop: \"password\"\n }, {\n default: _withCtx(() => [_createVNode(_component_el_input, {\n modelValue: $setup.form.password,\n \"onUpdate:modelValue\": _cache[3] || (_cache[3] = $event => $setup.form.password = $event),\n type: \"password\",\n placeholder: \"请输入密码\",\n \"prefix-icon\": \"Lock\",\n \"show-password\": \"\"\n }, null, 8 /* PROPS */, [\"modelValue\"])]),\n _: 1 /* STABLE */\n }), $setup.isRegister ? (_openBlock(), _createBlock(_component_el_form_item, {\n key: 0,\n prop: \"email\"\n }, {\n default: _withCtx(() => [_createVNode(_component_el_input, {\n modelValue: $setup.form.email,\n \"onUpdate:modelValue\": _cache[4] || (_cache[4] = $event => $setup.form.email = $event),\n placeholder: \"请输入邮箱\",\n \"prefix-icon\": \"Message\"\n }, null, 8 /* PROPS */, [\"modelValue\"])]),\n _: 1 /* STABLE */\n })) : _createCommentVNode(\"v-if\", true), _createVNode(_component_el_form_item, null, {\n default: _withCtx(() => [_createVNode(_component_el_button, {\n type: \"primary\",\n class: \"submit-btn\",\n loading: $setup.loading,\n onClick: $setup.handleSubmit\n }, {\n default: _withCtx(() => [_createTextVNode(_toDisplayString($setup.isRegister ? '注册' : '登录'), 1 /* TEXT */)]),\n _: 1 /* STABLE */\n }, 8 /* PROPS */, [\"loading\"])]),\n _: 1 /* STABLE */\n })]),\n _: 1 /* STABLE */\n }, 8 /* PROPS */, [\"model\"])]), _cache[8] || (_cache[8] = _createElementVNode(\"div\", {\n class: \"footer\"\n }, \" © 2024 物流管理系统 All Rights Reserved \", -1 /* HOISTED */))]);\n}","map":{"version":3,"names":["class","_createElementBlock","_hoisted_1","_createElementVNode","_hoisted_2","_hoisted_3","_toDisplayString","$setup","isRegister","_hoisted_4","_createVNode","_component_el_button","_normalizeClass","onClick","_cache","$event","default","_withCtx","_createTextVNode","_","_component_el_form","ref","model","form","rules","_component_el_form_item","prop","_component_el_input","modelValue","username","placeholder","password","type","_createBlock","key","email","_createCommentVNode","loading","handleSubmit"],"sources":["D:\\IDEAproject\\frontend\\Front-end logistics\\src\\views\\login\\index.vue"],"sourcesContent":["<template>\r\n <div class=\"login-container\">\r\n <div class=\"system-title\">物流管理系统</div>\r\n \r\n <div class=\"login-box\">\r\n <h2 class=\"title\">{{ isRegister ? '用户注册' : '欢迎登录' }}</h2>\r\n \r\n <div class=\"toggle-buttons\">\r\n <el-button \r\n :class=\"['toggle-btn', !isRegister && 'active']\"\r\n @click=\"isRegister = false\"\r\n >登录</el-button>\r\n <el-button \r\n :class=\"['toggle-btn', isRegister && 'active']\"\r\n @click=\"isRegister = true\"\r\n >注册</el-button>\r\n </div>\r\n \r\n <el-form \r\n ref=\"formRef\"\r\n :model=\"form\"\r\n :rules=\"rules\"\r\n label-width=\"0\"\r\n class=\"login-form\"\r\n >\r\n <el-form-item prop=\"username\">\r\n <el-input\r\n v-model=\"form.username\"\r\n placeholder=\"请输入用户名\"\r\n prefix-icon=\"User\"\r\n />\r\n </el-form-item>\r\n \r\n <el-form-item prop=\"password\">\r\n <el-input\r\n v-model=\"form.password\"\r\n type=\"password\"\r\n placeholder=\"请输入密码\"\r\n prefix-icon=\"Lock\"\r\n show-password\r\n />\r\n </el-form-item>\r\n \r\n <el-form-item v-if=\"isRegister\" prop=\"email\">\r\n <el-input\r\n v-model=\"form.email\"\r\n placeholder=\"请输入邮箱\"\r\n prefix-icon=\"Message\"\r\n />\r\n </el-form-item>\r\n \r\n <el-form-item>\r\n <el-button \r\n type=\"primary\" \r\n class=\"submit-btn\"\r\n :loading=\"loading\"\r\n @click=\"handleSubmit\"\r\n >\r\n {{ isRegister ? '注册' : '登录' }}\r\n </el-button>\r\n </el-form-item>\r\n </el-form>\r\n </div>\r\n \r\n <div class=\"footer\">\r\n © 2024 物流管理系统 All Rights Reserved\r\n </div>\r\n </div>\r\n</template>\r\n\r\n<script setup>\r\nimport { ref, reactive } from 'vue'\r\nimport { useRouter } from 'vue-router'\r\nimport { useStore } from 'vuex'\r\nimport { ElMessage } from 'element-plus'\r\nimport { User, Lock, Message } from '@element-plus/icons-vue'\r\nimport { login, register } from '@/api/auth'\r\n\r\nconst router = useRouter()\r\nconst store = useStore()\r\nconst formRef = ref(null)\r\nconst isRegister = ref(false)\r\nconst loading = ref(false)\r\n\r\nconst form = reactive({\r\n username: '',\r\n password: '',\r\n email: ''\r\n})\r\n\r\nconst rules = {\r\n username: [\r\n { required: true, message: '请输入用户名', trigger: 'blur' },\r\n { min: 3, max: 20, message: '长度在 3 到 20 个字符', trigger: 'blur' }\r\n ],\r\n password: [\r\n { required: true, message: '请输入密码', trigger: 'blur' },\r\n { min: 6, max: 20, message: '长度在 6 到 20 个字符', trigger: 'blur' }\r\n ],\r\n email: [\r\n { required: true, message: '请输入邮箱地址', trigger: 'blur' },\r\n { \r\n type: 'email', \r\n message: '请输入正确的邮箱地址', \r\n trigger: ['blur', 'change'] \r\n },\r\n {\r\n pattern: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/,\r\n message: '邮箱格式不正确',\r\n trigger: ['blur', 'change']\r\n }\r\n ]\r\n}\r\n\r\nconst handleSubmit = async () => {\r\n if (!formRef.value) return\r\n \r\n try {\r\n await formRef.value.validate()\r\n loading.value = true\r\n \r\n if (isRegister.value) {\r\n // 检查邮箱格式\r\n const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/\r\n if (!emailRegex.test(form.email)) {\r\n ElMessage.error('邮箱格式不正确')\r\n return\r\n }\r\n\r\n const res = await register(form)\r\n if (res.code === 200) {\r\n ElMessage.success(res.message || '注册成功,请登录')\r\n isRegister.value = false\r\n formRef.value.resetFields()\r\n form.username = form.username\r\n }\r\n } else {\r\n const res = await login(form)\r\n if (res.code === 200) {\r\n // 保存用户信息和 token\r\n store.commit('setUserInfo', {\r\n userId: res.data.userId,\r\n username: res.data.username,\r\n roles: res.data.roleCodes\r\n })\r\n store.commit('setToken', res.data.token)\r\n ElMessage.success('登录成功')\r\n \r\n // 根据角色重定向到不同页面\r\n if (res.data.roleCodes.includes('ROLE_ADMIN')) {\r\n router.push('/admin/orders')\r\n } else if (res.data.roleCodes.includes('ROLE_LOGISTICS_ADMIN')) {\r\n router.push('/admin/orders')\r\n } else if (res.data.roleCodes.includes('ROLE_WAREHOUSE_ADMIN')) {\r\n router.push('/orders/create')\r\n } else if (res.data.roleCodes.includes('ROLE_USER')) {\r\n router.push('/orders/my')\r\n } else {\r\n ElMessage.error('未知的用户角色')\r\n store.dispatch('logout')\r\n router.push('/login')\r\n }\r\n } else {\r\n // 显示后端返回的错误信息\r\n ElMessage.error(res.message || '登录失败')\r\n }\r\n }\r\n } catch (error) {\r\n console.error('操作失败:', error)\r\n // 显示具体的错误信息\r\n if (error.response?.data?.message) {\r\n ElMessage.error(error.response.data.message)\r\n } else {\r\n ElMessage.error(error.message || '登录失败,请检查用户名和密码')\r\n }\r\n } finally {\r\n loading.value = false\r\n }\r\n}\r\n\r\n// 注册图标组件\r\nconst icons = {\r\n User,\r\n Lock,\r\n Message\r\n}\r\n</script>\r\n\r\n<style scoped>\r\n.login-container {\r\n height: 100vh;\r\n display: flex;\r\n flex-direction: column;\r\n justify-content: center;\r\n align-items: center;\r\n background-color: #fff; /* 改为白色背景 */\r\n position: relative;\r\n}\r\n\r\n.system-title {\r\n font-size: 36px;\r\n font-weight: bold;\r\n color: #409EFF;\r\n margin-bottom: 40px;\r\n letter-spacing: 2px;\r\n text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);\r\n position: relative;\r\n}\r\n\r\n.system-title::after {\r\n content: '';\r\n position: absolute;\r\n bottom: -10px;\r\n left: 50%;\r\n transform: translateX(-50%);\r\n width: 60px;\r\n height: 3px;\r\n background: linear-gradient(45deg, #409EFF, #36cccb);\r\n border-radius: 3px;\r\n}\r\n\r\n.login-box {\r\n width: 420px;\r\n padding: 40px;\r\n background: #fff;\r\n border-radius: 16px;\r\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);\r\n transition: all 0.3s ease;\r\n animation: fadeIn 0.6s ease-out;\r\n border: 1px solid rgba(64, 158, 255, 0.1);\r\n}\r\n\r\n.login-box:hover {\r\n transform: translateY(-5px);\r\n box-shadow: 0 12px 40px rgba(64, 158, 255, 0.15);\r\n}\r\n\r\n.title {\r\n text-align: center;\r\n color: #409EFF;\r\n font-size: 24px;\r\n margin-bottom: 30px;\r\n font-weight: 600;\r\n}\r\n\r\n.toggle-buttons {\r\n display: flex;\r\n justify-content: center;\r\n margin-bottom: 30px;\r\n gap: 20px;\r\n}\r\n\r\n.toggle-btn {\r\n width: 100px;\r\n transition: all 0.3s ease;\r\n border: 1px solid #409EFF;\r\n}\r\n\r\n.toggle-btn.active {\r\n background: linear-gradient(45deg, #409EFF, #36cccb);\r\n color: white;\r\n font-weight: 500;\r\n transform: scale(1.05);\r\n border: none;\r\n}\r\n\r\n.login-form {\r\n margin-top: 20px;\r\n}\r\n\r\n.login-form :deep(.el-input__wrapper) {\r\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);\r\n border-radius: 8px;\r\n transition: all 0.3s ease;\r\n}\r\n\r\n.login-form :deep(.el-input__wrapper:hover) {\r\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);\r\n}\r\n\r\n.login-form :deep(.el-input__wrapper.is-focus) {\r\n box-shadow: 0 0 0 1px #409EFF;\r\n}\r\n\r\n.submit-btn {\r\n width: 100%;\r\n height: 44px;\r\n font-size: 16px;\r\n font-weight: 500;\r\n letter-spacing: 1px;\r\n background: linear-gradient(45deg, #409EFF, #36cccb);\r\n border: none;\r\n margin-top: 20px;\r\n transition: all 0.3s ease;\r\n}\r\n\r\n.submit-btn:hover {\r\n transform: translateY(-2px);\r\n box-shadow: 0 4px 12px rgba(64, 158, 255, 0.3);\r\n background: linear-gradient(45deg, #36cccb, #409EFF);\r\n}\r\n\r\n@keyframes fadeIn {\r\n from {\r\n opacity: 0;\r\n transform: translateY(20px);\r\n }\r\n to {\r\n opacity: 1;\r\n transform: translateY(0);\r\n }\r\n}\r\n\r\n@media (max-width: 480px) {\r\n .login-box {\r\n width: 90%;\r\n padding: 30px 20px;\r\n }\r\n \r\n .system-title {\r\n font-size: 28px;\r\n }\r\n}\r\n\r\n/* 添加页脚 */\r\n.footer {\r\n position: absolute;\r\n bottom: 20px;\r\n color: #909399;\r\n font-size: 14px;\r\n}\r\n</style> "],"mappings":";;EACOA,KAAK,EAAC;AAAiB;;EAGrBA,KAAK,EAAC;AAAW;;EAChBA,KAAK,EAAC;AAAO;;EAEZA,KAAK,EAAC;AAAgB;;;;;;uBAN/BC,mBAAA,CAkEM,OAlENC,UAkEM,G,0BAjEJC,mBAAA,CAAsC;IAAjCH,KAAK,EAAC;EAAc,GAAC,QAAM,sBAEhCG,mBAAA,CA0DM,OA1DNC,UA0DM,GAzDJD,mBAAA,CAAyD,MAAzDE,UAAyD,EAAAC,gBAAA,CAApCC,MAAA,CAAAC,UAAU,oCAE/BL,mBAAA,CASM,OATNM,UASM,GARJC,YAAA,CAGeC,oBAAA;IAFZX,KAAK,EAThBY,eAAA,iBASkCL,MAAA,CAAAC,UAAU;IACjCK,OAAK,EAAAC,MAAA,QAAAA,MAAA,MAAAC,MAAA,IAAER,MAAA,CAAAC,UAAU;;IAV5BQ,OAAA,EAAAC,QAAA,CAWS,MAAEH,MAAA,QAAAA,MAAA,OAXXI,gBAAA,CAWS,IAAE,E;IAXXC,CAAA;gCAYQ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