df9e61580cd10707f490e37b82a918eba4eec192.svn-base 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <template>
  2. <div class="main">
  3. <a-form-model class="user-layout-login" @keyup.enter.native="handleSubmit">
  4. <a-tabs :activeKey="customActiveKey" :tabBarStyle="{ textAlign: 'center', borderBottom: 'unset' }"
  5. @change="handleTabClick">
  6. <a-tab-pane key="tab1" tab="账号密码登录">
  7. <login-account ref="alogin" @validateFail="validateFail" @success="requestSuccess"
  8. @fail="requestFailed"></login-account>
  9. </a-tab-pane>
  10. <!-- <a-tab-pane key="tab2" tab="APP下载">-->
  11. <!-- <img src="../../assets/app.png" height="400" width="400"/>-->
  12. <!-- </a-tab-pane>-->
  13. <!-- <a-tab-pane key="tab2" tab="手机号登录">
  14. <login-phone ref="plogin" @validateFail="validateFail" @success="requestSuccess" @fail="requestFailed"></login-phone>
  15. </a-tab-pane>-->
  16. </a-tabs>
  17. <a-form-model-item>
  18. <a-checkbox @change="handleRememberMeChange" default-checked>自动登录</a-checkbox>
  19. <!--<router-link :to="{ name: 'alteration'}" class="forge-password" style="float: right;">
  20. 忘记密码
  21. </router-link>
  22. <router-link :to="{ name: 'register'}" class="forge-password" style="float: right;margin-right: 10px" >
  23. 注册账户
  24. </router-link>-->
  25. </a-form-model-item>
  26. <a-form-item style="margin-top:24px">
  27. <a-button size="large" type="primary" htmlType="submit" class="login-button" :loading="loginBtn"
  28. @click.stop.prevent="handleSubmit" :disabled="loginBtn">确定
  29. </a-button>
  30. </a-form-item>
  31. </a-form-model>
  32. <two-step-captcha v-if="requiredTwoStepCaptcha" :visible="stepCaptchaVisible" @success="stepCaptchaSuccess"
  33. @cancel="stepCaptchaCancel"></two-step-captcha>
  34. <login-select-tenant ref="loginSelect" @success="loginSelectOk"></login-select-tenant>
  35. <third-login ref="thirdLogin"></third-login>
  36. <img class="appimg" :class="{imgSize:isLarge}" @click="switchSize" src="../../assets/app.png"/>
  37. </div>
  38. </template>
  39. <script>
  40. import Vue from 'vue'
  41. import {ACCESS_TOKEN, ENCRYPTED_STRING} from '@/store/mutation-types'
  42. import ThirdLogin from './third/ThirdLogin'
  43. import LoginSelectTenant from './LoginSelectTenant'
  44. import TwoStepCaptcha from '@/components/tools/TwoStepCaptcha'
  45. import {encryption, getEncryptedString} from '@/utils/encryption/aesEncrypt'
  46. import {timeFix} from '@/utils/util'
  47. import LoginAccount from './LoginAccount'
  48. import LoginPhone from './LoginPhone'
  49. import JVxeImageCell from "@comp/JVxeCells/JVxeImageCell";
  50. import ImgDragSort from "@views/jeecg/ImgDragSort";
  51. export default {
  52. components: {
  53. LoginSelectTenant,
  54. TwoStepCaptcha,
  55. ThirdLogin,
  56. LoginAccount,
  57. LoginPhone
  58. },
  59. data() {
  60. return {
  61. customActiveKey: 'tab1',
  62. rememberMe: true,
  63. loginBtn: false,
  64. requiredTwoStepCaptcha: false,
  65. stepCaptchaVisible: false,
  66. encryptedString: {
  67. key: "1234567890adbcde",
  68. iv: "1234567890hjlkew",
  69. },
  70. isLarge:false
  71. }
  72. },
  73. created() {
  74. Vue.ls.remove(ACCESS_TOKEN)
  75. this.getEncrypte();
  76. this.getRouterData();
  77. this.rememberMe = true
  78. },
  79. methods: {
  80. handleTabClick(key) {
  81. this.customActiveKey = key
  82. },
  83. handleRememberMeChange(e) {
  84. this.rememberMe = e.target.checked
  85. },
  86. /**跳转到登录页面的参数-账号获取*/
  87. getRouterData() {
  88. this.$nextTick(() => {
  89. let temp = this.$route.params.username || this.$route.query.username || ''
  90. if (temp) {
  91. this.$refs.alogin.acceptUsername(temp)
  92. }
  93. })
  94. },
  95. //登录
  96. handleSubmit() {
  97. this.loginBtn = true;
  98. if (this.customActiveKey === 'tab1') {
  99. // 使用账户密码登录
  100. this.$refs.alogin.handleLogin(this.rememberMe)
  101. } else {
  102. //手机号码登录
  103. this.$refs.plogin.handleLogin(this.rememberMe)
  104. }
  105. },
  106. // 校验失败
  107. validateFail() {
  108. this.loginBtn = false;
  109. },
  110. // 登录后台成功
  111. requestSuccess(loginResult) {
  112. this.$refs.loginSelect.show(loginResult)
  113. },
  114. //登录后台失败
  115. requestFailed(err) {
  116. let description = ((err.response || {}).data || {}).message || err.message || "请求出现错误,请稍后再试"
  117. this.$notification['error']({
  118. message: '登录失败',
  119. description: description,
  120. duration: 4,
  121. });
  122. //账户密码登录错误后更新验证码
  123. if (this.customActiveKey === 'tab1' && description.indexOf('密码错误') > 0) {
  124. this.$refs.alogin.handleChangeCheckCode()
  125. }
  126. this.loginBtn = false;
  127. },
  128. loginSelectOk() {
  129. this.loginSuccess()
  130. },
  131. //登录成功
  132. loginSuccess() {
  133. this.$router.push({path: "/dashboard/analysis"}).catch(() => {
  134. console.log('登录跳转首页出错,这个错误从哪里来的')
  135. })
  136. this.$notification.success({
  137. message: '欢迎',
  138. description: `${timeFix()},欢迎回来`,
  139. });
  140. },
  141. stepCaptchaSuccess() {
  142. this.loginSuccess()
  143. },
  144. stepCaptchaCancel() {
  145. this.Logout().then(() => {
  146. this.loginBtn = false
  147. this.stepCaptchaVisible = false
  148. })
  149. },
  150. //获取密码加密规则
  151. getEncrypte() {
  152. var encryptedString = Vue.ls.get(ENCRYPTED_STRING);
  153. if (encryptedString == null) {
  154. getEncryptedString().then((data) => {
  155. this.encryptedString = data
  156. });
  157. } else {
  158. this.encryptedString = encryptedString;
  159. }
  160. },
  161. switchSize(){
  162. this.isLarge = !this.isLarge;
  163. }
  164. }
  165. }
  166. </script>
  167. <style lang="less" scoped>
  168. .user-layout-login {
  169. label {
  170. font-size: 14px;
  171. }
  172. .getCaptcha {
  173. display: block;
  174. width: 100%;
  175. height: 40px;
  176. }
  177. .forge-password {
  178. font-size: 14px;
  179. }
  180. button.login-button {
  181. padding: 0 15px;
  182. font-size: 16px;
  183. height: 40px;
  184. width: 100%;
  185. }
  186. .user-login-other {
  187. text-align: left;
  188. margin-top: 24px;
  189. line-height: 22px;
  190. .item-icon {
  191. font-size: 24px;
  192. color: rgba(0, 0, 0, .2);
  193. margin-left: 16px;
  194. vertical-align: middle;
  195. cursor: pointer;
  196. transition: color .3s;
  197. &:hover {
  198. color: #1890ff;
  199. }
  200. }
  201. .register {
  202. float: right;
  203. }
  204. }
  205. }
  206. </style>
  207. <style>
  208. .valid-error .ant-select-selection__placeholder {
  209. color: #f5222d;
  210. }
  211. .appimg{
  212. position: absolute;
  213. bottom: 2em;
  214. right: 2em;
  215. height: 100px;
  216. width: 100px;
  217. cursor:pointer;
  218. }
  219. .imgSize{
  220. height: 260px;
  221. width: 260px;
  222. }
  223. </style>