Login.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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 v-slot:prepend>
  18. <el-button icon="el-icon-mobile-phone"></el-button>
  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 v-slot:prepend>
  29. <el-button icon="el-icon-lock"></el-button>
  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 class="df aic jcc" style="margin-top: 55px">
  50. <img
  51. style="height: 20px"
  52. src="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"
  53. alt=""
  54. />
  55. <div
  56. style="
  57. height: 20px;
  58. line-height: 18px;
  59. font-size: 10px;
  60. color: #999;
  61. margin-left: 15px;
  62. "
  63. >
  64. 汇很多智慧航运研发中心
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. <div @click="goBeian" class="copyright">
  70. Copyright © 2022 汇很多(江苏)科技有限公司 苏ICP备2022023253号-1 号
  71. </div>
  72. </div>
  73. </template>
  74. <script>
  75. import { ref, reactive, toRefs, computed } from "vue";
  76. import { ElNotification } from "element-plus";
  77. import store from "../../store";
  78. import router from "../../router";
  79. import md5 from "md5";
  80. import api from "../../apis/fetch";
  81. export default {
  82. setup() {
  83. const form = ref(null);
  84. const ruleForm = reactive({
  85. ruleForm: {
  86. phone: "",
  87. password: "",
  88. },
  89. });
  90. const rules = reactive({
  91. rules: {
  92. phone: [
  93. { required: true, message: "请输入手机号", trigger: "blur" },
  94. { min: 11, max: 11, message: "请正确输入手机号", trigger: "blur" },
  95. ],
  96. password: [
  97. { required: true, message: "请输入密码", trigger: "blur" },
  98. { min: 6, max: 20, message: "请正确输入手机号", trigger: "blur" },
  99. ],
  100. },
  101. });
  102. function check() {
  103. // form.value.validate((valid) => {});
  104. }
  105. function login() {
  106. form.value.validate(async (valid) => {
  107. if (valid) {
  108. let { phone, password } = ruleForm.ruleForm;
  109. let res = await api.staffLogin({
  110. phone,
  111. // password: md5(password).toUpperCase(),
  112. password,
  113. // proxyId: 31,
  114. });
  115. if (res.data.status == 0) {
  116. let {
  117. userId,
  118. userName,
  119. phone,
  120. contactName,
  121. loginAccountId,
  122. rolePermission,
  123. } = res.data.result;
  124. if (!rolePermission.length) {
  125. ElNotification.error({
  126. title: "失败",
  127. duration: 2000,
  128. message: "暂无权限,请联系管理员",
  129. type: "error",
  130. });
  131. return;
  132. }
  133. ElNotification.success({
  134. title: "成功",
  135. duration: 2000,
  136. message: res.data.msg,
  137. type: "success",
  138. });
  139. localStorage.setItem("userId", userId);
  140. localStorage.setItem("userName", userName);
  141. localStorage.setItem("phone", phone);
  142. localStorage.setItem("contactName", contactName);
  143. localStorage.setItem("userType", 1);
  144. localStorage.setItem("loginAccountId", loginAccountId);
  145. rolePermission = rolePermission || [];
  146. let arr = [...new Set([...rolePermission])];
  147. localStorage.setItem("rolePermission", arr);
  148. store.dispatch(
  149. "GetBasePermissionData",
  150. localStorage.loginAccountId
  151. );
  152. let res1 = await store.dispatch(
  153. "GetUserPermission",
  154. localStorage.loginAccountId
  155. );
  156. router.replace({ path: store.state.menuData[0]?.items[0].path });
  157. store.commit("changeLogin", true);
  158. } else {
  159. ElNotification.error({
  160. title: "错误",
  161. duration: 3000,
  162. message: res.data.msg,
  163. });
  164. }
  165. } else {
  166. console.log("error submit!!");
  167. return false;
  168. }
  169. });
  170. }
  171. function goBeian() {
  172. window.open("https://beian.miit.gov.cn/");
  173. }
  174. return {
  175. form,
  176. ...toRefs(ruleForm),
  177. ...toRefs(rules),
  178. login,
  179. goBeian,
  180. };
  181. },
  182. };
  183. </script>
  184. <style scoped>
  185. .container {
  186. width: 100%;
  187. height: 100%;
  188. background-image: url(../../assets/login-back.png);
  189. background-size: cover;
  190. }
  191. .login-box {
  192. position: relative;
  193. display: flex;
  194. top: calc(50% - 255px);
  195. left: calc(50% - 478px);
  196. width: 966px;
  197. height: 508px;
  198. border-radius: 10px;
  199. overflow: hidden;
  200. }
  201. .left {
  202. height: 100%;
  203. width: 450px;
  204. background-image: url(../../assets/login-modal.png);
  205. }
  206. .left-up-icon {
  207. width: 40px;
  208. height: 40px;
  209. border-radius: 50%;
  210. margin: 24px;
  211. background-image: url(../../assets/logo.png);
  212. background-size: contain;
  213. }
  214. .right {
  215. height: 100%;
  216. width: 516px;
  217. background: #fff;
  218. }
  219. .title {
  220. width: 384px;
  221. height: 38px;
  222. display: flex;
  223. margin: 0 auto;
  224. margin-top: 100px;
  225. }
  226. .title-left {
  227. height: 38px;
  228. /* background: url(https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/web-static/wuchan3.jpg); */
  229. background-size: contain;
  230. background-repeat: no-repeat;
  231. line-height: 38px;
  232. /* padding-left: 46px; */
  233. font-size: 22px;
  234. }
  235. .title-mid {
  236. font-size: 25px;
  237. color: #e4e4e4;
  238. }
  239. .title-right {
  240. font-size: 28px;
  241. font-family: Adobe Heiti Std;
  242. font-weight: normal;
  243. color: #434343;
  244. line-height: 38px;
  245. }
  246. .form-container {
  247. margin: 0 auto;
  248. margin-top: 60px;
  249. width: 384px;
  250. }
  251. .copyright {
  252. position: absolute;
  253. width: 100vw;
  254. bottom: 70px;
  255. text-align: center;
  256. font-family: PingFang SC;
  257. font-weight: 400;
  258. color: #aaa;
  259. opacity: 0.8;
  260. cursor: pointer;
  261. }
  262. </style>