Login.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. <el-dialog
  52. title="请选择公司"
  53. width="500"
  54. v-model="comoanyModalVisable"
  55. :show-close="false"
  56. :close-on-click-modal="false"
  57. >
  58. <el-select
  59. @change="selectCompany"
  60. style="display: block; margin: 0 auto; width: 80%"
  61. v-model="store.state.currentCompany"
  62. placeholder="请选择"
  63. >
  64. <el-option
  65. v-for="item in store.state.companySelect"
  66. :key="item.key"
  67. :label="item.value"
  68. :value="item"
  69. />
  70. </el-select>
  71. </el-dialog>
  72. <div @click="goBeian" class="copyright">
  73. Copyright © 2022 汇很多(江苏)科技有限公司 苏ICP备2022023253号-1 号
  74. </div>
  75. </div>
  76. </template>
  77. <script setup>
  78. import { ref, reactive, toRefs } from "vue";
  79. import { ElNotification } from "element-plus";
  80. import store from "../../store";
  81. import router from "../../router";
  82. import { Iphone, Lock } from "@element-plus/icons-vue";
  83. import md5 from "md5";
  84. import api from "../../apis/fetch";
  85. const form = ref(null);
  86. const ruleForm = ref({
  87. phone: "",
  88. password: "",
  89. });
  90. const rules = ref({
  91. phone: [
  92. { required: true, message: "请输入手机号", trigger: "blur" },
  93. { min: 11, max: 11, message: "请正确输入手机号", trigger: "blur" },
  94. ],
  95. password: [{ required: true, message: "请输入密码", trigger: "blur" }],
  96. });
  97. function check() {
  98. // form.value.validate((valid) => {});
  99. }
  100. let comoanyModalVisable = ref(false);
  101. let cache = ref({});
  102. async function login() {
  103. // let {data} = await cloudConfig.doc("18ed09686196068205eeb77612d641c6").get();
  104. // let { version } = data[0];
  105. // localStorage.setItem("version", version);
  106. form.value.validate(async (valid) => {
  107. if (valid) {
  108. let { phone, password } = ruleForm.value;
  109. let { data } = await api.login({
  110. phone,
  111. password,
  112. // password: md5(password).toUpperCase(),
  113. });
  114. if (data.status == 0) {
  115. ElNotification.success({
  116. title: "成功",
  117. duration: 2000,
  118. message: data.msg,
  119. type: "success",
  120. });
  121. if (data.result.isSuperuser == 1) {
  122. comoanyModalVisable.value = true;
  123. cache.value = data.result;
  124. store.dispatch(
  125. "getShippingCompanySelect",
  126. data.result.loginAccountId
  127. );
  128. } else {
  129. store.commit("login", data.result);
  130. }
  131. } else {
  132. ElNotification.error({
  133. title: "错误",
  134. duration: 3000,
  135. message: data.msg,
  136. });
  137. }
  138. } else {
  139. console.log("error submit!!");
  140. return false;
  141. }
  142. });
  143. }
  144. function selectCompany(e) {
  145. localStorage.loginAccountId = e.key;
  146. localStorage.currentCompany = JSON.stringify(e);
  147. store.state.loginAccountId = e.key;
  148. store.commit("login", cache.value);
  149. }
  150. function goBeian() {
  151. window.open("https://beian.miit.gov.cn/");
  152. }
  153. </script>
  154. <style scoped>
  155. .container {
  156. width: 100%;
  157. height: 100%;
  158. background-image: url(../../assets/login-back.png);
  159. background-size: cover;
  160. }
  161. .login-box {
  162. position: relative;
  163. display: flex;
  164. top: calc(50% - 255px);
  165. left: calc(50% - 478px);
  166. width: 966px;
  167. height: 508px;
  168. border-radius: 10px;
  169. overflow: hidden;
  170. }
  171. .left {
  172. height: 100%;
  173. width: 450px;
  174. background-image: url(../../assets/login-modal.png);
  175. }
  176. .left-up-icon {
  177. width: 40px;
  178. height: 40px;
  179. border-radius: 50%;
  180. margin: 24px;
  181. background-image: url(../../assets/logo.png);
  182. background-size: contain;
  183. }
  184. .right {
  185. height: 100%;
  186. width: 516px;
  187. background: #fff;
  188. }
  189. .title {
  190. width: 384px;
  191. height: 38px;
  192. display: flex;
  193. margin: 0 auto;
  194. margin-top: 100px;
  195. }
  196. .title-left {
  197. height: 38px;
  198. width: 105px;
  199. 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);
  200. background-size: contain;
  201. background-repeat: no-repeat;
  202. }
  203. .title-mid {
  204. font-size: 25px;
  205. color: #e4e4e4;
  206. margin: 0 12px;
  207. }
  208. .title-right {
  209. font-size: 22px;
  210. font-family: Adobe Heiti Std;
  211. font-weight: normal;
  212. color: #434343;
  213. line-height: 38px;
  214. }
  215. .form-container {
  216. margin: 0 auto;
  217. margin-top: 60px;
  218. width: 384px;
  219. }
  220. .copyright {
  221. position: absolute;
  222. width: 100vw;
  223. bottom: 70px;
  224. text-align: center;
  225. font-family: PingFang SC;
  226. font-weight: 400;
  227. color: #aaa;
  228. opacity: 0.8;
  229. cursor: pointer;
  230. }
  231. </style>