login.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <div class="bg">
  3. <!-- <div class="content">
  4. <img
  5. src="../assets/login/logo_new.png"
  6. style="position: relative;
  7. left: 50%;transform: translate(-50%);"
  8. />
  9. <p style="color: #666;font-size: 16px; margin-bottom: 20px;">请用管理员账号密码登录</p>
  10. <el-form :model="ruleForm" :rules="rules" ref="ruleForm">
  11. <el-form-item prop="loginName">
  12. <el-input placeholder="请输入账号" clearable v-model="ruleForm.loginName"></el-input>
  13. </el-form-item>
  14. <el-form-item prop="loginPwd">
  15. <el-input placeholder="请输入密码" show-password clearable v-model="ruleForm.loginPwd"></el-input>
  16. </el-form-item>
  17. </el-form>
  18. <el-button type="primary" style="width:100%;" @click="login">登录</el-button>
  19. </div>-->
  20. <div class="login_main">
  21. <div class="login_main_left"></div>
  22. <div class="login_main_right">
  23. <div class="login_box">
  24. <div class="login_box_top">系 统 登 录</div>
  25. <div class="login_box_main">
  26. <el-form :model="ruleForm" :rules="rules" ref="ruleForm">
  27. <el-form-item prop="loginName">
  28. <el-input placeholder="账号" clearable v-model="ruleForm.loginName"></el-input>
  29. </el-form-item>
  30. <el-form-item prop="loginPwd">
  31. <el-input placeholder="密码" show-password clearable v-model="ruleForm.loginPwd"></el-input>
  32. </el-form-item>
  33. </el-form>
  34. <el-button
  35. type="primary"
  36. style="width:100%;margin-top: 10%"
  37. @click="login"
  38. :loading="logining"
  39. >登录</el-button>
  40. </div>
  41. <div class="login_box_foot">
  42. 技术支持:
  43. <span style="margin-right: 3%;color: #409EFF">盛创科技</span>联系电话:
  44. <span style="color: #409EFF">17004319000</span>
  45. </div>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. </template>
  51. <script>
  52. import { userLogin } from "../api";
  53. import storageUtil from "../util/storageUtil";
  54. export default {
  55. data() {
  56. return {
  57. ruleForm: {
  58. loginName: "",
  59. loginPwd: ""
  60. }, //表单数据
  61. rules: {
  62. loginName: [
  63. { required: true, message: "请输入账号", trigger: "change" }
  64. ],
  65. loginPwd: [{ required: true, message: "请输入密码", trigger: "change" }]
  66. }
  67. };
  68. },
  69. methods: {
  70. login() {
  71. this.$refs["ruleForm"].validate(valid => {
  72. if (valid) {
  73. this.loginSussess();
  74. } else {
  75. console.log("error submit!!");
  76. return false;
  77. }
  78. });
  79. },
  80. async loginSussess() {
  81. const result = await userLogin(
  82. {
  83. loginName: this.ruleForm.loginName,
  84. pwd: this.$md5(this.ruleForm.loginPwd)
  85. },
  86. `POST`
  87. );
  88. if (result.code == 0) {
  89. storageUtil.save("userInfo", result.data);
  90. storageUtil.save("name", this.ruleForm.loginName);
  91. storageUtil.save("pwd", this.$md5(this.ruleForm.loginPwd));
  92. console.log(storageUtil.read("userInfo"), "我存了吗");
  93. console.log(storageUtil.read("name"), "我存了吗");
  94. console.log(storageUtil.read("pwd"));
  95. this.$router.push("/home/home");
  96. } else {
  97. this.$message.error("登录失败,请核对账号和密码");
  98. }
  99. //this.$router.push('/home/home')
  100. // this.logining = true;
  101. // let result = await userLogin({
  102. // loginName: this.formData.loginName,
  103. // loginPwd: this.$md5(this.formData.loginPwd)
  104. // });
  105. // this.logining = false;
  106. // if (result.code == 0) {
  107. // this.storageUtil.save("sessionId", result.data);
  108. // this.$router.replace("/home");
  109. // if (this.formData.loginPwd === this.$dict.defaultPassword) {
  110. // const h = this.$createElement;
  111. // this.$notify({
  112. // title: '提示',
  113. // message: h('b',
  114. // '当前密码为初始密码,为了信息采集的安全,请尽快修改密码!'),
  115. // type: 'warning',
  116. // position: 'bottom-right',
  117. // duration: 0
  118. // });
  119. // }
  120. // }
  121. },
  122. GetQueryString(name) {
  123. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  124. var r = window.atob(window.location.search.substr(1)).match(reg); //search,查询?后面的参数,并匹配正则
  125. console.log(r);
  126. if (r != null) return unescape(r[2]);
  127. return null;
  128. }
  129. },
  130. mounted() {
  131. console.log(this.GetQueryString("name"), "我是带过来的账号");
  132. console.log(this.GetQueryString("password"), "我是带过来的密码");
  133. var name = this.GetQueryString("name");
  134. var password = this.GetQueryString("password");
  135. if (name != null && password != null) {
  136. this.ruleForm = {
  137. loginName: name,
  138. loginPwd: password
  139. };
  140. this.loginSussess();
  141. }
  142. }
  143. };
  144. </script>
  145. <style scoped>
  146. .bg {
  147. height: 100vh;
  148. background: url("../../src/assets/login/login_bg.png") no-repeat;
  149. background-size: 100% 100%;
  150. }
  151. .login_main {
  152. position: absolute;
  153. width: 58.4375vw;
  154. height: 31.0416vw;
  155. top: 50%;
  156. left: 50%;
  157. transform: translate(-50%, -50%);
  158. display: flex;
  159. background: #ffffff;
  160. box-shadow: 0 3px 25px 2px rgba(41, 125, 236, 0.2);
  161. }
  162. .login_main_left {
  163. flex: 4;
  164. background: url("../../src/assets/login/old.png") no-repeat;
  165. background-size: 100% 100%;
  166. }
  167. .login_main_right {
  168. flex: 6;
  169. position: relative;
  170. }
  171. .login_box {
  172. width: 65%;
  173. height: 80%;
  174. position: absolute;
  175. left: 50%;
  176. bottom: 8%;
  177. transform: translateX(-50%);
  178. display: flex;
  179. flex-direction: column;
  180. text-align: center;
  181. }
  182. .login_box_top {
  183. flex: 2;
  184. font-size: 1.875vw;
  185. font-weight: bold;
  186. color: #484848;
  187. }
  188. .login_box_main {
  189. flex: 7;
  190. }
  191. .login_box_foot {
  192. flex: 1;
  193. font-size: 0.8333vw;
  194. font-weight: 400;
  195. color: #484848;
  196. }
  197. .el-form-item >>> .el-input__inner {
  198. height: 2.76vw;
  199. line-height: 2.76vw;
  200. background: #f1f8fd;
  201. border-radius: 1.354vw;
  202. font-size: 1.0416vw;
  203. }
  204. .el-button--primary {
  205. height: 3.333vw;
  206. background: #5f9bff;
  207. border-radius: 1.666vw;
  208. font-size: 1.302vw;
  209. font-weight: 400;
  210. color: #ffffff;
  211. }
  212. </style>