Login.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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 © 2021 河南省汇很多科技有限公司 豫ICP备 2021029101 号
  71. </div>
  72. </div>
  73. </template>
  74. <script>
  75. import { ref, reactive, toRefs } 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. cargoOwnerId: 31,
  114. });
  115. if (res.data.status == 0) {
  116. ElNotification.success({
  117. title: "成功",
  118. duration: 2000,
  119. message: res.data.msg,
  120. type: "success",
  121. });
  122. let {
  123. userId,
  124. userName,
  125. phone,
  126. contactName,
  127. loginAccountId,
  128. rolePermission,
  129. } = res.data.result;
  130. localStorage.setItem("userId", userId);
  131. localStorage.setItem("userName", userName);
  132. localStorage.setItem("phone", phone);
  133. localStorage.setItem("contactName", contactName);
  134. localStorage.setItem("userType", 1);
  135. localStorage.setItem("loginAccountId", loginAccountId);
  136. rolePermission = rolePermission || [];
  137. let arr = [...new Set([...rolePermission, "VOYAGELIST"])];
  138. localStorage.setItem("rolePermission", arr);
  139. store.commit("changeLogin", true);
  140. store.dispatch(
  141. "GetBasePermissionData",
  142. localStorage.loginAccountId
  143. );
  144. store.dispatch("GetUserPermission", localStorage.loginAccountId);
  145. router.replace({ path: "/voyage/voyageList" });
  146. } else {
  147. ElNotification.error({
  148. title: "错误",
  149. duration: 3000,
  150. message: res.data.msg,
  151. });
  152. }
  153. } else {
  154. console.log("error submit!!");
  155. return false;
  156. }
  157. });
  158. }
  159. function goBeian() {
  160. window.open("https://beian.miit.gov.cn/");
  161. }
  162. return {
  163. form,
  164. ...toRefs(ruleForm),
  165. ...toRefs(rules),
  166. login,
  167. goBeian,
  168. };
  169. },
  170. };
  171. </script>
  172. <style scoped>
  173. .container {
  174. width: 100%;
  175. height: 100%;
  176. background-image: url(../../assets/login-back.png);
  177. background-size: cover;
  178. }
  179. .login-box {
  180. position: relative;
  181. display: flex;
  182. top: calc(50% - 255px);
  183. left: calc(50% - 478px);
  184. width: 966px;
  185. height: 508px;
  186. border-radius: 10px;
  187. overflow: hidden;
  188. }
  189. .left {
  190. height: 100%;
  191. width: 450px;
  192. background-image: url(../../assets/login-modal.png);
  193. }
  194. .left-up-icon {
  195. width: 40px;
  196. height: 40px;
  197. border-radius: 50%;
  198. margin: 24px;
  199. background-image: url(../../assets/logo.png);
  200. background-size: contain;
  201. }
  202. .right {
  203. height: 100%;
  204. width: 516px;
  205. background: #fff;
  206. }
  207. .title {
  208. width: 384px;
  209. height: 38px;
  210. display: flex;
  211. margin: 0 auto;
  212. margin-top: 100px;
  213. }
  214. .title-left {
  215. height: 38px;
  216. background: url(https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/web-static/wuchan3.jpg);
  217. background-size: contain;
  218. background-repeat: no-repeat;
  219. line-height: 38px;
  220. padding-left: 46px;
  221. font-size: 22px;
  222. }
  223. .title-mid {
  224. font-size: 25px;
  225. color: #e4e4e4;
  226. }
  227. .title-right {
  228. font-size: 28px;
  229. font-family: Adobe Heiti Std;
  230. font-weight: normal;
  231. color: #434343;
  232. line-height: 38px;
  233. }
  234. .form-container {
  235. margin: 0 auto;
  236. margin-top: 60px;
  237. width: 384px;
  238. }
  239. .copyright {
  240. position: absolute;
  241. width: 520px;
  242. bottom: 70px;
  243. left: calc(50% - 250px);
  244. font-family: PingFang SC;
  245. font-weight: 400;
  246. color: #aaa;
  247. opacity: 0.8;
  248. cursor: pointer;
  249. }
  250. </style>