register.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. <template>
  2. <div class="backdrop zap-login">
  3. <el-container>
  4. <!-- logo -->
  5. <img class="zap-logo" src="../assets/images/login/login_logo.png" alt="">
  6. <el-main>
  7. <!-- 中间部分 -->
  8. <div class="login">
  9. <div class="login-left">
  10. <img class="login-name" src="../assets/images/login/login_name.png" alt="">
  11. <img class="login-illustration" src="../assets/images/login/login_illustration.png" alt="">
  12. </div>
  13. <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form">
  14. <template v-if="!scanningLogin">
  15. <div class="zap-2dcode">
  16. <!-- <img class="zap-2dcode__text" src="../assets/images/code1_1.png" alt=""> -->
  17. <!-- <img class="zap-2dcode__img" src="../assets/images/code1_2.gif" alt="" @click="scanningLogin=true"> -->
  18. </div>
  19. <el-tabs v-model="activeName" class="zap-tabs" @tab-click="changeLoginType">
  20. <el-tab-pane label="验证码登录" name="login_shortMessage">
  21. <el-form-item prop="username">
  22. <el-input v-model="loginForm.username" type="text" auto-complete="off" placeholder="手机号">
  23. <svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" />
  24. </el-input>
  25. </el-form-item>
  26. <el-form-item prop="cade">
  27. <el-input v-model="loginForm.shortMessageCode" type="text" maxlength="" auto-complete="off" placeholder="请输入验证码" id="" onkeydown="enterHandler(event)">
  28. <svg-icon slot="prefix" icon-class="validCode" class="el-input__icon input-icon" />
  29. <el-button class="zap-code-button" slot="suffix" @click="sendMessage" :disabled="sendShortMessageBtn">{{codeBtnWord}}</el-button>
  30. </el-input>
  31. </el-form-item>
  32. <el-form-item style="width:100%;">
  33. <el-button :loading="loading" class="zap-button" size="medium" type="primary" @click.native.prevent="handleLogin">
  34. <span v-if="!loading">登 录</span>
  35. <span v-else>登 录 中...</span>
  36. </el-button>
  37. </el-form-item>
  38. <el-form-item>
  39. <div class="zap-agreement">
  40. <span class="zap-agreement__text">登录视为同意并遵守</span>
  41. <div class="zap-agreement__link">
  42. <span>《招采云链服务平台会员注册协议》</span>
  43. <span>《招采云链服务平台隐私政策》</span>
  44. </div>
  45. </div>
  46. </el-form-item>
  47. </el-tab-pane>
  48. </el-tabs>
  49. </template>
  50. </el-form>
  51. <!-- 底部 -->
  52. </div>
  53. </el-main>
  54. <el-dialog
  55. title="选择企业"
  56. :visible.sync="dialogVisible"
  57. width="30%">
  58. <el-select v-model="chooseCompanyId" placeholder="请选择">
  59. <el-option
  60. v-for="item in companyList"
  61. :key="item.scyId"
  62. :label="item.scyName"
  63. :value="item.scyId">
  64. </el-option>
  65. </el-select>
  66. <span slot="footer" class="dialog-footer">
  67. <el-button type="primary" @click="chooseLogin()">确 定</el-button>
  68. </span>
  69. </el-dialog>
  70. </el-container>
  71. <el-footer></el-footer>
  72. <!-- 密码登录验证码 -->
  73. <el-dialog
  74. title="验证码"
  75. :close-on-click-modal="false"
  76. :visible.sync="codeDialogVisible"
  77. width="30%">
  78. <div style="display:flex;">
  79. <el-input v-model="loginForm.code" auto-complete="off" placeholder="验证码" style="width: 53%;" @keyup.enter.native="handleLogin">
  80. <svg-icon slot="prefix" icon-class="validCode" class="el-input__icon input-icon" />
  81. </el-input>
  82. <div class="login-code">
  83. <img :src="codeUrl" @click="getCode" class="login-code-img" />
  84. </div>
  85. </div>
  86. <span slot="footer" class="dialog-footer">
  87. <el-button type="primary" @click="handleImgCodeSubmit">确 定</el-button>
  88. </span>
  89. </el-dialog>
  90. </div>
  91. </template>
  92. <script>
  93. import { getCodeImg, sendShortMessage, chooseCompanyLogin} from "@/api/login";
  94. import { wxImg } from "@/api/system/weChat";
  95. import Cookies from "js-cookie";
  96. import { encrypt, decrypt } from "@/utils/jsencrypt";
  97. import wxlogin from 'vue-wxlogin'
  98. export default {
  99. components: {
  100. wxlogin : wxlogin
  101. },
  102. name: "Login",
  103. data() {
  104. return {
  105. //默认背景图
  106. activeName: "login_shortMessage",
  107. baseImg: require('../assets/images/login/login_illustration.png'),
  108. BackgroundImg : require('../assets/images/login/login_illustration.png'),
  109. scanningLogin: false, // 是否扫码登陆
  110. logo: '',
  111. // baseLogo: require('../assets/images/lgo.png'),
  112. codeUrl: "",
  113. cookiePassword: "",
  114. loginForm: {
  115. shortMessageCode: '',
  116. username: "",
  117. password: "",
  118. rememberMe: false,
  119. code: "",
  120. uuid: "",
  121. unionId : "",
  122. type : "2"
  123. },
  124. codeBtnWord: '获取验证码', // 获取验证码按钮文字
  125. waitTime:2, // 获取验证码按钮失效时间
  126. loginRules: {
  127. username: [
  128. {
  129. required: true,
  130. trigger: "blur",
  131. message: "用户名不能为空",
  132. },
  133. ]
  134. },
  135. loading: false,
  136. redirect: undefined,
  137. wxSrc: require("../assets/images/wx1.png"),
  138. sendShortMessageBtn : false,
  139. dialogVisible : false,
  140. companyList : [],
  141. chooseCompanyId : '',
  142. codeDialogVisible: false
  143. };
  144. },
  145. watch: {
  146. $route: {
  147. handler: function (route) {
  148. this.redirect = route.query && route.query.redirect;
  149. },
  150. immediate: true,
  151. },
  152. },
  153. created() {
  154. this.getCode();
  155. this.getCookie();
  156. // this.getlistDomain();
  157. },
  158. methods: {
  159. changeImg(){
  160. this.wxSrc = require("../assets/images/wx.png")
  161. },
  162. returnImg(){
  163. this.wxSrc = require("../assets/images/wx1.png")
  164. },
  165. getCode() {
  166. getCodeImg().then((res) => {
  167. this.codeUrl = "data:image/gif;base64," + res.img;
  168. this.loginForm.uuid = res.uuid;
  169. });
  170. },
  171. getCookie() {
  172. const username = Cookies.get("username");
  173. const password = Cookies.get("password");
  174. const rememberMe = Cookies.get("rememberMe");
  175. this.loginForm = {
  176. username:
  177. username === undefined ? this.loginForm.username : username,
  178. password:
  179. password === undefined
  180. ? this.loginForm.password
  181. : decrypt(password),
  182. rememberMe:
  183. rememberMe === undefined ? false : Boolean(rememberMe),
  184. };
  185. },
  186. handleImgCodeSubmit () {
  187. if (this.activeName === 'login_password') {
  188. this.handleLogin()
  189. } else {
  190. this.sendMessage()
  191. }
  192. },
  193. handleLogin() {
  194. this.$refs.loginForm.validate((valid) => {
  195. if (valid) {
  196. this.loading = true;
  197. // 验证码不能为空
  198. if (this.loginForm.shortMessageCode == null || this.loginForm.shortMessageCode == "") {
  199. this.msgError("请输入短信验证码!");
  200. this.loading = false;
  201. return;
  202. }
  203. this.loginForm.unionId = this.getUrlKey("unionId");
  204. if (this.loginForm.unionId == null || this.loginForm.unionId == "") {
  205. this.msgError("微信unionId数据异常!");
  206. this.loading = false;
  207. return;
  208. }
  209. this.loginForm.type = "2";
  210. this.$store
  211. .dispatch("Login", this.loginForm)
  212. .then((data) => {
  213. console.log(data)
  214. if (data.code == "0") {
  215. console.log("未认证!")
  216. this.$router.push({ path: "/certification" });
  217. // 认证单个企业
  218. } else if (data.code == "1") {
  219. // 认证通过
  220. if (data.loginUser.sysUser.companyStatus == "00") {
  221. console.log(this.redirect,"AAAAA")
  222. // if(this.redirect == '/home'){
  223. // this.$router.push({ path: "/homePage"+this.redirect || "/" });
  224. // }else{
  225. // this.$router.push({ path: this.redirect || "/" });
  226. // }
  227. this.$router.push({ path: this.redirect || "/" });
  228. // 认证未通过
  229. } else {
  230. console.log("未认证通过!")
  231. this.$router.push({ path: "/certification" });
  232. }
  233. // 多加企业
  234. } else {
  235. this.companyList = data.companyList;
  236. this.chooseCompanyId = this.companyList[0].scyId;
  237. this.dialogVisible = true;
  238. }
  239. this.loading = false;
  240. })
  241. .catch(() => {
  242. this.loading = false;
  243. this.getCode();
  244. });
  245. }
  246. });
  247. },
  248. getUrlKey(name) {
  249. return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ""])[1].replace(/\+/g, '%20')) || null
  250. },
  251. changeLoginType(e){
  252. if (this.activeName === 'login_password') {
  253. this.loginRules.code = [
  254. {
  255. required: true,
  256. trigger: "change",
  257. message: "验证码不能为空",
  258. },
  259. ]
  260. } else {
  261. delete this.loginRules.code
  262. }
  263. this.getCode();
  264. },
  265. sendMessage(){
  266. this.$refs.loginForm.validate((valid) => {
  267. if (valid) {
  268. if (this.codeDialogVisible) {
  269. if (!this.loginForm.code) {
  270. this.loading = false
  271. return this.msgError("请输入验证码!");
  272. } else {
  273. this.codeDialogVisible = false
  274. }
  275. } else {
  276. return this.codeDialogVisible = true
  277. }
  278. // 调用获取短信验证码接口
  279. sendShortMessage(this.loginForm.username, this.loginForm.code, this.loginForm.uuid).then(response => {
  280. this.sendShortMessageBtn = true;
  281. this.msgSuccess("发送成功!");
  282. // 因为下面用到了定时器,需要保存this指向
  283. let that = this
  284. that.waitTime = 60;
  285. this.codeBtnWord = `${this.waitTime}s 后重新获取`
  286. let timer = setInterval(function(){
  287. if(that.waitTime>1){
  288. that.waitTime--
  289. that.codeBtnWord = `${that.waitTime}s 后重新获取`
  290. }else{
  291. clearInterval(timer)
  292. that.codeBtnWord = '获取验证码'
  293. that.waitTime = 60
  294. that.getCode();
  295. that.sendShortMessageBtn = false;
  296. }
  297. },1000)
  298. }).catch((response)=>{
  299. this.getCode();
  300. });
  301. }
  302. })
  303. },
  304. chooseLogin(){
  305. chooseCompanyLogin(this.chooseCompanyId).then(response => {
  306. if (response.code == "200") {
  307. // 认证通过
  308. if (response.data.sysUser.companyStatus == "00") {
  309. if(this.redirect == '/home'){
  310. this.$router.push({ path: "/homePage"+this.redirect || "/" });
  311. }else{
  312. this.$router.push({ path: this.redirect || "/" });
  313. }
  314. // this.$router.push({ path: this.redirect || "/" });
  315. // 认证未通过
  316. } else {
  317. console.log("未认证通过!")
  318. this.$router.push({ path: "/certification" });
  319. }
  320. }
  321. }).catch((response)=>{
  322. });
  323. }
  324. }
  325. };
  326. </script>
  327. <style rel="stylesheet/scss" lang="scss">
  328. // 大背景图
  329. .backdrop {
  330. padding-top: 100px;
  331. background-color: #ebf3ff;
  332. width: 100%;
  333. min-height: 100%;
  334. text-align: center;
  335. }
  336. .zap-login{
  337. .login {
  338. display: flex;
  339. justify-content: center;
  340. height: 100%;
  341. background-size: cover;
  342. }
  343. // 中间背景图
  344. .login-form {
  345. margin-left: 75px;
  346. border-radius: 6px;
  347. background-size: 935px 434px;
  348. background-repeat: no-repeat;
  349. margin-top: 40px;
  350. }
  351. // 输入框大小
  352. .el-input {
  353. height: 55px;
  354. width: 100%;
  355. background-image: linear-gradient(
  356. #fdfdfd,
  357. #fdfdfd),
  358. linear-gradient(
  359. #e7f0ff,
  360. #e7f0ff);
  361. background-blend-mode: normal,
  362. normal;
  363. input {
  364. height: 55px;
  365. width: 100%;
  366. font-size: 18px;
  367. }
  368. }
  369. .input-icon {
  370. height: 53px;
  371. width: 22px;
  372. margin-left: 14px;
  373. margin-right: 14px
  374. }
  375. .el-input--prefix .el-input__inner{
  376. padding-left: 50px;
  377. }
  378. .login-tip {
  379. font-size: 13px;
  380. text-align: center;
  381. }
  382. .el-form-item--medium .el-form-item__content{
  383. display: flex;
  384. align-items: center;
  385. }
  386. // 验证码
  387. .login-code {
  388. height: 55px;
  389. img {
  390. cursor: pointer;
  391. vertical-align: middle;
  392. }
  393. }
  394. .login-code-img {
  395. flex: 1;
  396. height: 55px;
  397. margin-left: 8px;
  398. }
  399. .rightulliimg{
  400. width: 860px;
  401. }
  402. .divider_left{
  403. margin-left: -40px;
  404. }
  405. // 内部供应链
  406. .zap-tabs{
  407. width: 410px;
  408. min-height: 480px;
  409. padding: 10px 48px 46px;
  410. box-sizing: border-box;
  411. background-image: linear-gradient(
  412. #ffffff,
  413. #ffffff),
  414. linear-gradient(
  415. #f3f3f3,
  416. #f3f3f3);
  417. .el-tabs__nav-wrap{
  418. padding: 0 12px;
  419. }
  420. .el-tabs__nav-wrap::after{
  421. height: 0;
  422. }
  423. .el-tabs__nav{
  424. width: 100%;
  425. }
  426. .el-tabs__item{
  427. height: 56px;
  428. line-height: 56px;
  429. font-size: 24px;
  430. color: #333333;
  431. &:nth-of-type(3){
  432. padding-left: 30px;
  433. }
  434. }
  435. .el-tabs__item.is-active{
  436. color: #0056eb;
  437. }
  438. .el-tabs__active-bar{
  439. background-color: #0056eb;
  440. }
  441. }
  442. .login-left{
  443. width: 704px;
  444. padding-top: 164px;
  445. .login-name{
  446. width: 515px;
  447. }
  448. .login-illustration{
  449. width: 704px;
  450. }
  451. }
  452. .zap-logo{
  453. position: absolute;
  454. top: 25px;
  455. left: 45px;
  456. width: 210px;
  457. height: 60px;
  458. }
  459. .zap-2dcode{
  460. display: flex;
  461. justify-content: flex-end;
  462. align-items: center;
  463. width: 410px;;
  464. padding-top: 10px;
  465. padding-right: 10px;
  466. font-size: 0;
  467. background-color: #ffffff;
  468. box-sizing: border-box;
  469. }
  470. .zap-2dcode__text{
  471. width: 113px;
  472. height: 28px;
  473. }
  474. .zap-2dcode__img{
  475. width: 60px;
  476. height: 61px;
  477. cursor: pointer;
  478. }
  479. .zap-button{
  480. margin-top: 25px;
  481. width: 100%;
  482. height: 55px;
  483. font-size: 18px;
  484. border-radius: 0;
  485. background-image: linear-gradient(
  486. #0056eb,
  487. #0056eb),
  488. linear-gradient(
  489. #e7f0ff,
  490. #e7f0ff);
  491. background-blend-mode: normal,
  492. normal;
  493. }
  494. .zap-agreement{
  495. display: flex;
  496. align-items: top;
  497. margin-top: 8px;
  498. line-height: 18px;
  499. font-size: 12px;
  500. }
  501. .zap-agreement__text{
  502. color: #666666;
  503. }
  504. .zap-agreement__link{
  505. display: flex;
  506. flex-direction: column;
  507. align-items: flex-start;
  508. color: #389cf4;
  509. cursor: pointer;
  510. }
  511. .zap-code-button{
  512. padding: 0 16px;
  513. line-height: 55px;
  514. font-size: 18px;
  515. color: #23b24b;
  516. border: none;
  517. background-color: transparent;
  518. }
  519. .el-button.is-disabled, .el-button.is-disabled:hover, .el-button.is-disabled:focus{
  520. background-color: transparent;
  521. }
  522. // 扫码登录
  523. .zap-scanning{
  524. width: 410px;
  525. height: 550px;
  526. background-image: linear-gradient(
  527. #ffffff,
  528. #ffffff),
  529. linear-gradient(
  530. #f3f3f3,
  531. #f3f3f3);
  532. background-blend-mode: normal,
  533. normal;
  534. box-sizing: border-box;
  535. }
  536. .zap-scanning__title{
  537. padding: 0 60px;
  538. font-size: 24px;
  539. color: #333333;
  540. }
  541. .zap-scanning__img{
  542. display: block;
  543. width: 220px;
  544. height: 220px;
  545. margin: 40px auto 0;
  546. object-fit: cover;
  547. }
  548. .zap-scanning__bottom{
  549. display: flex;
  550. align-items: center;
  551. justify-content: center;
  552. margin-top: 18px;
  553. font-size: 14px;
  554. }
  555. .zap-scanning__icon{
  556. width: 22px;
  557. height: 22px;
  558. margin-right: 10px;
  559. }
  560. .zap-scanning__text{
  561. color: #333333;
  562. }
  563. .zap-scanning__color{
  564. color: #23b24b;
  565. }
  566. .el-tabs__header{
  567. margin-bottom: 38px;
  568. }
  569. .el-dialog:not(.is-fullscreen){
  570. margin-top: 25vh !important;
  571. }
  572. }
  573. </style>