login.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. <template>
  2. <div class="system-layer" :style="{ backgroundImage: `url('/image/Frame 208@2x.png')` }">
  3. <div class="l-content">
  4. <div class="login-layer">
  5. <div class="content">
  6. <div class="info">
  7. <div class="top">
  8. <img src="/image/logo@2x.png" />
  9. </div>
  10. <div class="center">
  11. <h1>不可移动文物管理平台</h1>
  12. <p>
  13. <img src="/image/logo.png" />
  14. </p>
  15. </div>
  16. <div class="bottom">
  17. <div class="abr-info">
  18. <p>Android版</p>
  19. <div class="e-code">
  20. <span v-html="qrUrl"></span>
  21. <div class="e-logo">
  22. <img src="/image/e-code.png" />
  23. </div>
  24. </div>
  25. <p class="desc">扫描安装文保1号App</p>
  26. </div>
  27. <img class="code" src="/image/pic_camera@2x.png" />
  28. </div>
  29. </div>
  30. <!-- login right panel -->
  31. <template v-if="currentStatus(0)">
  32. <el-form class="panel login" :model="form" @submit.stop>
  33. <h2>欢迎登录</h2>
  34. <el-form-item class="panel-form-item">
  35. <p class="err-info">{{ verification.phone }}</p>
  36. <el-input :maxlength="11" v-model.trim="form.phone" placeholder="手机号"
  37. @keydown.enter="submitClick"></el-input>
  38. </el-form-item>
  39. <el-form-item class="panel-form-item">
  40. <p class="err-info">{{ verification.psw }}</p>
  41. <el-input v-model="form.psw" :maxlength="16" placeholder="密码" :type="flag ? 'text' : 'password'"
  42. @keydown.enter="submitClick">
  43. <template v-slot:suffix>
  44. <el-icon :size="20" @click="flag = !flag" class="icon-style">
  45. <View v-if="flag" />
  46. <Hide v-else />
  47. </el-icon>
  48. </template>
  49. </el-input>
  50. </el-form-item>
  51. <el-form-item class="panel-form-item" style="user-select: none">
  52. <DragVerify ref="verify" :class="{ passing: isPassing2 }" :isPassing="isPassing2"
  53. @passcallback="isPassing2 = true" handlerIcon="el-icon-d-arrow-right" background="#D9D9D9"
  54. textColor="#333333" successIcon="el-icon-circle-check" :text="isPassing2 ? '已通过验证' : '登录需要拖拽验证'"
  55. successText="验证通过" :width="400">
  56. <template v-slot:handlerIcon>
  57. <el-icon :size="20" style="
  58. width: 20px;
  59. display: inline-block;
  60. line-height: 20px;
  61. margin-top: 8px;
  62. ">
  63. <DArrowRight v-if="!isPassing2" />
  64. <SuccessFilled v-else />
  65. </el-icon>
  66. </template>
  67. </DragVerify>
  68. </el-form-item>
  69. <el-form-item class="panel-form-item">
  70. <el-button type="primary" class="fill submit" @click="submitClick">登录</el-button>
  71. </el-form-item>
  72. <div class="register">
  73. <span @click="handleForgetPassword"> 忘记密码</span> |
  74. <span @click="handleRegister"> 单位注册</span>
  75. </div>
  76. </el-form>
  77. </template>
  78. <template v-if="currentStatus(1)">
  79. <register @done="goTologin"></register>
  80. </template>
  81. <template v-if="currentStatus(2)">
  82. <reset @done="goTologin"></reset>
  83. </template>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. </template>
  89. <script lang="ts" setup>
  90. import { reactive, watch, ref, computed } from "vue";
  91. import { View, Hide, DArrowRight, SuccessFilled } from "@element-plus/icons-vue";
  92. import { login } from "@/store/user";
  93. import { ElMessage } from "element-plus";
  94. import { router } from "@/router";
  95. import qrCode from "qrcode";
  96. import DragVerify from "@/components/drag-verify.vue";
  97. import register from '@/view/register/register.vue'
  98. import reset from '@/view/register/reset.vue'
  99. const PHONE = {
  100. REG: /^1(3|4|5|6|7|8|9)\d{9}$/,
  101. // REG: /^((13[0-9]|14[01456879]|15[0-3,5-9]|16[2567]|17[0-8]|18[0-9]|19[0-3,5-9])\d{8})|(8){11}$/,
  102. tip: "手机号格式不正确!",
  103. };
  104. // 是否显示明文密码
  105. const flag = ref(false);
  106. const verify = ref<any>();
  107. const isPassing2 = ref(false);
  108. const registerStatus = ref(0);
  109. const currentStatus = computed(() => (status: number) => status === registerStatus.value)
  110. // 表单
  111. const form = reactive({
  112. phone: import.meta.env.DEV ? "13800000001" : "",
  113. psw: import.meta.env.DEV ? "88888888Sw" : "",
  114. });
  115. const verification = reactive({ phone: "", psw: "" });
  116. const fromVerification = (verification: { phone: string; psw: string }) => {
  117. if (!form.phone) {
  118. verification.phone = "请输入手机号";
  119. } else if (["88888888888", "99999999999"].includes(form.phone)) {
  120. verification.phone = "";
  121. } else {
  122. verification.phone = PHONE.REG.test(form.phone) ? "" : PHONE.tip;
  123. }
  124. if (!form.psw) {
  125. verification.psw = "请输入密码";
  126. } else {
  127. verification.psw = "";
  128. }
  129. };
  130. watch(
  131. form,
  132. () => {
  133. const currentVerification = { phone: "", psw: "" };
  134. fromVerification(currentVerification);
  135. if (!currentVerification.phone) {
  136. verification.phone = "";
  137. }
  138. if (!currentVerification.psw) {
  139. verification.psw = "";
  140. }
  141. },
  142. { immediate: true }
  143. );
  144. const qrUrl = ref<string>();
  145. qrCode.toString(
  146. `${location.origin}/android-download/app-download.html`,
  147. { type: "svg", width: 128, margin: 0, errorCorrectionLevel: "L" },
  148. (_, url) => {
  149. qrUrl.value = url;
  150. }
  151. );
  152. // 表单提交
  153. const submitClick = async () => {
  154. fromVerification(verification);
  155. if (verification.phone && verification.phone !== "88888888888") {
  156. return ElMessage.error(verification.phone);
  157. }
  158. if (verification.psw) return ElMessage.error(verification.psw);
  159. if (!isPassing2.value) {
  160. return ElMessage.error("登录需要拖拽验证");
  161. }
  162. try {
  163. await login({ phoneNum: form.phone, password: form.psw });
  164. router.replace("scene");
  165. } catch (e) {
  166. console.error(e);
  167. }
  168. verify.value.reset();
  169. isPassing2.value = false;
  170. };
  171. // 忘记密码
  172. const handleForgetPassword = () => {
  173. registerStatus.value = 2
  174. }
  175. // 注册
  176. const handleRegister = () => {
  177. registerStatus.value = 1
  178. }
  179. // 业务回到login
  180. const goTologin = () => {
  181. registerStatus.value = 0
  182. }
  183. </script>
  184. <style lang="scss" scoped>
  185. .login-layer {
  186. width: 100%;
  187. height: 100%;
  188. }
  189. .content {
  190. display: flex;
  191. justify-content: center;
  192. align-items: center;
  193. justify-content: space-between;
  194. box-sizing: border-box;
  195. max-width: 1620px;
  196. height: 100vh;
  197. padding: 0 50px 0 50px;
  198. }
  199. .info {
  200. color: #000;
  201. flex: none;
  202. text-align: left;
  203. display: flex;
  204. flex-direction: column;
  205. justify-content: space-between;
  206. max-width: 800px;
  207. height: 100vh;
  208. flex: 1;
  209. margin-right: 10%;
  210. .top {
  211. margin-top: 50px;
  212. img {
  213. width: 142px;
  214. }
  215. }
  216. .bottom {
  217. height: 470px;
  218. display: flex;
  219. align-items: center;
  220. justify-content: center;
  221. .code {
  222. height: 100%;
  223. flex: none;
  224. }
  225. .abr-info {
  226. flex: 1;
  227. display: flex;
  228. flex-direction: column;
  229. align-items: center;
  230. p:first-child {
  231. font-size: 20px;
  232. line-height: 32px;
  233. color: #93795d;
  234. padding-left: 32px;
  235. position: relative;
  236. &::after {
  237. content: "";
  238. position: absolute;
  239. left: 0;
  240. top: 0;
  241. width: 32px;
  242. height: 32px;
  243. background: url("/image/Android@2x.png") no-repeat center center;
  244. background-size: 100% 100%;
  245. }
  246. }
  247. .e-code {
  248. width: 128px;
  249. margin-top: 13px;
  250. position: relative;
  251. >img {
  252. width: 100%;
  253. }
  254. .e-logo {
  255. position: absolute;
  256. top: 50%;
  257. left: 50%;
  258. width: 40px;
  259. height: 40px;
  260. transform: translate(-50%, -50%);
  261. padding: 7px;
  262. border-radius: 4px;
  263. text-align: center;
  264. img {
  265. height: 100%;
  266. width: 100%;
  267. background-size: cover;
  268. }
  269. }
  270. }
  271. p:last-child {
  272. font-weight: 400;
  273. font-size: 14px;
  274. color: rgba(0, 0, 0, 0.5);
  275. }
  276. }
  277. }
  278. .center {
  279. text-align: center;
  280. h1 {
  281. color: #781c0b;
  282. font-size: 48px;
  283. line-height: 3.7rem;
  284. margin-bottom: 0.7rem;
  285. }
  286. p {
  287. width: 100%;
  288. margin-top: 40px;
  289. img {
  290. width: 320px;
  291. }
  292. }
  293. }
  294. }
  295. .top-text {
  296. margin-bottom: 50px;
  297. pointer-events: none;
  298. height: 153px;
  299. min-width: 1200px;
  300. img {
  301. position: absolute;
  302. right: 0;
  303. }
  304. }
  305. .fill {
  306. width: 100%;
  307. }
  308. .login {
  309. width: 400px;
  310. // padding: 40px 40px 30px;
  311. position: relative;
  312. display: inline-block;
  313. flex: none;
  314. h2 {
  315. padding-left: 0;
  316. padding-bottom: 0;
  317. border-bottom: none;
  318. margin-bottom: 24px;
  319. span {
  320. color: #646566;
  321. font-size: 1.33rem;
  322. margin-top: 0.71rem;
  323. display: block;
  324. }
  325. }
  326. .panel-form-item {
  327. padding-left: 0;
  328. padding-right: 0;
  329. .icon-style {
  330. margin-right: 14px;
  331. font-size: 20px;
  332. line-height: 50px;
  333. }
  334. }
  335. .more a:first-child::after {
  336. content: "";
  337. position: absolute;
  338. right: -5px;
  339. width: 1px;
  340. height: 8px;
  341. background: #dcdee0;
  342. top: 50%;
  343. transform: translateY(-50%);
  344. }
  345. }
  346. .code-img {
  347. width: 100%;
  348. height: 100%;
  349. // object-fit: cover;
  350. }
  351. .system-layer {
  352. width: 100%;
  353. min-height: 100%;
  354. display: flex;
  355. flex-direction: row;
  356. align-items: center;
  357. justify-content: center;
  358. background: no-repeat left bottom;
  359. background-size: auto 100%;
  360. }
  361. .l-content {
  362. display: flex;
  363. width: 100%;
  364. height: 100%;
  365. justify-content: center;
  366. align-items: flex-start;
  367. }
  368. .register {
  369. display: flex;
  370. flex-direction: row;
  371. flex: 1;
  372. justify-content: center;
  373. span {
  374. padding: 0 10px;
  375. }
  376. }
  377. </style>
  378. <style>
  379. .login .code-form-item .el-input {
  380. display: flex;
  381. }
  382. .login .code-form-item .el-input-group__append {
  383. flex: none;
  384. margin-left: 10px;
  385. width: 95px;
  386. display: flex;
  387. align-items: center;
  388. justify-content: center;
  389. padding: 0;
  390. }
  391. .login .code-form-item .el-input__inner {
  392. flex: 1;
  393. }
  394. .login .code-form-item .el-input-group__append,
  395. .login .code-form-item .el-input__inner {
  396. border-radius: 4px;
  397. }
  398. input[type="password"]::-ms-reveal {
  399. display: none;
  400. }
  401. .panel {
  402. /* background: rgba(255, 255, 255, 0.7);
  403. box-shadow: 0px 2px 20px 0px rgba(5, 38, 38, 0.15);
  404. border-radius: 10px; */
  405. width: 400px;
  406. /* padding: 30px 0 40px; */
  407. text-align: initial;
  408. h2 {
  409. font-weight: bold;
  410. font-size: 30px;
  411. font-weight: bold;
  412. color: rgba(0, 0, 0, 0.85);
  413. margin-bottom: 2.14rem;
  414. padding-left: 60px;
  415. padding-bottom: 20px;
  416. }
  417. .panel-form-item {
  418. position: relative;
  419. padding-bottom: 24px;
  420. margin: 0;
  421. padding-left: 90px;
  422. padding-right: 90px;
  423. &.remember {
  424. padding: 0;
  425. }
  426. .err-info {
  427. position: absolute;
  428. top: 100%;
  429. left: 0;
  430. margin: 0;
  431. font-size: 0.8rem;
  432. line-height: 1.14rem;
  433. color: #fa5555;
  434. }
  435. }
  436. .more {
  437. text-align: center;
  438. a {
  439. color: #323233;
  440. line-height: 21px;
  441. font-size: 16px;
  442. margin: 0 5px;
  443. position: relative;
  444. text-decoration: none;
  445. cursor: pointer;
  446. }
  447. }
  448. }
  449. .panel-form-item .el-select {
  450. width: 100%;
  451. }
  452. .panel-form-item .el-button,
  453. .panel-form-item .el-input__inner {
  454. height: 40px;
  455. font-size: 1.14rem;
  456. }
  457. .panel-form-item .el-button {
  458. line-height: 26px;
  459. font-weight: bold;
  460. font-size: 16px;
  461. }
  462. .panel-form-item .el-form-item__label {
  463. line-height: 50px;
  464. }
  465. .e-code img {
  466. width: 100%;
  467. }
  468. .submit {
  469. --el-color-primary: #93795d;
  470. --el-button-hover-border-color: #93795d;
  471. --el-button-hover-bg-color: #93795d;
  472. --el-button-active-bg-color: #93795d;
  473. --el-button-active-border-color: #93795d;
  474. }
  475. .drag_verify {
  476. border: 1px solid #dcdfe6;
  477. }
  478. .register span {
  479. cursor: pointer;
  480. }
  481. </style>