Login.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <template>
  2. <div class="login-all">
  3. <div class="login-haed">
  4. <div class="img-logo">
  5. <div class="logos">
  6. <img src="../assets/logo2.png" />
  7. </div>
  8. <div class="names">PAN-AMERICAN INTERNATIONAL</div>
  9. </div>
  10. <div class="help-box">
  11. <div class="help-title">没有企业账户?</div>
  12. <router-link class="help-btn" :to="{path:'/Enroll'}">去注册</router-link>
  13. <!-- <div class="help-btn">去注册</div> -->
  14. </div>
  15. </div>
  16. <div class="login-dominant">
  17. <div class="login-box">
  18. <div class="login-title">泛美OA办公系统</div>
  19. <div class="login-input">
  20. <el-input @keyup.enter.native="Login()" class="accounts" placeholder="请输入您的账户" v-model="usernum">
  21. <i slot="prefix" class="iconfont el-input__icon icon-zhanghu"></i>
  22. </el-input>
  23. <el-input @keyup.enter.native="Login()" class="passwords" placeholder="请输入您的密码" show-password v-model="password">
  24. <i slot="prefix" class="iconfont el-input__icon icon-mima"></i>
  25. </el-input>
  26. <div class="el-input remembers">
  27. <div class="el-input-box">
  28. <input id="ckxjz" v-model="msgs" type="checkbox">
  29. <span class="two" @click="ckxclick"></span>
  30. <label for="ckxjz">记住账户</label>
  31. </div>
  32. <!-- <div class="fotger-pass">
  33. 忘记密码?
  34. </div> -->
  35. </div>
  36. <div class="loginbtn-box">
  37. <el-button @click="Login()" class="loginbtn"
  38. v-loading.fullscreen.lock="fullscreenLoading" round>登 录</el-button>
  39. </div>
  40. </div>
  41. <div></div>
  42. </div>
  43. </div>
  44. <div class="fout-box">
  45. PAN-AMERICAN INTERNATIONAL OA AI SYSTEM<br>
  46. © 2024 PAN-AMERICAN INTERNATIONAL CORPOPATION. ALL Rights Reserved.
  47. </div>
  48. </div>
  49. </template>
  50. <script>
  51. import Vuex from 'vuex';
  52. import { mapMutations, mapActions } from 'vuex'
  53. export default {
  54. ...mapMutations(['setphone']),//引入保存phone数据方法
  55. data() {
  56. return {
  57. usernum: '',
  58. password: '',
  59. msgs: false,
  60. fullscreenLoading: false
  61. }
  62. },
  63. methods: {
  64. ...mapActions(['vlogin']),
  65. //记住账户click
  66. ckxclick() {
  67. if (this.msgs == true) {
  68. this.msgs = false;
  69. } else {
  70. this.msgs = true;
  71. }
  72. },
  73. //记住密码存cookie
  74. setUserInfo() {
  75. var vm = this;
  76. // 判断用户是否勾选记住密码,如果勾选,向cookie中储存登录信息,
  77. // 如果没有勾选,储存的信息为空
  78. console.log(vm.msgs)
  79. if (vm.msgs) {
  80. vm.$cookie.set("userName", vm.usernum,7);
  81. vm.$cookie.set("userPwd", vm.password,7);
  82. vm.$cookie.set("checked", vm.msgs,7);
  83. } else {
  84. vm.$cookie.set("userName", "");
  85. vm.$cookie.set("userPwd", "");
  86. vm.$cookie.set("checked","");
  87. }
  88. },
  89. //记住密码存cookie
  90. getUserInfo() {
  91. this.usernum=this.$cookie.get('userName');
  92. this.password=this.$cookie.get('userPwd');
  93. this.msgs=this.$cookie.get('checked');
  94. },
  95. keyd(e){
  96. let that = this
  97. e = window.event || e
  98. //保证是在登录页面发出的enter事件
  99. if (e.code === 'Enter' || e.code === 'enter' || e.code === 'NumpadEnter') {
  100. //调用登录函数
  101. that.Login();
  102. }
  103. },
  104. //登录
  105. Login() {
  106. // if (this.usernum!='051') {
  107. // return this.$message({
  108. // message: "oa系统整改",
  109. // type: 'warning'
  110. // });
  111. // }
  112. var homepage = "";
  113. if (this.usernum == "" || this.password == "") {
  114. this.$message({
  115. message: "请填写账号密码!",
  116. type: 'warning'
  117. });
  118. return false;
  119. }
  120. this.fullscreenLoading = true;
  121. var url = "/api/login"
  122. var that = this
  123. this.$axios({
  124. method: 'post',
  125. url: url,
  126. data: {
  127. number: this.usernum,
  128. password: this.password
  129. }
  130. }).then(function (res) {
  131. console.log(res);
  132. if (res.data.code == 200) {
  133. window.removeEventListener('keydown',that.keyd,false);
  134. localStorage.setItem('userinif', JSON.stringify(res.data.data));
  135. localStorage.setItem('unReadCount', JSON.stringify(res.data.data.unReadCount));
  136. that.fullscreenLoading = false;
  137. for (var l = 0; l < res.data.data.authData.length; l++) {
  138. if (res.data.data.authData[l].modulName == '主页') {
  139. homepage = res.data.data.authData[l].pageList[0].webUrl
  140. localStorage.setItem("indexs", res.data.data.authData[l].modulid + '-' + res.data.data.authData[l].pageList[0].pageid);
  141. localStorage.setItem("innhtml", res.data.data.authData[l].pageList[0].pageName);
  142. }
  143. }
  144. that.$router.push({ path: "/home" + homepage });
  145. that.setUserInfo();
  146. console.log("/home" + homepage);
  147. // that.$router.push('/home/index');
  148. } else {
  149. that.fullscreenLoading = false;
  150. that.$message({
  151. message: res.data.msg,
  152. type: 'warning'
  153. });
  154. }
  155. })
  156. }
  157. },
  158. mounted() {
  159. console.log(process.env.API_HOST);
  160. document.querySelector(".login-all").style.height = window.innerHeight + "px";
  161. this.getUserInfo();
  162. window.addEventListener('keydown',this.keyd);
  163. }
  164. }
  165. </script>
  166. <style>
  167. .login-all .fout-box {
  168. width: 100%;
  169. text-align: center;
  170. background-color: #0008;
  171. padding: 20px;
  172. color: #fff;
  173. line-height: 34px;
  174. position: fixed;
  175. bottom:0px;
  176. font-size: 14px;
  177. }
  178. #ckxjz {
  179. cursor: pointer;
  180. opacity: 0;
  181. }
  182. #ckxjz[type=checkbox]+span {
  183. display: inline-block;
  184. border-radius: 2px;
  185. width: 15px;
  186. height: 15px;
  187. border: 1px solid #FFF;
  188. background-color: transparent;
  189. position: absolute;
  190. left: 5px;
  191. top: 3px;
  192. cursor: pointer;
  193. }
  194. #ckxjz[type=checkbox]:checked+span::after {
  195. content: '\2714';
  196. color: #fff;
  197. position: absolute;
  198. font-size: 20px;
  199. left: 2px;
  200. bottom: -2px;
  201. }
  202. .login-all {
  203. background-image: url("../../static/bj111.jpg");
  204. background-repeat: no-repeat;
  205. background-size: 100% 100%;
  206. }
  207. .login-haed {
  208. padding: 50px 100px;
  209. display: flex;
  210. justify-content: space-between;
  211. }
  212. .img-logo {
  213. display: flex;
  214. align-items: center;
  215. }
  216. .logos {
  217. color: #fff;
  218. font-size: 48px;
  219. font-weight: 600;
  220. font-family: fangsong;
  221. width: 80px;
  222. height: 80px;
  223. }
  224. .logos img {
  225. width: 100%;
  226. }
  227. .names {
  228. color: #fff;
  229. margin-left: 20px;
  230. font-size: 24px;
  231. font-weight: 600;
  232. font-family: fangsong;
  233. }
  234. .help-box {
  235. display: flex;
  236. align-items: center;
  237. }
  238. .help-title {
  239. color: #fff;
  240. }
  241. .help-btn {
  242. margin-left: 20px;
  243. color: #1DA3D8;
  244. }
  245. .el-input-box{
  246. margin-left: 5px;
  247. }
  248. .login-box {
  249. width: 400px;
  250. height: 300px;
  251. background-color: rgba(26, 30, 42, 0.7);
  252. /*background-color: rgba(42,53,88);*/
  253. margin: 0 auto;
  254. border-radius: 20px;
  255. padding: 20px 50px;
  256. margin-top: 120px;
  257. }
  258. .login-title {
  259. color: #fff;
  260. font-size: 24px;
  261. font-weight: 600;
  262. text-align: center;
  263. margin-top: 10px;
  264. margin-bottom: 20px;
  265. }
  266. .icon-mima {
  267. font-weight: 600;
  268. }
  269. .icon-zhanghu {
  270. color: #1DA3D8;
  271. }
  272. .icon-mima {
  273. color: #1DA3D8;
  274. }
  275. .login-dominant .login-box .login-input .remembers {
  276. display: flex;
  277. justify-content: space-between;
  278. align-items: center;
  279. }
  280. .fotger-pass {
  281. color: #1DA3D8;
  282. }
  283. .loginbtn {
  284. background-color: transparent;
  285. color: #1DA3D8;
  286. border: 1px solid #1DA3D8;
  287. }
  288. .loginbtn-box {
  289. text-align: center;
  290. padding: 25px;
  291. }
  292. body {
  293. margin: 0;
  294. padding: 0;
  295. }
  296. .login-all .login-input .el-input input {
  297. border-radius: 20px;
  298. background-color: transparent;
  299. color: #fff;
  300. }
  301. .login-all .loginbtn-box .el-button.is-round {
  302. border-radius: 25px;
  303. padding: 12px 50px;
  304. font-size: 20px;
  305. }
  306. .login-all .login-input .el-input {
  307. margin-top: 20px;
  308. }
  309. .login-all .el-input label {
  310. color: #fff;
  311. }
  312. .login-all .login-input .el-input__prefix {
  313. width: 40px;
  314. }
  315. .login-all .login-input .el-input--prefix .el-input__inner {
  316. padding-left: 50px;
  317. }
  318. @media (max-height:760px) {
  319. .fout-box{
  320. display: none;
  321. }
  322. }
  323. </style>