registerUser.vue 21 KB

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