index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. <template>
  2. <div class="login-container">
  3. <div class="flexBox">
  4. <div>
  5. <el-form
  6. ref="loginForm"
  7. :model="loginForm"
  8. :rules="loginRules"
  9. class="login-form"
  10. auto-complete="on"
  11. label-position="left"
  12. @submit.native.prevent="handleLogin"
  13. >
  14. <div class="flex">
  15. <div class="image-container">
  16. <div class="empty-height2 fiexlay">
  17. <img
  18. v-if="companyList[0] && companyList[0].logo"
  19. class="logo"
  20. :src="$showImgUrl(companyList[0].logo)"
  21. alt
  22. />
  23. {{ companyList[0] && companyList[0].sysName ? companyList[0].sysName : '' }}
  24. </div>
  25. <el-carousel :interval="5000" arrow="always" height="440px" class="carousel">
  26. <el-carousel-item v-for="item in banner" :key="item.id">
  27. <el-image :z-index="1" :src="$showImgUrl(item.imgCarouselUrl)" />
  28. </el-carousel-item>
  29. </el-carousel>
  30. </div>
  31. <div class="right-container">
  32. <div class="empty-height" />
  33. <div class="form-container">
  34. <div class="title">工单客服管理系统</div>
  35. <el-form-item prop="username">
  36. <span class="svg-container">
  37. <svg-icon icon-class="user" />
  38. </span>
  39. <el-input
  40. ref="username"
  41. v-model="loginForm.username"
  42. placeholder="请输入用户名"
  43. name="username"
  44. type="text"
  45. tabindex="1"
  46. auto-complete="on"
  47. />
  48. </el-form-item>
  49. <el-form-item prop="password">
  50. <span class="svg-container">
  51. <svg-icon icon-class="password" />
  52. </span>
  53. <el-input
  54. :key="passwordType"
  55. ref="password"
  56. v-model="loginForm.password"
  57. :type="passwordType"
  58. placeholder="请输入密码"
  59. name="password"
  60. tabindex="2"
  61. auto-complete="off"
  62. />
  63. <span class="show-pwd" @click="showPwd">
  64. <svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" />
  65. </span>
  66. </el-form-item>
  67. <el-form-item prop="codeValue">
  68. <span class="svg-container">
  69. <svg-icon icon-class="password" />
  70. </span>
  71. <el-input
  72. ref="codeValue"
  73. v-model="loginForm.codeValue"
  74. placeholder="请输入验证码"
  75. name="codeValue"
  76. type="text"
  77. tabindex="3"
  78. auto-complete="off"
  79. />
  80. <div class="code" @click="getCode"><img :src="'data:image/jpeg;base64,' + codeImage" alt="" /></div>
  81. </el-form-item>
  82. <el-checkbox v-model="isRemenberPw">记住密码</el-checkbox>
  83. <div class="button-container">
  84. <el-button :loading="loading" type="primary" @click.native.prevent="handleLogin">登录</el-button>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. </el-form>
  90. </div>
  91. <div v-if="companyList && companyList.length" class="info">
  92. <div class="info-item">
  93. <el-link :href="companyList[0].icpRecordLink" :underline="false" target="_blank">{{
  94. companyList[0].icpRecord
  95. }}</el-link>
  96. <div v-if="companyList[0].companyName && companyList[0].icpRecordLink" style="margin: 0 20px">|</div>
  97. <el-link :href="companyList[0].pubSecurityRecordLink" :underline="false" target="_blank">
  98. <el-image style="width: 14px; height: 16px" :src="require('@/assets/login/icon_0001.png')" />
  99. {{ companyList[0].pubSecurityRecord }}
  100. </el-link>
  101. </div>
  102. <div class="info-item">
  103. <el-link href="https://www.zfire.top/#/" :underline="false" target="_blank">
  104. {{ companyList[0] && companyList[0].companyName ? companyList[0].companyName : '' }}
  105. </el-link>
  106. </div>
  107. <div class="info-item">
  108. <el-link href="https://mp.weixin.qq.com" :underline="false" target="_blank"> 微信公众号&小程序 </el-link>
  109. <div style="margin: 0 20px">|</div>
  110. <el-link href="https://pay.weixin.qq.com/" :underline="false" target="_blank"> 微信支付商户平台 </el-link>
  111. </div>
  112. <div class="link_gs">
  113. <span v-if="dictList.length > 0" :underline="false" target="_blank">友链:</span>
  114. <el-link
  115. style="margin-left: 10px"
  116. v-for="(v, i) in dictList"
  117. :key="i"
  118. :href="v.amityUrl"
  119. :underline="false"
  120. target="_blank"
  121. >
  122. <el-image style="width: 14px; height: 16px" :src="$showImgUrl(v.amityUrlLogo)"></el-image>
  123. {{ v.amityUrlName }}</el-link
  124. >
  125. </div>
  126. </div>
  127. </div>
  128. </div>
  129. </template>
  130. <script>
  131. import { validUsername } from '@/utils/validate'
  132. import Cookies from 'js-cookie'
  133. import { getCode, getList, getCompanyList, recordAmityList2 } from '@/api/user'
  134. export default {
  135. name: 'Login',
  136. data() {
  137. const validateUsername = (rule, value, callback) => {
  138. if (value.length <= 0) {
  139. callback(new Error('请输入用户名'))
  140. } else {
  141. callback()
  142. }
  143. }
  144. const validatePassword = (rule, value, callback) => {
  145. if (value.length <= 0) {
  146. callback(new Error('请输入密码'))
  147. } else {
  148. callback()
  149. }
  150. }
  151. const validateCode = (rule, value, callback) => {
  152. if (value.length <= 0) {
  153. callback(new Error('请输入验证码'))
  154. } else {
  155. callback()
  156. }
  157. }
  158. return {
  159. loginForm: {
  160. username: '',
  161. password: '',
  162. code: '',
  163. codeValue: ''
  164. },
  165. loginRules: {
  166. username: [{ required: true, trigger: 'change', validator: validateUsername }],
  167. password: [{ required: true, trigger: 'change', validator: validatePassword }],
  168. codeValue: [{ required: true, trigger: 'change', validator: validateCode }]
  169. },
  170. loading: false,
  171. passwordType: 'password',
  172. redirect: undefined,
  173. isRemenberPw: false,
  174. codeImage: '',
  175. banner: [],
  176. companyList: [],
  177. dictList: []
  178. }
  179. },
  180. watch: {
  181. $route: {
  182. handler: function (route) {
  183. this.redirect = route.query && route.query.redirect
  184. },
  185. immediate: true
  186. }
  187. },
  188. created() {
  189. // 获取缓存信息
  190. if (localStorage.getItem('greemall_login')) {
  191. let storageData = JSON.parse(localStorage.getItem('greemall_login'))
  192. this.loginForm.username = storageData.username
  193. this.isRemenberPw = storageData.isRemenberPw
  194. }
  195. if (this.isRemenberPw) {
  196. this.getCookie()
  197. }
  198. this.getCode()
  199. this.getList()
  200. this.getCompanyList()
  201. this.getDictAmityPage()
  202. },
  203. methods: {
  204. // 获取轮播图
  205. getList() {
  206. getList().then(res => {
  207. this.banner = res.data
  208. })
  209. },
  210. //获取友情链接列表
  211. getDictAmityPage() {
  212. recordAmityList2().then(res => {
  213. this.dictList = res.data
  214. })
  215. },
  216. // 获取备案信息
  217. getCompanyList() {
  218. getCompanyList().then(res => {
  219. this.companyList = res.data
  220. })
  221. },
  222. // 获取验证码
  223. getCode() {
  224. getCode().then(res => {
  225. this.loginForm.code = res.data.code
  226. this.codeImage = res.data.pic
  227. })
  228. },
  229. // 显示隐藏密码
  230. showPwd() {
  231. if (this.passwordType === 'password') {
  232. this.passwordType = ''
  233. } else {
  234. this.passwordType = 'password'
  235. }
  236. this.$nextTick(() => {
  237. this.$refs.password.focus()
  238. })
  239. },
  240. // 登录
  241. handleLogin() {
  242. this.$refs.loginForm.validate(valid => {
  243. if (valid) {
  244. this.loading = true
  245. this.$store
  246. .dispatch('user/login', this.loginForm)
  247. .then(() => {
  248. this.$router.push({ path: this.redirect || '/' })
  249. this.saveUnAndPw()
  250. this.loading = false
  251. })
  252. .catch(() => {
  253. this.getCode()
  254. this.loginForm.codeValue = ''
  255. this.loading = false
  256. })
  257. } else {
  258. console.log('error submit!!')
  259. return false
  260. }
  261. })
  262. },
  263. // 处理账号密码的储存
  264. saveUnAndPw() {
  265. let storageData = {
  266. username: this.loginForm.username,
  267. isRemenberPw: this.isRemenberPw
  268. }
  269. localStorage.setItem('greemall_login', JSON.stringify(storageData))
  270. if (this.isRemenberPw) {
  271. this.setCookie(this.loginForm.username, this.loginForm.password, 7)
  272. }
  273. },
  274. //设置cookie
  275. setCookie(c_name, c_pwd, exdays) {
  276. var exdate = new Date() //获取时间
  277. exdate.setTime(exdate.getTime() + 24 * 60 * 60 * 1000 * exdays) //保存的天数
  278. //字符串拼接cookie
  279. window.document.cookie = 'greemall_username' + '=' + c_name + ';path=/;expires=' + exdate.toGMTString()
  280. window.document.cookie = 'greemall_password' + '=' + c_pwd + ';path=/;expires=' + exdate.toGMTString()
  281. },
  282. //读取cookie
  283. getCookie: function () {
  284. if (document.cookie.length > 0) {
  285. var arr = document.cookie.split('; ') //这里显示的格式需要切割一下自己可输出看下
  286. for (var i = 0; i < arr.length; i++) {
  287. var arr2 = arr[i].split('=') //再次切割
  288. //判断查找相对应的值
  289. if (arr2[0] == 'greemall_username') {
  290. this.loginForm.username = arr2[1] //保存到保存数据的地方
  291. } else if (arr2[0] == 'greemall_password') {
  292. this.loginForm.password = arr2[1]
  293. }
  294. }
  295. }
  296. },
  297. //清除cookie
  298. clearCookie: function () {
  299. this.setCookie('', '', -1) //修改2值都为空,天数为负1天就好了
  300. }
  301. }
  302. }
  303. </script>
  304. <style lang="scss">
  305. /* 修复input 背景不协调 和光标变色 */
  306. /* Detail see https://github.com/PanJiaChen/vue-element-admin/pull/927 */
  307. $bg: #283443;
  308. $light_gray: #fff;
  309. $cursor: #fff;
  310. $back: #333;
  311. @supports (-webkit-mask: none) and (not (cater-color: $cursor)) {
  312. .login-container .el-input input {
  313. color: $cursor;
  314. }
  315. }
  316. .info-item .el-link--inner {
  317. color: #ffffff;
  318. }
  319. /* reset element-ui css */
  320. .login-container {
  321. background: url('~@/assets/login/background.png') center center;
  322. background-size: cover;
  323. height: 100vh;
  324. .el-input {
  325. display: inline-block;
  326. height: 47px;
  327. width: 85%;
  328. input {
  329. background: transparent;
  330. border: 0px;
  331. -webkit-appearance: none;
  332. border-radius: 0px;
  333. padding: 12px 5px 12px 15px;
  334. color: $back;
  335. height: 47px;
  336. caret-color: $back;
  337. border-bottom: none !important;
  338. &:-webkit-autofill {
  339. box-shadow: 0 0 0px 1000px $cursor inset !important;
  340. -webkit-text-fill-color: $back !important;
  341. }
  342. }
  343. }
  344. .el-carousel__arrow--left,
  345. .el-carousel__arrow--right {
  346. display: none;
  347. }
  348. .carousel {
  349. border-top-left-radius: 15px;
  350. border-bottom-left-radius: 15px;
  351. overflow: hidden;
  352. }
  353. .el-form-item {
  354. border: 1px solid rgba(255, 255, 255, 0.1);
  355. border-radius: 5px;
  356. color: #454545;
  357. margin-bottom: 25px !important;
  358. }
  359. .el-checkbox__input {
  360. display: none;
  361. }
  362. .el-form-item__error {
  363. left: 30px;
  364. }
  365. .el-form-item__content {
  366. display: flex;
  367. align-items: center;
  368. line-height: 0;
  369. }
  370. .show-pwd {
  371. line-height: 40px;
  372. }
  373. .el-checkbox__input.is-checked + .el-checkbox__label {
  374. color: #4684f4db;
  375. }
  376. .checkbox {
  377. position: relative;
  378. display: flex;
  379. align-items: center;
  380. margin-left: 1px;
  381. .check-yes {
  382. position: relative;
  383. line-height: 0;
  384. }
  385. .yes {
  386. position: absolute;
  387. left: 50%;
  388. top: 50%;
  389. transform: translate(-50%, -50%);
  390. }
  391. .el-checkbox {
  392. margin: 0 !important;
  393. }
  394. }
  395. /* 可以设置不同的进入和离开动画 */
  396. /* 设置持续时间和动画函数 */
  397. .slide-fade-enter-active {
  398. transition: all 0.3s ease;
  399. }
  400. .slide-fade-leave-active {
  401. transition: all 0.8s cubic-bezier(1, 0.5, 0.8, 1);
  402. }
  403. .slide-fade-leave-active {
  404. transform: translateX(10px);
  405. opacity: 0;
  406. }
  407. .wei {
  408. display: flex;
  409. flex-direction: column;
  410. justify-content: center;
  411. align-items: center;
  412. margin-top: 30px;
  413. text-align: center;
  414. text-align-last: center;
  415. &-item-tip {
  416. height: 19px;
  417. font-size: 20px;
  418. margin-top: 17px;
  419. }
  420. &-item-text {
  421. height: 12px;
  422. font-size: 14px;
  423. margin-top: 17px;
  424. color: #999;
  425. }
  426. }
  427. }
  428. </style>
  429. <style lang="scss" scoped>
  430. $bg: #2d3a4b;
  431. $dark_gray: #889aa4;
  432. $light_gray: #eee;
  433. .flex {
  434. display: flex;
  435. align-items: center;
  436. }
  437. .info {
  438. display: flex;
  439. align-items: center;
  440. flex-direction: column;
  441. justify-content: center;
  442. width: 1080px;
  443. margin-top: 50px;
  444. line-height: 30px;
  445. text-align: center;
  446. text-align-last: center;
  447. color: #fff;
  448. z-index: 999;
  449. }
  450. .link_gs {
  451. font-size: 14px;
  452. }
  453. ::v-deep .link_gs .el-link--inner {
  454. color: #fff;
  455. font-weight: initial;
  456. }
  457. .info-item {
  458. display: flex;
  459. align-items: center;
  460. justify-content: center;
  461. }
  462. .title-item {
  463. display: flex;
  464. flex-direction: column;
  465. justify-content: center;
  466. align-items: center;
  467. margin: 0 30px;
  468. cursor: pointer;
  469. font-size: 22px;
  470. color: #666666;
  471. line-height: 40px;
  472. border-bottom: 3px solid #ffffff;
  473. }
  474. .acitve {
  475. font-weight: bold;
  476. color: #4684f4;
  477. border-bottom: 3px solid #4684f4;
  478. }
  479. .flexBox {
  480. display: flex;
  481. padding-top: calc(50vh - 230px);
  482. justify-content: space-between;
  483. flex-direction: column;
  484. align-items: center;
  485. }
  486. .input-box {
  487. position: relative;
  488. width: 360px;
  489. height: 50px;
  490. margin-bottom: 25px;
  491. background: #ffffff;
  492. border: 1px solid #e6e6e6 !important;
  493. border-radius: 4px;
  494. }
  495. .input-box:last-child {
  496. margin-bottom: 10px;
  497. }
  498. .flex {
  499. display: flex;
  500. flex-direction: row;
  501. }
  502. .empty-height {
  503. font-size: 30px;
  504. font-weight: bolder;
  505. height: 46px;
  506. margin: 15px 0;
  507. color: #fff;
  508. }
  509. .empty-height2 {
  510. font-size: 30px;
  511. font-weight: bolder;
  512. height: 42px;
  513. margin: 15px 0;
  514. color: #fff;
  515. }
  516. .fiexlay {
  517. width: auto;
  518. height: 46px;
  519. display: flex;
  520. align-items: center;
  521. }
  522. .logo {
  523. height: 42px;
  524. margin-right: 5px;
  525. }
  526. .el-carousel__item:nth-child(2n) {
  527. background-color: #99a9bf;
  528. }
  529. .el-carousel__item:nth-child(2n + 1) {
  530. background-color: #d3dce6;
  531. }
  532. .login-container {
  533. min-height: 100%;
  534. width: 100%;
  535. height: 100vh;
  536. background-color: $bg;
  537. overflow: hidden;
  538. .login-form {
  539. position: relative;
  540. width: 1920px;
  541. max-width: 100%;
  542. height: 100%;
  543. display: flex;
  544. flex-direction: column;
  545. align-items: center;
  546. }
  547. .image-container {
  548. width: 700px;
  549. height: 516px;
  550. // overflow: hidden;
  551. }
  552. .right-container {
  553. width: 440px;
  554. height: 516px;
  555. .form-container {
  556. height: 440px;
  557. padding: 20px 30px 27px 40px;
  558. background: #fff;
  559. border-radius: 0 15px 15px 0;
  560. .title {
  561. justify-content: center;
  562. letter-spacing: 4px;
  563. text-align: center;
  564. margin-bottom: 35px;
  565. }
  566. }
  567. }
  568. .tips {
  569. font-size: 14px;
  570. color: #fff;
  571. margin-bottom: 10px;
  572. span {
  573. &:first-of-type {
  574. margin-right: 16px;
  575. }
  576. }
  577. }
  578. .svg-container {
  579. margin: 0 0 0 14px;
  580. // padding: 6px 5px 6px 5px;
  581. color: #33aef7;
  582. vertical-align: middle;
  583. width: 30px;
  584. display: inline-block;
  585. }
  586. .title-container {
  587. border-radius: 15px 15px 0 0;
  588. overflow: hidden;
  589. img {
  590. width: 100%;
  591. display: block;
  592. }
  593. }
  594. .show-pwd {
  595. position: absolute;
  596. right: 30px;
  597. top: 7px;
  598. font-size: 16px;
  599. color: $dark_gray;
  600. cursor: pointer;
  601. user-select: none;
  602. }
  603. .code {
  604. position: absolute;
  605. right: 30px;
  606. top: 7px;
  607. z-index: 99;
  608. cursor: pointer;
  609. img {
  610. height: 30px;
  611. }
  612. }
  613. .code2 {
  614. position: absolute;
  615. right: 0;
  616. top: -1px;
  617. .el-button {
  618. height: 50px;
  619. }
  620. }
  621. .button-container {
  622. text-align: center;
  623. margin-top: 20px;
  624. button {
  625. font-size: 16px;
  626. width: 100%;
  627. height: 45px;
  628. border-radius: 4px;
  629. background: #4684f4;
  630. box-shadow: 2px 3px 8px 0px #4684f46b;
  631. }
  632. }
  633. }
  634. .float_right {
  635. position: absolute;
  636. right: 0;
  637. font-size: 14px;
  638. cursor: pointer;
  639. }
  640. ::v-deep .el-form-item__error {
  641. color: #f56c6c;
  642. font-size: 12px;
  643. line-height: 1;
  644. padding-top: 6px;
  645. position: absolute;
  646. top: 100%;
  647. left: 0;
  648. }
  649. .el-link.el-link--default:hover {
  650. color: #4684f4;
  651. }
  652. @media only screen and (max-width: 600px) {
  653. .image-container {
  654. display: none;
  655. }
  656. .form-container {
  657. border-radius: 15px !important;
  658. }
  659. }
  660. </style>