项目原始demo,不改动
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
Bu depo arşivlendi. Dosyaları görüntüleyebilir ve klonlayabilirsiniz ama işlem gönderemez ve konu/değişiklik isteği açamazsınız.
 
 
 
 

566 satır
17 KiB

  1. <!--
  2. * @Description: 登录页面组件
  3. * @version: V1.0
  4. * @Author: xzx
  5. * @Date: 2019-11-04 17:22:44
  6. * @LastEditors : xzx
  7. * @LastEditTime : 2019-12-29 10:50:35
  8. -->
  9. <template>
  10. <div class="loginbox_warp" id="app">
  11. <!-- 登录背景动画 -->
  12. <iframe
  13. src="../../static/img/bgAnimate/bganimat.html"
  14. frameborder="0"
  15. style="width:100%;height:98%;width:calc(100vw);height:calc(100vh);position: absolute;top:0"
  16. class="login_bg"
  17. ></iframe>
  18. <div class="LoginTitleWel">
  19. <div class="logintitlefirst">
  20. <span>欢迎使用</span>
  21. <span>探索者协同</span>
  22. </div>
  23. </div>
  24. <!-- <div class="logoarea">
  25. <div class="loginimgboxa">
  26. <img src="/static/img/loginBox.svg" class="loginimgbordera" />
  27. <img src="/static/img/Logo/logoA.png" alt="" class="loginimgboxImga" />
  28. </div>
  29. </div>-->
  30. <div class="loginbox">
  31. <div>
  32. <!-- 第一次登录 -->
  33. <div v-show="loginShow == 0">
  34. <div class="login_formBox">
  35. <label class="loginlabel">验证身份</label>
  36. <label class="loginlabel">
  37. <i class="icon font_family icon-icon_fanhui combackreturn" v-on:click="returnLoign"></i>设置密码
  38. </label>
  39. <form class="formlogin">
  40. <div class="formlogin_item">
  41. <input type="text" name placeholder="请输入企业预留手机号或邮箱" class="login_input" />
  42. </div>
  43. <div class="formlogin_item">
  44. <input type="password" name placeholder="设置登入密码" class="login_input" />
  45. </div>
  46. <div class="formlogin_item">
  47. <input type="password" name placeholder="确认登入密码" class="login_input" />
  48. </div>
  49. </form>
  50. </div>
  51. <div>
  52. <button class="login_btn">下一步</button>
  53. <button class="login_btn">完成并登入</button>
  54. </div>
  55. </div>
  56. <!-- 以后登录 -->
  57. <div v-if="loginShow == 1">
  58. <div class="login_formBox">
  59. <label class="loginlabel">登入</label>
  60. <form class="formlogin">
  61. <div class="formlogin_item">
  62. <input
  63. type="text"
  64. name="username"
  65. placeholder="请输入企业预留手机号或邮箱"
  66. class="login_input"
  67. v-model="account"
  68. />
  69. </div>
  70. <div class="formlogin_item">
  71. <input
  72. type="password"
  73. name
  74. placeholder="输入登入密码"
  75. class="login_input"
  76. v-model="pwd"
  77. @keyup.enter="ToMain"
  78. />
  79. <a
  80. href="javascript:;"
  81. class="loginlabel_resit"
  82. v-on:click="backPassword"
  83. v-if="account != ''"
  84. >忘记密码</a>
  85. </div>
  86. <div class="worningalert" v-if="errTips == true">{{tipmgs}}</div>
  87. </form>
  88. </div>
  89. <el-checkbox v-model="isRemember" class="login_checkBox mt-10">记住密码</el-checkbox>
  90. <div>
  91. <button class="login_btn" @click="ToMain" @keyup.enter.native="ToMain">登入</button>
  92. <a class="login_btn_defualt" v-on:click="loginBackManage">切换至后台登入</a>
  93. </div>
  94. </div>
  95. <!--登录后台 -->
  96. <div v-if="loginShow == 2">
  97. <div class="login_formBox">
  98. <label class="loginlabel">登入后台</label>
  99. <form name="formName" class="formlogin">
  100. <div class="formlogin_item">
  101. <input
  102. type="text"
  103. name="inputName"
  104. value
  105. placeholder="请输入企业预留手机号或邮箱"
  106. class="login_input"
  107. v-model="account"
  108. />
  109. </div>
  110. <div class="formlogin_item">
  111. <input
  112. type="password"
  113. name
  114. placeholder="请输入登入密码"
  115. class="login_input"
  116. v-model="pwd"
  117. @keyup.enter="ToMain"
  118. />
  119. <a
  120. href="javascript:;"
  121. class="loginlabel_resit"
  122. v-on:click="backPassword"
  123. v-if="account != ''"
  124. >忘记密码</a>
  125. </div>
  126. <div class="worningalert" v-if="errTips == true">{{tipmgs}}</div>
  127. </form>
  128. </div>
  129. <el-checkbox v-model="isRemember" class="login_checkBox mt-10">记住密码</el-checkbox>
  130. <div>
  131. <button class="login_btn" @click="ToMain" @keyup.enter.native="ToMain">登入</button>
  132. <a class="login_btn_defualt" v-on:click="loginPage">切换至平台登入</a>
  133. </div>
  134. </div>
  135. <!-- 找回密码 -->
  136. <div v-if="loginShow == 3">
  137. <div class="login_formBox">
  138. <label class="loginlabel">
  139. <i class="icon font_family icon-icon_fanhui combackreturn" v-on:click="loginPage"></i>输入账号
  140. </label>
  141. <form class="formlogin">
  142. <input
  143. type="text"
  144. name
  145. placeholder="请输入企业预留手机号或邮箱"
  146. v-model="phoneNumber"
  147. class="login_input"
  148. />
  149. </form>
  150. </div>
  151. <div>
  152. <button class="login_btn" v-on:click="next">下一步</button>
  153. </div>
  154. </div>
  155. <!-- 找回密码第二步 -->
  156. <div v-if="loginShow == 4">
  157. <div class="login_formBox">
  158. <label class="loginlabel">
  159. <i class="icon font_family icon-icon_fanhui combackreturn" v-on:click="prev"></i>验证身份
  160. </label>
  161. <form class="formlogin">
  162. <div class="formlogin_item rightBtn_input">
  163. <input type="text" name placeholder="输入验证码" class="login_input" v-model="phoneCode" />
  164. <BtnSmsCode :phoneNum="phoneNumber" :checkPhoneNum="phoneNumber"></BtnSmsCode>
  165. </div>
  166. </form>
  167. </div>
  168. <div>
  169. <button class="login_btn" v-on:click="loginShow = 5">下一步</button>
  170. </div>
  171. </div>
  172. <!-- 找回密码第三步 -->
  173. <div v-if="loginShow == 5">
  174. <div class="login_formBox">
  175. <label class="loginlabel">
  176. <i class="icon font_family icon-icon_fanhui combackreturn" v-on:click="prev"></i>重制密码
  177. </label>
  178. <form class="formlogin">
  179. <div class="formlogin_item">
  180. <input
  181. type="text"
  182. name
  183. placeholder="输入新密码"
  184. class="login_input"
  185. v-model="firstNewPwd"
  186. />
  187. </div>
  188. <div class="formlogin_item">
  189. <input
  190. type="password"
  191. name
  192. placeholder="确认新密码"
  193. class="login_input"
  194. v-model="enterNewPwd"
  195. @input="checkPwd()"
  196. />
  197. <span class="yyerrtip">{{ checkPwdTip }}</span>
  198. <!-- //dhj 也可以内置在input里面,方法二选一吧 -->
  199. </div>
  200. </form>
  201. </div>
  202. <div>
  203. <button class="login_btn" v-on:click="returnLoign">重新登入</button>
  204. </div>
  205. </div>
  206. </div>
  207. </div>
  208. </div>
  209. </template>
  210. <style>
  211. .login_bg {
  212. width: 100%;
  213. height: 99%;
  214. }
  215. .login_checkBox .el-checkbox__inner {
  216. width: 16px;
  217. height: 16px;
  218. border-radius: 3px;
  219. }
  220. .login_checkBox .el-checkbox__inner::after {
  221. border: 1px solid #fff;
  222. border-top: 0;
  223. border-left: 0;
  224. height: 9px;
  225. left: 3px;
  226. top: 0px;
  227. width: 5px;
  228. }
  229. </style>
  230. <script>
  231. import BtnSmsCode from "./components/BtnSmsCode/BtnSmsCode.vue";
  232. export default {
  233. components: {
  234. BtnSmsCode
  235. },
  236. data() {
  237. return {
  238. filelist: [],
  239. login: true,
  240. regist: false,
  241. errTips: false,
  242. tipmgs: "",
  243. account: "",
  244. pwd: "",
  245. loginShow: 1,
  246. isBackground: false,
  247. phoneNumber: "", //手机号码
  248. firstNewPwd: "", //初次输入密码
  249. enterNewPwd: "", //确认密码
  250. checkPwdTip: "", //检测提示
  251. phoneCode: "", //手机验证码
  252. isRemember: false, //记住密码
  253. isClient: process.env.IS_CLIENT //是否是客户端
  254. };
  255. },
  256. beforeRouteLeave(to, from, next) {
  257. sessionStorage.login = from.name;
  258. next();
  259. },
  260. created: function() {
  261. sessionStorage.login = "";
  262. },
  263. mounted: function() {
  264. this.loadRemember();
  265. window["tipMsg"] = msg => {
  266. this.tipMsg(msg);
  267. };
  268. },
  269. methods: {
  270. /**
  271. * 提示信息
  272. */
  273. tipMsg(msg){
  274. this.$notify({
  275. title: "温馨提示",
  276. message: msg,
  277. type: "warning",
  278. offset: 100,
  279. duration: 3500
  280. });
  281. },
  282. /**
  283. * @description: 获取记住密码
  284. * @param {type}
  285. * @return:
  286. */
  287. loadRemember() {
  288. if (this.$cookie.get("remember")) {
  289. this.account = this.$cookie.get("account");
  290. this.pwd = this.$cookie.get("pwd");
  291. var backgroundValue = this.$cookie.get("background");
  292. if (backgroundValue == "false") {
  293. this.isBackground = false;
  294. }
  295. this.isRemember = true;
  296. }
  297. },
  298. /**
  299. * @description: 找回密码
  300. * @param {type}
  301. * @return:
  302. */
  303. backPassword: function() {
  304. this.loginShow = 3;
  305. },
  306. /**
  307. * @description: 上一步
  308. * @param {type}
  309. * @return:
  310. */
  311. prev: function() {
  312. this.loginShow = 3;
  313. },
  314. /**
  315. * @description: 下一步
  316. * @param {type}
  317. * @return:
  318. */
  319. next: function() {
  320. if (!/^1[3456789]\d{9}$/.test(this.phoneNumber)) {
  321. this.$notify({
  322. title: "温馨提示",
  323. message: "请检查手机号是否填写正确",
  324. type: "warning",
  325. offset: 100,
  326. duration: 2500
  327. });
  328. } else {
  329. this.checkPhone();
  330. }
  331. },
  332. /**
  333. * @description: 检测手机是否可用
  334. * @param {type}
  335. * @return:
  336. */
  337. checkPhone: function() {
  338. var thisApp = this;
  339. this.$axios({
  340. method: "get",
  341. url: encodeURI(
  342. process.env.API_HOST + "account/check/phone/" + thisApp.phoneNum
  343. ),
  344. params: { phone: thisApp.phoneNum }
  345. })
  346. .then(response => {
  347. if (response.data.state == 1) {
  348. thisApp.$notify({
  349. title: "温馨提示",
  350. type: "warning",
  351. message: response.data.message,
  352. offset: 100,
  353. duration: 2500
  354. });
  355. thisApp.loginShow = 4;
  356. } else {
  357. thisApp.$notify.error({
  358. title: "温馨提示",
  359. message: response.data.message,
  360. offset: 100,
  361. duration: 2500
  362. });
  363. }
  364. })
  365. .catch(error => {
  366. console.log(error);
  367. });
  368. },
  369. loginPage: function() {
  370. this.loginShow = 1;
  371. if(this.isBackground){
  372. this.isBackground = false;
  373. }else{
  374. this.isBackground = true;
  375. }
  376. },
  377. /**
  378. * @description:返回登录
  379. * @param {type}
  380. * @return:
  381. */
  382. returnLoign: function() {
  383. if (this.firstNewPwd != this.enterNewPwd) {
  384. this.$notify({
  385. title: "温馨提示",
  386. message: "您输入的两次密码不一致",
  387. type: "warning",
  388. offset: 100,
  389. duration: 2500
  390. });
  391. return;
  392. } else {
  393. var thisApp = this;
  394. this.$axios({
  395. method: "put",
  396. url: encodeURI(process.env.API_HOST + "account/pwd/phone"),
  397. data: {
  398. phone: thisApp.phoneNumber,
  399. code: thisApp.phoneCode,
  400. newPwd: thisApp.enterNewPwd
  401. }
  402. })
  403. .then(function(response) {
  404. if (response.data.state == 1) {
  405. thisApp.$notify({
  406. title: "温馨提示",
  407. type: "warning",
  408. message: response.data.message,
  409. offset: 100,
  410. duration: 2500
  411. });
  412. thisApp.firstNewPwd = "";
  413. thisApp.enterNewPwd = "";
  414. thisApp.phoneNumber = "";
  415. thisApp.phoneCode = "";
  416. thisApp.loginPage();
  417. } else {
  418. thisApp.$notify.error({
  419. title: "温馨提示",
  420. message: response.data.message,
  421. offset: 100,
  422. duration: 2500
  423. });
  424. }
  425. })
  426. .catch(function(error) {
  427. console.log(error);
  428. });
  429. }
  430. },
  431. /**
  432. * @description: 登录探索者后台
  433. * @param {type}
  434. * @return:
  435. */
  436. loginBackManage: function() {
  437. this.loginShow = 2;
  438. this.isBackground = true;
  439. },
  440. /**
  441. * @description: 系统登录
  442. * @param {type}
  443. * @return:
  444. */
  445. ToMain: function() {
  446. var thisApp = this;
  447. if (thisApp.account == "") {
  448. thisApp.errTips = true;
  449. thisApp.tipmgs = "请输入用户名!";
  450. return;
  451. }
  452. if (thisApp.pwd == "") {
  453. thisApp.errTips = true;
  454. thisApp.tipmgs = "请输入密码!";
  455. return;
  456. }
  457. var param = {
  458. userName: this.account,
  459. passWord: this.pwd,
  460. isBackground: this.isBackground
  461. };
  462. this.$axios({
  463. method: "post",
  464. url: encodeURI(process.env.API_HOST + "account/login"),
  465. data: param
  466. })
  467. .then(function(response) {
  468. var state = response.data.state;
  469. if (state === 1) {
  470. sessionStorage.userId = response.data.data.userID;
  471. sessionStorage.companyName = response.data.data.companyName;
  472. sessionStorage.companyId = response.data.data.companyID;
  473. sessionStorage.permission = response.data.data.permission;
  474. sessionStorage.backgroundPermission =
  475. response.data.data.backgroundPermission;
  476. sessionStorage.cnName = response.data.data.cnName;
  477. sessionStorage.userName = response.data.data.userName;
  478. sessionStorage.user = JSON.stringify(response.data.data);
  479. sessionStorage.token = response.data.data.token;
  480. sessionStorage.pageName = "index";
  481. if (thisApp.isRemember) {
  482. thisApp.$cookie.set("remember", true);
  483. thisApp.$cookie.set("account", thisApp.account);
  484. thisApp.$cookie.set("pwd", thisApp.pwd);
  485. thisApp.$cookie.set("background", thisApp.isBackground);
  486. } else {
  487. thisApp.$cookie.remove("remember");
  488. thisApp.$cookie.remove("account");
  489. thisApp.$cookie.remove("pwd");
  490. thisApp.$cookie.remove("background");
  491. }
  492. // 客户端启动服务
  493. if (thisApp.isClient) {
  494. var userName = sessionStorage.userName;
  495. if (
  496. sessionStorage.userName == null ||
  497. sessionStorage.userName == undefined ||
  498. sessionStorage.userName == ""
  499. ) {
  500. userName = response.data.data.phone;
  501. }
  502. back.startService(
  503. sessionStorage.userId,
  504. sessionStorage.companyId,
  505. userName,
  506. response.data.data.passWord
  507. );
  508. if (thisApp.isRemember) {
  509. thisApp.$cookie.set("remember", true, {expires: 7});
  510. thisApp.$cookie.set("account", thisApp.account, {expires: 7});
  511. thisApp.$cookie.set("pwd", thisApp.pwd, {expires: 7});
  512. thisApp.$cookie.set("background", thisApp.isBackground, {expires: 7});
  513. } else {
  514. thisApp.$cookie.remove("remember");
  515. thisApp.$cookie.remove("account");
  516. thisApp.$cookie.remove("pwd");
  517. thisApp.$cookie.remove("background");
  518. }
  519. }
  520. if (!thisApp.isBackground) {
  521. thisApp.$router.push({
  522. path: "/index"
  523. });
  524. } else {
  525. if (sessionStorage.backgroundPermission == 3) {
  526. thisApp.$router.push({
  527. path: "/system"
  528. });
  529. } else{
  530. thisApp.$router.push({
  531. path: "/company"
  532. });
  533. }
  534. }
  535. thisApp.$notify({
  536. title: "恭喜您",
  537. message: "登录成功!开始愉快的体验吧",
  538. type: "success",
  539. offset: 100,
  540. duration: 2500
  541. });
  542. } else {
  543. thisApp.errTips = true;
  544. thisApp.tipmgs = response.data.message;
  545. }
  546. })
  547. .catch(function(error) {
  548. console.log(error);
  549. });
  550. },
  551. /**
  552. * @description: 检测两次密码是否一致
  553. * @param {type}
  554. * @return:
  555. */
  556. checkPwd: function() {
  557. if (this.firstNewPwd != this.enterNewPwd) {
  558. this.checkPwdTip = "两次密码输入不一致";
  559. } else {
  560. this.checkPwdTip = "成功";
  561. }
  562. }
  563. }
  564. };
  565. </script>