johnsen 10 месяцев назад
Родитель
Сommit
ffe4648cd8
1 измененных файлов с 97 добавлено и 73 удалено
  1. 97 73
      src/views/system/login/index.vue

+ 97 - 73
src/views/system/login/index.vue

@@ -5,7 +5,7 @@
         <div class="login-top">
           <van-icon name="comment-circle-o" class="logo-icon" />
           <div class="logo-text">{{ $t('common.platform') }}</div>
-          <br>
+          <br />
           <!-- <div class="logo-text">(11111111111)</div> -->
         </div>
       </div>
@@ -18,18 +18,20 @@
             name="username"
             icon-prefix="ibps-icon"
             left-icon="user-circle-o"
-            clearable />
+            clearable
+          />
           <van-field
             v-model="loginForm.password"
             :type="passwordType"
             :placeholder="$t('system.login.passwordPlaceholder')"
             :rules="[{ required: true, message: ' ' }]"
-            :right-icon="passwordType==='password'?'eye-slash':'eye'"
+            :right-icon="passwordType === 'password' ? 'eye-slash' : 'eye'"
             name="password"
             icon-prefix="ibps-icon"
             left-icon="lock"
             clearable
-            @click-right-icon="showPassword" />
+            @click-right-icon="showPassword"
+          />
           <van-field
             v-if="enabledValidCode"
             v-model="loginForm.captcha"
@@ -38,9 +40,14 @@
             name="captcha"
             icon-prefix="ibps-icon"
             left-icon="qrcode"
-            clearable>
+            clearable
+          >
             <template #button>
-              <img :src="code.src" class="login-code-img" @click="refreshCode">
+              <img
+                :src="code.src"
+                class="login-code-img"
+                @click="refreshCode"
+              />
             </template>
           </van-field>
           <div class="ibps-mt">
@@ -49,7 +56,11 @@
             </van-button>
           </div>
         </van-form>
-        <switch-environment v-if="$nodeEnv === 'development'" class="ibps-mt ibps-text-center" type="link" />
+        <switch-environment
+          v-if="$nodeEnv === 'development'"
+          class="ibps-mt ibps-text-center"
+          type="link"
+        />
         <div v-if="outSideSingInShow" class="outSideSingInClass">
           <span @click="goOutSideSingIn()">非内部人员签到</span>
         </div>
@@ -68,14 +79,16 @@ import '@/assets/styles/pages/login.scss'
 import SwitchEnvironment from '@/views/system/switch-environment'
 import { encryptByAes } from '@/utils/encrypt'
 
