index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <div id="userLayout" class="w-full h-full relative">
  3. <div
  4. class="rounded-lg flex items-center justify-evenly w-full h-full bg-white md:w-screen md:h-screen md:bg-[#194bfb]"
  5. >
  6. <div class="md:w-3/5 w-10/12 h-full flex items-center justify-evenly">
  7. <div
  8. class="oblique h-[130%] w-3/5 bg-white transform -rotate-12 absolute -ml-52"
  9. />
  10. <!-- 分割斜块 -->
  11. <div
  12. class="z-[999] pt-12 pb-10 md:w-96 w-full rounded-lg flex flex-col justify-between box-border"
  13. >
  14. <div>
  15. <!--LOGO-->
  16. <div class="flex items-center justify-center" style="height:100px;width: 100px;margin-left: 110px;" >
  17. <!-- <img class="w-48 h-16" :src="`/src/assets/dacheng.jpg`" alt /> -->
  18. <!-- <img class="w-48 h-48" :src="`https://reachingkayo.com/Uploads/62f88d57efb9d749.jpg`" alt width="400px" height="400px"/> -->
  19. </div>
  20. <div class="mb-9">
  21. <p class="text-center text-3xl font-bold">
  22. AI云图像包装设计系统
  23. </p>
  24. </div>
  25. <el-form
  26. ref="loginForm"
  27. :model="loginFormData"
  28. :rules="rules"
  29. :validate-on-rule-change="false"
  30. @keyup.enter="submitForm"
  31. >
  32. <el-form-item prop="username" class="mb-6">
  33. <el-input
  34. v-model="loginFormData.username"
  35. size="large"
  36. placeholder="请输入用户名"
  37. suffix-icon="user"
  38. />
  39. </el-form-item>
  40. <el-form-item prop="password" class="mb-6">
  41. <el-input
  42. v-model="loginFormData.password"
  43. show-password
  44. size="large"
  45. type="password"
  46. placeholder="请输入密码"
  47. />
  48. </el-form-item>
  49. <!-- <el-form-item
  50. v-if="loginFormData.openCaptcha"
  51. prop="captcha"
  52. class="mb-6"
  53. >
  54. <div class="flex w-full justify-between">
  55. <el-input
  56. v-model="loginFormData.captcha"
  57. placeholder="请输入验证码"
  58. size="large"
  59. class="flex-1 mr-5"
  60. />
  61. <div class="w-1/3 h-11 bg-[#c3d4f2] rounded">
  62. <img
  63. v-if="picPath"
  64. class="w-full h-full"
  65. :src="picPath"
  66. alt="请输入验证码"
  67. @click="loginVerify()"
  68. />
  69. </div>
  70. </div>
  71. </el-form-item> -->
  72. <el-form-item class="mb-6">
  73. <el-button
  74. class="shadow shadow-blue-600 h-11 w-full"
  75. type="primary"
  76. size="large"
  77. @click="submitForm"
  78. >登 录</el-button
  79. >
  80. </el-form-item>
  81. </el-form>
  82. </div>
  83. </div>
  84. </div>
  85. <div class="hidden md:block w-1/2 h-full float-right bg-[#194bfb]">
  86. <img
  87. class="h-full"
  88. src="@/assets/login_right_banner.jpg"
  89. alt="banner"
  90. />
  91. </div>
  92. </div>
  93. <BottomInfo class="left-0 right-0 absolute bottom-3 mx-auto w-full z-20">
  94. <div class="links items-center justify-center gap-2 hidden md:flex">
  95. <a href="http://doc.henrongyi.top/" target="_blank">
  96. <img src="@/assets/docs.png" class="w-8 h-8" alt="文档" />
  97. </a>
  98. <a href="https://support.qq.com/product/371961" target="_blank">
  99. <img src="@/assets/kefu.png" class="w-8 h-8" alt="客服" />
  100. </a>
  101. <a
  102. href="https://github.com/flipped-aurora/gin-vue-admin"
  103. target="_blank"
  104. >
  105. <img src="@/assets/github.png" class="w-8 h-8" alt="github" />
  106. </a>
  107. <a href="https://space.bilibili.com/322210472" target="_blank">
  108. <img src="@/assets/video.png" class="w-8 h-8" alt="视频站" />
  109. </a>
  110. </div>
  111. </BottomInfo>
  112. <!-- 添加的中间信息 -->
  113. <!-- <div class="absolute bottom-10 left-[45%] transform -translate-x-1/2 text-center">
  114. <p>联系电话:竺工 13958052363</p>
  115. </div> -->
  116. </div>
  117. </template>
  118. <script setup>
  119. // import { captcha } from "@/api/user";
  120. import { checkDB } from "@/api/initdb";
  121. import BottomInfo from "@/view/layout/bottomInfo/bottomInfo.vue";
  122. import { reactive, ref } from "vue";
  123. import { ElMessage } from "element-plus";
  124. import { useRouter } from "vue-router";
  125. import { useUserStore } from "@/pinia/modules/user";
  126. import {getMachineMac} from '@/api/jixiaoguanli/jitairibaobiao'
  127. defineOptions({
  128. name: "Login",
  129. });
  130. const router = useRouter();
  131. // 验证函数
  132. const checkUsername = (rule, value, callback) => {
  133. if (value.length < 3) {
  134. return callback(new Error("请输入正确的用户名"));
  135. } else {
  136. callback();
  137. }
  138. };
  139. const checkPassword = (rule, value, callback) => {
  140. if (value.length < 6) {
  141. return callback(new Error("请输入正确的密码"));
  142. } else {
  143. callback();
  144. }
  145. };
  146. // 获取验证码
  147. const loginVerify = () => {
  148. // captcha({}).then(async (ele) => {
  149. // rules.captcha.push({
  150. // max: ele.data.captchaLength,
  151. // min: ele.data.captchaLength,
  152. // message: `请输入${ele.data.captchaLength}位验证码`,
  153. // trigger: "blur",
  154. // });
  155. // picPath.value = ele.data.picPath;
  156. // loginFormData.captchaId = ele.data.captchaId;
  157. // loginFormData.openCaptcha = ele.data.openCaptcha;
  158. // // console.log();
  159. // });
  160. };
  161. loginVerify();
  162. // 登录相关操作
  163. const loginForm = ref(null);
  164. const picPath = ref("");
  165. const loginFormData = reactive({
  166. username: "",
  167. password: "",
  168. captcha: "443188",
  169. captchaId: "0FZfnUtAOrdXvTETkJRc",
  170. openCaptcha: false,
  171. });
  172. const rules = reactive({
  173. username: [{ validator: checkUsername, trigger: "blur" }],
  174. password: [{ validator: checkPassword, trigger: "blur" }],
  175. // captcha: [
  176. // {
  177. // message: "验证码格式不正确",
  178. // trigger: "blur",
  179. // },
  180. // ],
  181. });
  182. const userStore = useUserStore();
  183. const login = async () => {
  184. return await userStore.LoginIn(loginFormData);
  185. };
  186. const submitForm = () => {
  187. loginForm.value.validate(async (v) => {
  188. if (v) {
  189. const flag = await login();
  190. if (!flag) {
  191. loginVerify();
  192. }
  193. } else {
  194. ElMessage({
  195. type: "error",
  196. message: "请正确填写登录信息",
  197. showClose: true,
  198. });
  199. loginVerify();
  200. return false;
  201. }
  202. });
  203. };
  204. // 跳转初始化
  205. const checkInit = async () => {
  206. const res = await checkDB();
  207. if (res.code === 0) {
  208. if (res.data?.needInit) {
  209. userStore.NeedInit();
  210. router.push({ name: "Init" });
  211. } else {
  212. ElMessage({
  213. type: "info",
  214. message: "已配置数据库信息,无法初始化",
  215. });
  216. }
  217. }
  218. };
  219. const GetAddr = () => {
  220. var xmlhttp = null;
  221. var res;
  222. if (window.XMLHttpRequest) {
  223. xmlhttp = new XMLHttpRequest();
  224. } else if (window.ActiveXObject) {
  225. xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  226. }
  227. // 设置回调函数
  228. xmlhttp.onreadystatechange = function () {
  229. if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
  230. res = eval("(" + xmlhttp.response + ")");
  231. let result = "";
  232. for (let i = 0; i < res.macAddress.length; i++) {
  233. if (i % 2 === 0 && i !== 0) {
  234. result += "-"; // 根据实际需求修改分隔符
  235. }
  236. result += res.macAddress[i];
  237. }
  238. }
  239. };
  240. // 打开一个连接
  241. xmlhttp.open("get", "http://127.0.0.1:8090/init");
  242. // 发送请求
  243. xmlhttp.send();
  244. };
  245. // 在页面加载时获取MAC地址并进行自动登录
  246. GetAddr();
  247. // userStore.LoginIn2({
  248. // username: "CF01#",
  249. // password: "123456",
  250. // captcha: "443188",
  251. // captchaId: "0FZfnUtAOrdXvTETkJRc",
  252. // openCaptcha: false,
  253. // });
  254. </script>