Login.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  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-AMEPICAN 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">泛美国际 - AI智能办公系统</div>
  19. <div class="login-input">
  20. <el-input @keyup.enter.native="Login()" class="accounts" placeholder="请输入您的账户" v-model="usernum">
  21. <i slot="prefix" class="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="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 AMEPICAN INTERNATIONAL OA AI SYSTEM<br>
  46. © 2023 PAN AMEPICAN 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. //登录
  96. Login() {
  97. var homepage = "";
  98. if (this.usernum == "" || this.password == "") {
  99. this.$message({
  100. message: "请填写账号密码!",
  101. type: 'warning'
  102. });
  103. return false;
  104. }
  105. this.fullscreenLoading = true;
  106. var url = "/api/login"
  107. var that = this
  108. this.$axios({
  109. method: 'post',
  110. url: url,
  111. data: {
  112. number: this.usernum,
  113. password: this.password
  114. }
  115. }).then(function (res) {
  116. console.log(res);
  117. if (res.data.code == 200) {
  118. localStorage.setItem('userinif', JSON.stringify(res.data.data));
  119. that.fullscreenLoading = false;
  120. for (var l = 0; l < res.data.data.authData.length; l++) {
  121. if (res.data.data.authData[l].modulName == '主页') {
  122. homepage = res.data.data.authData[l].pageList[0].webUrl
  123. localStorage.setItem("indexs", res.data.data.authData[l].modulid + '-' + res.data.data.authData[l].pageList[0].pageid);
  124. localStorage.setItem("innhtml", res.data.data.authData[l].pageList[0].pageName);
  125. }
  126. }
  127. that.$router.push({ path: "/home" + homepage });
  128. that.setUserInfo();
  129. console.log("/home" + homepage)
  130. // that.$router.push('/home/index');
  131. } else {
  132. that.fullscreenLoading = false;
  133. that.$message({
  134. message: res.data.msg,
  135. type: 'warning'
  136. });
  137. }
  138. })
  139. }
  140. },
  141. mounted() {
  142. console.log(process.env.API_HOST);
  143. document.querySelector(".login-all").style.height = window.innerHeight + "px";
  144. this.getUserInfo();
  145. let that = this
  146. document.onkeydown = function (e) {
  147. e = window.event || e
  148. //保证是在登录页面发出的enter事件
  149. if (e.code === 'Enter' || e.code === 'enter' || e.code === 'NumpadEnter') {
  150. //调用登录函数
  151. that.Login();
  152. }
  153. }
  154. }
  155. }
  156. </script>
  157. <style scoped>
  158. .fout-box {
  159. width: 100%;
  160. text-align: center;
  161. background-color: #0008;
  162. padding: 20px;
  163. color: #fff;
  164. line-height: 34px;
  165. position: fixed;
  166. bottom: 0;
  167. font-size: 14px;
  168. }
  169. #ckxjz {
  170. cursor: pointer;
  171. opacity: 0;
  172. }
  173. #ckxjz[type=checkbox]+span {
  174. display: inline-block;
  175. border-radius: 2px;
  176. width: 15px;
  177. height: 15px;
  178. border: 1px solid #FFF;
  179. background-color: transparent;
  180. position: absolute;
  181. left: 0px;
  182. top: 3px;
  183. cursor: pointer;
  184. }
  185. #ckxjz[type=checkbox]:checked+span::after {
  186. content: '\2714';
  187. color: #fff;
  188. position: absolute;
  189. font-size: 20px;
  190. left: 2px;
  191. bottom: -2px;
  192. }
  193. .login-all {
  194. background-image: url("../assets/back.png");
  195. background-repeat: no-repeat;
  196. background-size: 100% 100%;
  197. }
  198. .login-haed {
  199. padding: 50px 100px;
  200. display: flex;
  201. justify-content: space-between;
  202. }
  203. .img-logo {
  204. display: flex;
  205. align-items: center;
  206. }
  207. .logos {
  208. color: #fff;
  209. font-size: 48px;
  210. font-weight: 600;
  211. font-family: fangsong;
  212. width: 80px;
  213. height: 80px;
  214. }
  215. .logos img {
  216. width: 100%;
  217. }
  218. .names {
  219. color: #fff;
  220. margin-left: 20px;
  221. font-size: 24px;
  222. font-weight: 600;
  223. font-family: fangsong;
  224. }
  225. .help-box {
  226. display: flex;
  227. align-items: center;
  228. }
  229. .help-title {
  230. color: #fff;
  231. }
  232. .help-btn {
  233. margin-left: 20px;
  234. color: #1DA3D8;
  235. }
  236. .login-box {
  237. width: 400px;
  238. height: 300px;
  239. background-color: rgba(26, 30, 42, 0.7);
  240. /*background-color: rgba(42,53,88);*/
  241. margin: 0 auto;
  242. border-radius: 20px;
  243. padding: 20px 50px;
  244. margin-top: 120px;
  245. }
  246. .login-title {
  247. color: #fff;
  248. font-size: 24px;
  249. font-weight: 600;
  250. text-align: center;
  251. margin-top: 10px;
  252. margin-bottom: 20px;
  253. }
  254. .icon-mima {
  255. font-weight: 600;
  256. }
  257. .icon-zhanghu {
  258. color: #1DA3D8;
  259. }
  260. .icon-mima {
  261. color: #1DA3D8;
  262. }
  263. .remembers {
  264. display: flex;
  265. justify-content: space-between;
  266. align-items: center;
  267. }
  268. .fotger-pass {
  269. color: #1DA3D8;
  270. }
  271. .loginbtn {
  272. background-color: transparent;
  273. color: #1DA3D8;
  274. border: 1px solid #1DA3D8;
  275. }
  276. .loginbtn-box {
  277. text-align: center;
  278. padding: 25px;
  279. }
  280. </style>
  281. <style >
  282. body {
  283. margin: 0;
  284. padding: 0;
  285. }
  286. .login-input .el-input input {
  287. border-radius: 20px;
  288. background-color: transparent;
  289. color: #fff;
  290. }
  291. .loginbtn-box .el-button.is-round {
  292. border-radius: 25px;
  293. padding: 12px 50px;
  294. font-size: 20px;
  295. }
  296. .login-input .el-input {
  297. margin-top: 20px;
  298. }
  299. .el-input label {
  300. color: #fff;
  301. }
  302. .login-input .el-input__prefix {
  303. width: 40px;
  304. }
  305. .login-input .el-input--prefix .el-input__inner {
  306. padding-left: 50px;
  307. }
  308. /*.accounts{
  309. position: relative;
  310. }
  311. .accounts::after{
  312. content: "请输入您的账户";
  313. display: inline-block;
  314. position: absolute;
  315. color: #fff;
  316. left: 50px;
  317. top: -10px;
  318. background-color: rgba(42,53,88);
  319. /*background-image: url("../assets/zhedang.png");
  320. }
  321. .passwords{
  322. position: relative;
  323. }
  324. .passwords::after{
  325. content: "请输入您的密码";
  326. display: inline-block;
  327. position: absolute;
  328. color: #fff;
  329. left: 50px;
  330. top: -10px;
  331. background-color: rgba(42,53,88);
  332. /*background-image: url("../assets/zhedang.png");
  333. }*/
  334. </style>