-const loginForm = process.env.NODE_ENV === 'development'
-  ? {
-    username: 'shekou',
-    password: 'szjbd168'
-  } : {
-    username: '',
-    password: ''
-  }
+const loginForm =
+  process.env.NODE_ENV === 'development'
+    ? {
+        username: 'shekou',
+        password: 'szjbd168'
+      }
+    : {
+        username: '',
+        password: ''
+      }
 export default {
   components: {
     SwitchEnvironment
@@ -105,14 +118,18 @@ export default {
   },
   watch: {
     $route: {
-      handler: function(route) {
+      handler: function (route) {
         // if (route.query.codeId) {
         // this.redirect = '/dashboard'
         // this.redirect = `${route.path}?codeId=${route.query.codeId}`;
         // } else {
         this.redirect = route.query && route.query.redirect
         // console.log(this.redirect)
-        if (this.redirect && this.redirect.indexOf('/bpmn/siginin/index?codeId=') !== -1 && this.redirect.indexOf('type=reveal') !== -1) {
+        if (
+          this.redirect &&
+          this.redirect.indexOf('/bpmn/siginin/index?codeId=') !== -1 &&
+          this.redirect.indexOf('type=reveal') !== -1
+        ) {
           this.outSideSingInShow = true
         }
         // }
@@ -122,7 +139,11 @@ export default {
   },
 
   created() {
-    if (this.$router.currentRoute.query.hasOwnProperty('accessToken') && this.$router.currentRoute.query.hasOwnProperty('orgCode') && this.$router.currentRoute.query.hasOwnProperty('username')) {
+    if (
+      this.$router.currentRoute.query.hasOwnProperty('accessToken') &&
+      this.$router.currentRoute.query.hasOwnProperty('orgCode') &&
+      this.$router.currentRoute.query.hasOwnProperty('username')
+    ) {
       console.log(this.$router.currentRoute.query)
 
       this.loginForm.clientKey = '1001'
@@ -144,23 +165,21 @@ export default {
     this.loginForm.requestId = ''
   },
   methods: {
-    ...mapActions('ibps/account', [
-      'login',
-      'getCaptcha',
-      'getRegisterOpen'
-    ]),
+    ...mapActions('ibps/account', ['login', 'getCaptcha', 'getRegisterOpen']),
     isRegisterOpen() {
-      this.getRegisterOpen().then((data) => {
-        this.isRegOpen = data.data
-        if (this.isRegOpen) {
-          this.usernameRules = [
-            { required: true, message: ' ' },
-            { validator: this.validateMobile, message: ' ' }
-          ]
-        } else {
-          this.usernameRules = [{ required: true, message: ' ' }]
-        }
-      }).catch((e) => { })
+      this.getRegisterOpen()
+        .then((data) => {
+          this.isRegOpen = data.data
+          if (this.isRegOpen) {
+            this.usernameRules = [
+              { required: true, message: ' ' },
+              { validator: this.validateMobile, message: ' ' }
+            ]
+          } else {
+            this.usernameRules = [{ required: true, message: ' ' }]
+          }
+        })
+        .catch((e) => {})
     },
     validateMobile(value) {
       if (Utils.isEmpty(value)) {
@@ -184,22 +203,22 @@ export default {
     },
     // 获取验证码
     loadValidCode(isBackfill) {
-      this.getCaptcha({ params: { requestId: this.loginForm.requestId }}).then((data) => {
-        // 返回状态501,说明系统没有开启验证码
-        if (data.state === 501) {
-          this.enabledValidCode = false
-        } else {
-          this.enabledValidCode = true
-          this.code.src = data.data
-          this.loginForm.requestId = data.variables.requestId
-        }
-        this.initValidCode()
-        if (isBackfill) {
-          this.loginForm.code = this.code.value
-        }
-      }).catch((e) => {
-
-      })
+      this.getCaptcha({ params: { requestId: this.loginForm.requestId } })
+        .then((data) => {
+          // 返回状态501,说明系统没有开启验证码
+          if (data.state === 501) {
+            this.enabledValidCode = false
+          } else {
+            this.enabledValidCode = true
+            this.code.src = data.data
+            this.loginForm.requestId = data.variables.requestId
+          }
+          this.initValidCode()
+          if (isBackfill) {
+            this.loginForm.code = this.code.value
+          }
+        })
+        .catch((e) => {})
     },
     refreshCode() {
       this.loadValidCode()
@@ -224,28 +243,33 @@ export default {
     handleLogin() {
       // eslint-disable-next-line no-undef
       const params = structuredClone(this.loginForm)
-      params.password = this.loginForm.password === '' ? '' : encryptByAes(this.loginForm.password, 'pwd')
+      params.password =
+        this.loginForm.password === ''
+          ? ''
+          : encryptByAes(this.loginForm.password, 'pwd')
       this.login({
         form: params
-      }).then(() => {
-        // let path = '/'
-        // if (this.redirect) {
-        //   path = '/dashboard'
-        // }
-        const redirectPath = this.redirect || '/'
-        this.$router.push({ path: redirectPath })
-      }).catch((err) => {
-        // 验证码错误自动清空&密码输入错误3次后触发验证码填写模块
-        if (err && err.state === 6020104) {
-          this.loginForm.captcha = ''
-          this.enabledValidCode = true
-          this.refreshCode()
-        }
-        if (err && err.state && this.enabledValidCode) {
-          this.loginForm.captcha = ''
-          this.refreshCode()
-        }
       })
+        .then(() => {
+          // let path = '/'
+          // if (this.redirect) {
+          //   path = '/dashboard'
+          // }
+          const redirectPath = this.redirect || '/'
+          this.$router.push({ path: redirectPath })
+        })
+        .catch((err) => {
+          // 验证码错误自动清空&密码输入错误3次后触发验证码填写模块
+          if (err && err.state === 6020104) {
+            this.loginForm.captcha = ''
+            this.enabledValidCode = true
+            this.refreshCode()
+          }
+          if (err && err.state && this.enabledValidCode) {
+            this.loginForm.captcha = ''
+            this.refreshCode()
+          }
+        })
     },
     goOutSideSingIn() {
       const redirectPath = this.redirect.replace('index', 'outIndex')
@@ -255,15 +279,15 @@ export default {
 }
 </script>
 <style lang="scss" scoped>
-.outSideSingInClass{
+.outSideSingInClass {
   text-align: center;
   font-size: 12px;
-  color: #409EFF;
+  color: #409eff;
   margin-top: 20px;
   // text-decoration: underline;
-  span{
+  span {
     padding: 0 4px 1px 4px;
-    border-bottom: 1px solid #409EFF;
+    border-bottom: 1px solid #409eff;
   }
 }
 </style>