ソースを参照

修复登录记住密码

li.shaoyi 3 年 前
コミット
295cf4f6dc

+ 0 - 1
src/router/index.ts

@@ -87,7 +87,6 @@ router.beforeEach((to, from, next) => {
                         const { ACCOUNT, PASSWORD } = to.query
                         login(ACCOUNT as string, PASSWORD as string, [], true).then(res => {
                             setLoadComplete(true)
-                            localStorageUtil.setItem('loginAccount', ACCOUNT); // 缓存登录账号
                             eventBus.$emit('loginSuccess', true);
                             next({ name })
                         }).catch(err => {

+ 1 - 0
src/services/proto/accountinfo/interface.ts

@@ -183,6 +183,7 @@ export interface CustomerInfoOperateReq {
     teammanageruserid?: number
     sex?: number;
     birthday?: string;
+    customername?: string;
 }
 // 客户资料操作响应 0 29 188
 export interface CustomerInfoOperateRsp {

+ 143 - 147
src/views/account/login.vue

@@ -19,13 +19,7 @@
               </a-input>
             </a-form-item>
             <a-form-item name="password" class="mb20">
-              <a-input
-                @keyup.enter="loginAction"
-                placeholder="请输入您的登录密码"
-                type="password"
-                v-model:value="form.password"
-                autocomplete
-              >
+              <a-input @keyup.enter="loginAction" placeholder="请输入您的登录密码" type="password" v-model:value="form.password" autocomplete>
                 <template #prefix>
                   <img src="@/assets/images/password.png" alt />
                 </template>
@@ -33,7 +27,7 @@
             </a-form-item>
             <a-form-item>
               <div class="login-remember-password">
-                <a-checkbox v-model:checked="form.isRemember">记住账号</a-checkbox>
+                <a-checkbox v-model:checked="form.isRemember" @change="rememberChange">记住账号</a-checkbox>
                 <!-- <router-link to="/resetPassword">忘记密码?</router-link> -->
               </div>
             </a-form-item>
@@ -76,19 +70,12 @@ interface Form {
 }
 
 const initForm: Form = {
-  account: '',
+  account: window.localStorage.getItem('rememberAccount') ?? '',
   password: '',
-  isRemember: false,
+  isRemember: window.localStorage.getItem('isRememberAccount') ? true : false,
   isRead: false,
 };
 
-function setRememberAccount(): void {
-  const account: string = localStorageUtil.getItem('loginAccount');
-  if (account) {
-    Object.assign(initForm, { account, isRemember: true });
-  }
-}
-
 // declare global {
 //     interface Window {
 //         qt: {
@@ -166,10 +153,18 @@ export default defineComponent({
     };
     const formDom: any = ref(null);
     const router = useRouter();
-    form.password = '';
-    // setRememberAccount();
     // qt
     const { getQtInfo } = qtAction();
+
+    function rememberChange() {
+      if (form.isRemember) {
+        window.localStorage.setItem('isRememberAccount', 'true');
+      } else {
+        window.localStorage.removeItem('rememberAccount');
+        window.localStorage.removeItem('isRememberAccount');
+      }
+    }
+
     function loginAction() {
       formDom.value.validate().then(() => {
         loading.value = true;
@@ -181,8 +176,9 @@ export default defineComponent({
               setLoadComplete(true);
               const { account, isRemember } = toRaw(form);
               if (isRemember) {
-                localStorageUtil.setItem('loginAccount', account); // 缓存登录账号
+                window.localStorage.setItem('rememberAccount', account); // 缓存登录账号
               }
+              form.password = '';
               eventBus.$emit('loginSuccess', true);
               router.push({ name: 'home' });
               loading.value = false;
@@ -210,157 +206,157 @@ export default defineComponent({
           goHomeloading.value = false;
         });
     };
-    return { form, loginAction, rules, formDom, loading, goHomeloading, goHome };
+    return { form, loginAction, rememberChange, rules, formDom, loading, goHomeloading, goHome };
   },
 });
 </script>
 
 <style lang="less" scoped>
 .login {
-  width: 100%;
-  height: 100%;
-  background: url(../../assets/images/loginBackground.png) no-repeat scroll 0 0;
-  background-size: 100% 100%;
+    width: 100%;
+    height: 100%;
+    background: url(../../assets/images/loginBackground.png) no-repeat scroll 0 0;
+    background-size: 100% 100%;
 }
 .ant-row {
-  height: 100%;
+    height: 100%;
 }
 .ant-col {
-  width: 690px;
-  height: 450px;
-  border-radius: 5px;
-  box-shadow: 0px 5px 10px 0px rgba(18, 22, 24, 0.18);
-  overflow: hidden;
-  .flex();
+    width: 690px;
+    height: 450px;
+    border-radius: 5px;
+    box-shadow: 0px 5px 10px 0px rgba(18, 22, 24, 0.18);
+    overflow: hidden;
+    .flex();
 }
 
 .login-background {
-  width: 275px;
-  background: url("../../assets/images/logoBackground.png") no-repeat scroll 0 0;
-  background-size: cover;
-  display: flex;
-  align-items: center;
-  justify-content: center;
-  div {
-    // margin-top: 120px;
-    // margin-left: 69.5px; // 企业风管logo
-    // margin-left: 33px; // 云融
-    width: 136px;
-    height: 136px;
-    min-width: 136px;
-    min-height: 136px;
-    position: relative;
+    width: 275px;
+    background: url('../../assets/images/logoBackground.png') no-repeat scroll 0 0;
+    background-size: cover;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    div {
+        // margin-top: 120px;
+        // margin-left: 69.5px; // 企业风管logo
+        // margin-left: 33px; // 云融
+        width: 136px;
+        height: 136px;
+        min-width: 136px;
+        min-height: 136px;
+        position: relative;
 
-    // img {
-    //     max-width: 100%;
-    //     max-height: 100%;
-    //     .position(absolute, 0%, auto, auto, 50%);
-    //     z-index: 10;
-    //     transform: translate(-50%, -50%);
-    // }
-  }
+        // img {
+        //     max-width: 100%;
+        //     max-height: 100%;
+        //     .position(absolute, 0%, auto, auto, 50%);
+        //     z-index: 10;
+        //     transform: translate(-50%, -50%);
+        // }
+    }
 
-  // .ant-btn {
-  //     background: @cyan-color2;
-  //     border-color: @cyan-color2;
-  //     border-radius: 10px;
-  //     font-size: 14px;
-  //     color: @white;
-  //     margin-top: 90px;
-  //     margin-left: -60px;
-  // }
+    // .ant-btn {
+    //     background: @cyan-color2;
+    //     border-color: @cyan-color2;
+    //     border-radius: 10px;
+    //     font-size: 14px;
+    //     color: @white;
+    //     margin-top: 90px;
+    //     margin-left: -60px;
+    // }
 }
 .login-content {
-  flex: 1;
-  padding-left: 53px;
-  padding-right: 53px;
-  min-width: 405px;
-  background: @m-white0;
-  ::v-deep(.ant-form) {
-    margin-top: 20px;
-    .ant-form-item-control-wrapper {
-      width: 100%;
-    }
-    .ant-form-item-control.has-error {
-      .ant-form-item-children {
+    flex: 1;
+    padding-left: 53px;
+    padding-right: 53px;
+    min-width: 405px;
+    background: @m-white0;
+    ::v-deep(.ant-form) {
+        margin-top: 20px;
+        .ant-form-item-control-wrapper {
+            width: 100%;
+        }
+        .ant-form-item-control.has-error {
+            .ant-form-item-children {
+                .ant-input-affix-wrapper {
+                    .ant-input {
+                        background: transparent !important;
+                    }
+                }
+            }
+            .ant-form-explain {
+                text-align: left;
+                padding-left: 24px;
+            }
+        }
+        .ant-input {
+            border: 0;
+            border-radius: 0;
+            width: 100%;
+            height: 40px;
+            font-size: 16px;
+            font-family: Adobe Heiti Std;
+
+            &:-webkit-autofill {
+                box-shadow: 0 0 0 1000px #fff inset;
+                -webkit-text-fill-color: @m-black;
+            }
+        }
         .ant-input-affix-wrapper {
-          .ant-input {
-            background: transparent !important;
-          }
+            box-shadow: none;
+            border: none;
+            border-radius: 0;
+            border-bottom: 1px solid @m-grey3;
+            padding: 0;
+        }
+        .ant-input-affix-wrapper:hover {
+            border-bottom: 1px solid @m-blue1;
         }
-      }
-      .ant-form-explain {
-        text-align: left;
-        padding-left: 24px;
-      }
     }
-    .ant-input {
-      border: 0;
-      border-radius: 0;
-      width: 100%;
-      height: 40px;
-      font-size: 16px;
-      font-family: Adobe Heiti Std;
-
-      &:-webkit-autofill {
-        box-shadow: 0 0 0 1000px #fff inset;
-        -webkit-text-fill-color: @m-black;
-      }
+    .mt20 {
+        margin-top: 20px;
     }
-    .ant-input-affix-wrapper {
-      box-shadow: none;
-      border: none;
-      border-radius: 0;
-      border-bottom: 1px solid @m-grey3;
-      padding: 0;
+    .mb20 {
+        margin-bottom: 20px;
     }
-    .ant-input-affix-wrapper:hover {
-      border-bottom: 1px solid @m-blue1;
+    .ant-form-item,
+    .ant-form label {
+        font-size: 16px;
     }
-  }
-  .mt20 {
-    margin-top: 20px;
-  }
-  .mb20 {
-    margin-bottom: 20px;
-  }
-  .ant-form-item,
-  .ant-form label {
-    font-size: 16px;
-  }
-  .ant-form-item {
-    margin-bottom: 10px;
-  }
-  p {
-    font-size: 26px;
-    text-align: left;
-    font-family: Adobe Heiti Std;
-    font-weight: normal;
-    color: @m-grey4;
-    margin-top: 40px;
-    margin-bottom: 10px;
-  }
-  img {
-    width: 19px;
-    height: 21px;
-  }
-  .login-remember-password {
-    .flex();
-    justify-content: space-between;
-    a {
-      color: @m-grey4;
+    .ant-form-item {
+        margin-bottom: 10px;
+    }
+    p {
+        font-size: 26px;
+        text-align: left;
+        font-family: Adobe Heiti Std;
+        font-weight: normal;
+        color: @m-grey4;
+        margin-top: 40px;
+        margin-bottom: 10px;
+    }
+    img {
+        width: 19px;
+        height: 21px;
+    }
+    .login-remember-password {
+        .flex();
+        justify-content: space-between;
+        a {
+            color: @m-grey4;
+        }
     }
-  }
 
-  .ant-btn {
-    width: 100%;
-    font-size: 16px;
-    background: @m-blue1;
-    border-radius: 3px;
-    color: @m-white0;
-    height: 50px;
-    font-weight: 500;
-    line-height: 43px;
-  }
+    .ant-btn {
+        width: 100%;
+        font-size: 16px;
+        background: @m-blue1;
+        border-radius: 3px;
+        color: @m-white0;
+        height: 50px;
+        font-weight: 500;
+        line-height: 43px;
+    }
 }
 </style>

+ 3 - 2
src/views/information/custom/compoments/add/index.vue

@@ -330,12 +330,13 @@ export default defineComponent({
           userid: getUserId(), // 必填
           areaid: getUserId(),
           userinfotype: Number(param.userinfotype),
-          username: Number(param.userinfotype) === 1 ? param.username : param.customername,
+          username: param.username || param.customername,
           userstate: OperateType, // 1: 保存草稿 2: 新增
+          customername: param.customername || param.username,
           // 以上必填
           cardtype: Number(param.userinfotype) === 1 ? 0 : param.cardtype ?? -1, // 证件类型
           cardnum: param.cardnum, // 证件号码
-          nickname: Number(param.userinfotype) === 1 ? param.username : param.nickname, // 昵称
+          nickname: param.nickname || param.username, // 昵称
           remark: param.remark, // 备注
           mobilephone: param.mobilephone, //  手机号码
           telphone: param.telphone, // 电话