Login.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <div class="container">
  3. <div class="login-box">
  4. <div class="left">
  5. <div class="left-up-icon"></div>
  6. </div>
  7. <div class="right">
  8. <div class="title">
  9. <div class="title-left"></div>
  10. <div class="title-mid">丨</div>
  11. <div class="title-right">智慧远程海事管理系统</div>
  12. </div>
  13. <div class="form-container">
  14. <el-form :model="ruleForm" :rules="rules" ref="form">
  15. <el-form-item prop="phone">
  16. <el-input placeholder="请输入手机号" v-model="ruleForm.phone">
  17. <template #prepend>
  18. <el-button :icon="Iphone" />
  19. </template>
  20. </el-input>
  21. </el-form-item>
  22. <el-form-item prop="password">
  23. <el-input
  24. type="password"
  25. placeholder="请输入密码"
  26. v-model="ruleForm.password"
  27. >
  28. <template #prepend>
  29. <el-button :icon="Lock" />
  30. </template>
  31. </el-input>
  32. </el-form-item>
  33. <el-form-item>
  34. <el-button
  35. style="
  36. width: 384px;
  37. height: 48px;
  38. border-radius: 2px;
  39. margin-top: 40px;
  40. "
  41. type="primary"
  42. @click="login('ruleForm')"
  43. >
  44. 登录
  45. </el-button>
  46. </el-form-item>
  47. </el-form>
  48. </div>
  49. </div>
  50. </div>
  51. <div @click="goBeian" class="copyright">
  52. Copyright © 2022 汇很多(江苏)科技有限公司 苏ICP备2022023253号-1 号
  53. </div>
  54. </div>
  55. </template>
  56. <script setup>
  57. import { ref, reactive, toRefs } from "vue";
  58. import { ElNotification } from "element-plus";
  59. import store from "../../store";
  60. import router from "../../router";
  61. import { Iphone, Lock } from "@element-plus/icons-vue";
  62. import md5 from "md5";
  63. import api from "../../apis/fetch";
  64. const form = ref(null);
  65. const ruleForm = ref({
  66. phone: "",
  67. password: "",
  68. });
  69. const rules = ref({
  70. phone: [
  71. { required: true, message: "请输入手机号", trigger: "blur" },
  72. { min: 11, max: 11, message: "请正确输入手机号", trigger: "blur" },
  73. ],
  74. password: [{ required: true, message: "请输入密码", trigger: "blur" }],
  75. });
  76. function check() {
  77. // form.value.validate((valid) => {});
  78. }
  79. async function login() {
  80. // let {data} = await cloudConfig.doc("18ed09686196068205eeb77612d641c6").get();
  81. // let { version } = data[0];
  82. // localStorage.setItem("version", version);
  83. form.value.validate(async (valid) => {
  84. if (valid) {
  85. let { phone, password } = ruleForm.value;
  86. let { data } = await api.login({
  87. phone,
  88. password,
  89. // password: md5(password).toUpperCase(),
  90. });
  91. if (data.status == 0) {
  92. ElNotification.success({
  93. title: "成功",
  94. duration: 2000,
  95. message: data.msg,
  96. type: "success",
  97. });
  98. Object.keys(data.result).forEach((key) => {
  99. localStorage.setItem(key, data.result[key]);
  100. });
  101. store.commit("changeLogin", true);
  102. router.replace({ path: "/index" });
  103. } else {
  104. ElNotification.error({
  105. title: "错误",
  106. duration: 3000,
  107. message: data.msg,
  108. });
  109. }
  110. } else {
  111. console.log("error submit!!");
  112. return false;
  113. }
  114. });
  115. }
  116. function goBeian() {
  117. window.open("https://beian.miit.gov.cn/");
  118. }
  119. </script>
  120. <style scoped>
  121. .container {
  122. width: 100%;
  123. height: 100%;
  124. background-image: url(../../assets/login-back.png);
  125. background-size: cover;
  126. }
  127. .login-box {
  128. position: relative;
  129. display: flex;
  130. top: calc(50% - 255px);
  131. left: calc(50% - 478px);
  132. width: 966px;
  133. height: 508px;
  134. border-radius: 10px;
  135. overflow: hidden;
  136. }
  137. .left {
  138. height: 100%;
  139. width: 450px;
  140. background-image: url(../../assets/login-modal.png);
  141. }
  142. .left-up-icon {
  143. width: 40px;
  144. height: 40px;
  145. border-radius: 50%;
  146. margin: 24px;
  147. background-image: url(../../assets/logo.png);
  148. background-size: contain;
  149. }
  150. .right {
  151. height: 100%;
  152. width: 516px;
  153. background: #fff;
  154. }
  155. .title {
  156. width: 384px;
  157. height: 38px;
  158. display: flex;
  159. margin: 0 auto;
  160. margin-top: 100px;
  161. }
  162. .title-left {
  163. height: 38px;
  164. width: 105px;
  165. background: url(https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/miniapp-static/%E6%B1%87%E5%BE%88%E5%A4%9Alogo-%E5%B7%A6%E5%8F%B3.png?sign=22b9335300bbef8d04da1b9b75589f7e&t=1634706935);
  166. background-size: contain;
  167. background-repeat: no-repeat;
  168. }
  169. .title-mid {
  170. font-size: 25px;
  171. color: #e4e4e4;
  172. margin: 0 12px;
  173. }
  174. .title-right {
  175. font-size: 22px;
  176. font-family: Adobe Heiti Std;
  177. font-weight: normal;
  178. color: #434343;
  179. line-height: 38px;
  180. }
  181. .form-container {
  182. margin: 0 auto;
  183. margin-top: 60px;
  184. width: 384px;
  185. }
  186. .copyright {
  187. position: absolute;
  188. width: 100vw;
  189. bottom: 70px;
  190. text-align: center;
  191. font-family: PingFang SC;
  192. font-weight: 400;
  193. color: #aaa;
  194. opacity: 0.8;
  195. cursor: pointer;
  196. }
  197. </style>