OrgLogin.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <div class="main iot-login-content">
  3. <div class="top-img"></div>
  4. <div class="sign-text">登录到 联锁管理平台</div>
  5. <a-form-model class="user-layout-login" @keyup.enter.native="handleSubmit">
  6. <a-tabs :activeKey="customActiveKey" :tabBarStyle="{ textAlign: 'center', borderBottom: 'unset' }" @change="handleTabClick" class="u-login-tabs">
  7. <!-- <a-tab-pane key="sso" tab="SSO">
  8. <login-sso ref="ssologin" @validateFail="validateFail" @success="requestSuccess" @fail="requestFailed"></login-sso>
  9. </a-tab-pane> -->
  10. <a-tab-pane key="system" tab="标准">
  11. <login-account ref="alogin" @validateFail="validateFail" @success="requestSuccess" @fail="requestFailed"></login-account>
  12. </a-tab-pane>
  13. <!-- 修改框架 -->
  14. <!-- <a-tab-pane key="tab2" tab="手机号登录">
  15. <login-phone ref="plogin" @validateFail="validateFail" @success="requestSuccess" @fail="requestFailed"></login-phone>
  16. </a-tab-pane> -->
  17. </a-tabs>
  18. <a-form-model-item>
  19. <a-checkbox @change="handleRememberMeChange" default-checked>记住我</a-checkbox>
  20. <!-- 修改框架 -->
  21. <!-- <router-link :to="{ name: 'alteration'}" class="forge-password" style="float: right;">
  22. 忘记密码
  23. </router-link> -->
  24. <!-- <router-link :to="{ name: 'register'}" class="forge-password" style="float: right;margin-right: 10px" >
  25. 注册账户
  26. </router-link> -->
  27. </a-form-model-item>
  28. <a-form-item style="margin-top:24px">
  29. <a-button size="large" type="primary" htmlType="submit" class="login-button" :loading="loginBtn" @click.stop.prevent="handleSubmit" :disabled="loginBtn">登录
  30. </a-button>
  31. </a-form-item>
  32. </a-form-model>
  33. <two-step-captcha v-if="requiredTwoStepCaptcha" :visible="stepCaptchaVisible" @success="stepCaptchaSuccess" @cancel="stepCaptchaCancel"></two-step-captcha>
  34. <login-select-tenant ref="loginSelect" @success="loginSelectOk"></login-select-tenant>
  35. <!-- 修改框架 -->
  36. <!-- <third-login ref="thirdLogin"></third-login> -->
  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 { getEncryptedString } from '@/utils/encryption/aesEncrypt'
  46. import { timeFix } from '@/utils/util'
  47. import LoginAccount from './LoginAccount'
  48. import LoginSso from './LoginSSO'
  49. // import LoginPhone from './LoginPhone'
  50. export default {
  51. components: {
  52. LoginSelectTenant,
  53. TwoStepCaptcha,
  54. ThirdLogin,
  55. LoginAccount,
  56. LoginSso,
  57. // LoginPhone
  58. },
  59. data () {
  60. return {
  61. customActiveKey: 'system',
  62. rememberMe: true,
  63. loginBtn: false,
  64. requiredTwoStepCaptcha: false,
  65. stepCaptchaVisible: false,
  66. encryptedString:{
  67. key:"",
  68. iv:"",
  69. },
  70. }
  71. },
  72. created() {
  73. Vue.ls.remove(ACCESS_TOKEN)
  74. this.getRouterData();
  75. this.rememberMe = true
  76. },
  77. methods:{
  78. handleTabClick(key){
  79. this.customActiveKey = key
  80. },
  81. handleRememberMeChange(e){
  82. this.rememberMe = e.target.checked
  83. },
  84. /**跳转到登录页面的参数-账号获取*/
  85. getRouterData(){
  86. this.$nextTick(() => {
  87. let temp = this.$route.params.username || this.$route.query.username || ''
  88. if (temp) {
  89. this.$refs.alogin.acceptUsername(temp)
  90. }
  91. })
  92. },
  93. //登录
  94. handleSubmit () {
  95. this.loginBtn = true;
  96. if (this.customActiveKey === 'sso') {
  97. //SSO单点登录
  98. this.$refs.ssologin.handleLogin(this.rememberMe)
  99. } else {
  100. // 使用账户密码登录
  101. this.$refs.alogin.handleLogin(this.rememberMe)
  102. }
  103. },
  104. // 校验失败
  105. validateFail(){
  106. this.loginBtn = false;
  107. },
  108. // 登录后台成功
  109. requestSuccess(loginResult){
  110. this.$refs.loginSelect.show(loginResult)
  111. },
  112. //登录后台失败
  113. requestFailed (err) {
  114. let description = ((err.response || {}).data || {}).message || err.message || "请求出现错误,请稍后再试"
  115. this.$notification[ 'error' ]({
  116. message: '登录失败',
  117. description: description,
  118. duration: 4,
  119. });
  120. //账户密码登录错误后更新验证码
  121. // if(this.customActiveKey === 'sso' && description.indexOf('密码错误')>0){
  122. // this.$refs.alogin.handleChangeCheckCode()
  123. // }
  124. this.loginBtn = false;
  125. },
  126. loginSelectOk(){
  127. this.loginSuccess()
  128. },
  129. //登录成功
  130. loginSuccess () {
  131. this.$router.push({ path: "/interLock/summary" }).catch(()=>{
  132. // this.$router.push({ path: "/dashboard/analysis" }).catch(()=>{
  133. console.log('登录跳转首页出错,这个错误从哪里来的')
  134. })
  135. this.$notification.success({
  136. message: '欢迎',
  137. description: `${timeFix()},欢迎回来`,
  138. });
  139. },
  140. stepCaptchaSuccess () {
  141. this.loginSuccess()
  142. },
  143. stepCaptchaCancel () {
  144. this.Logout().then(() => {
  145. this.loginBtn = false
  146. this.stepCaptchaVisible = false
  147. })
  148. },
  149. //获取密码加密规则
  150. getEncrypte(){
  151. var encryptedString = Vue.ls.get(ENCRYPTED_STRING);
  152. if(encryptedString == null){
  153. getEncryptedString().then((data) => {
  154. this.encryptedString = data
  155. });
  156. }else{
  157. this.encryptedString = encryptedString;
  158. }
  159. }
  160. }
  161. }
  162. </script>
  163. <style lang="less">
  164. .u-login-tabs{
  165. .ant-tabs-nav-container{
  166. font-size: 16px !important;
  167. }
  168. .ant-tabs-nav{
  169. width: 100%;
  170. .ant-tabs-tab{
  171. width: 100%;
  172. margin: 0;
  173. }
  174. }
  175. .ant-tabs-nav .ant-tabs-tab-active{
  176. color: #3395ff !important;
  177. }
  178. .ant-tabs-ink-bar{
  179. width: 100% !important;
  180. height: 3px;
  181. background: #3395ff;
  182. }
  183. }
  184. .iot-login-content{
  185. .ant-checkbox-checked .ant-checkbox-inner{
  186. background-color: #3395FF !important;
  187. border-color: #3395FF;
  188. }
  189. }
  190. </style>
  191. <style lang="less" scoped>
  192. .top-img{
  193. width: 100%;
  194. height: 64px;
  195. background: url('../../assets/login_logo.svg') no-repeat;
  196. background-size: 100%;
  197. }
  198. .sign-text{
  199. width: 100%;
  200. height: 32px;
  201. font-size: 16px;
  202. font-weight: 400;
  203. color: #646464;
  204. margin-top: 8px;
  205. }
  206. .user-layout-login {
  207. label {
  208. font-size: 14px;
  209. }
  210. .getCaptcha {
  211. display: block;
  212. width: 100%;
  213. height: 40px;
  214. }
  215. .forge-password {
  216. font-size: 14px;
  217. }
  218. button.login-button {
  219. width: 100%;
  220. height: 40px;
  221. padding: 0 15px;
  222. font-size: 16px;
  223. background: #004280;
  224. font-weight: 700;
  225. border-color: transparent;
  226. }
  227. .user-login-other {
  228. text-align: left;
  229. margin-top: 24px;
  230. line-height: 22px;
  231. .item-icon {
  232. font-size: 24px;
  233. color: rgba(0,0,0,.2);
  234. margin-left: 16px;
  235. vertical-align: middle;
  236. cursor: pointer;
  237. transition: color .3s;
  238. &:hover {
  239. color: #1890ff;
  240. }
  241. }
  242. .register {
  243. float: right;
  244. }
  245. }
  246. }
  247. </style>
  248. <style>
  249. .valid-error .ant-select-selection__placeholder{
  250. color: #f5222d;
  251. }
  252. </style>