From 91ed935cc1bfddfe2af6b72998291a843525ee15 Mon Sep 17 00:00:00 2001
From: qushaowei <qushaowei@163.com>
Date: 星期一, 06 十一月 2023 14:05:51 +0800
Subject: [PATCH] 登陆成功后转到我的消息界面

---
 src/views/user/Login.vue |  366 ++++++++++++++++++++++++++++------------------------
 1 files changed, 196 insertions(+), 170 deletions(-)

diff --git a/src/views/user/Login.vue b/src/views/user/Login.vue
index 539640c..81546d3 100644
--- a/src/views/user/Login.vue
+++ b/src/views/user/Login.vue
@@ -1,35 +1,61 @@
 <template>
   <div class="main">
-    <a-form-model class="user-layout-login" @keyup.enter.native="handleSubmit">
-      <a-tabs :activeKey="customActiveKey" :tabBarStyle="{ textAlign: 'center', borderBottom: 'unset' }"  @change="handleTabClick">
-        <a-tab-pane key="tab1" tab="璐﹀彿瀵嗙爜鐧诲綍">
-          <login-account ref="alogin" @validateFail="validateFail" @success="requestSuccess" @fail="requestFailed"></login-account>
+    <a-form-model
+      class="user-layout-login"
+      @keyup.enter.native="handleSubmit"
+    >
+      <a-tabs
+        :activeKey="customActiveKey"
+        :tabBarStyle="{ textAlign: 'center', borderBottom: 'unset' }"
+        @change="handleTabClick"
+      >
+        <a-tab-pane
+          key="tab1"
+          tab="璐﹀彿瀵嗙爜鐧诲綍"
+        >
+          <login-account
+            ref="alogin"
+            @validateFail="validateFail"
+            @success="requestSuccess"
+            @fail="requestFailed"
+          ></login-account>
         </a-tab-pane>
 
         <!--<a-tab-pane key="tab2" tab="鎵嬫満鍙风櫥褰�">-->
-          <!--<login-phone ref="plogin" @validateFail="validateFail" @success="requestSuccess" @fail="requestFailed"></login-phone>-->
+        <!--<login-phone ref="plogin" @validateFail="validateFail" @success="requestSuccess" @fail="requestFailed"></login-phone>-->
         <!--</a-tab-pane>-->
       </a-tabs>
 
       <a-form-model-item>
         <!--<a-checkbox @change="handleRememberMeChange" default-checked>鑷姩鐧诲綍</a-checkbox>-->
         <!--<router-link :to="{ name: 'alteration'}" class="forge-password" style="float: right;">-->
-          <!--蹇樿瀵嗙爜-->
+        <!--蹇樿瀵嗙爜-->
         <!--</router-link>-->
         <!--<router-link :to="{ name: 'register'}" class="forge-password" style="float: right;margin-right: 10px" >-->
-          <!--娉ㄥ唽璐︽埛-->
+        <!--娉ㄥ唽璐︽埛-->
         <!--</router-link>-->
       </a-form-model-item>
 
       <a-form-item style="margin-top:24px">
-        <a-button size="large"  type="primary"  htmlType="submit"  class="login-button"  :loading="loginBtn"  @click.stop.prevent="handleSubmit" :disabled="loginBtn">纭畾
+        <a-button
+          size="large"
+          type="primary"
+          htmlType="submit"
+          class="login-button"
+          :loading="loginBtn"
+          @click.stop.prevent="handleSubmit"
+          :disabled="loginBtn"
+        >纭畾
         </a-button>
       </a-form-item>
 
     </a-form-model>
 
     <!--<two-step-captcha v-if="requiredTwoStepCaptcha" :visible="stepCaptchaVisible" @success="stepCaptchaSuccess" @cancel="stepCaptchaCancel"></two-step-captcha>-->
-    <login-select-tenant ref="loginSelect" @success="loginSelectOk"></login-select-tenant>
+    <login-select-tenant
+      ref="loginSelect"
+      @success="loginSelectOk"
+    ></login-select-tenant>
     <!--<third-login ref="thirdLogin"></third-login>-->
   </div>
 </template>
@@ -49,194 +75,194 @@
 import { getAction } from '../../api/manage'
 
 export default {
-    components: {
-      LoginSelectTenant,
-      TwoStepCaptcha,
-      // ThirdLogin,
-      LoginAccount,
-      LoginPhone,
-      store
+  components: {
+    LoginSelectTenant,
+    TwoStepCaptcha,
+    // ThirdLogin,
+    LoginAccount,
+    LoginPhone,
+    store
+  },
+  data() {
+    return {
+      customActiveKey: 'tab1',
+      rememberMe: true,
+      loginBtn: false,
+      requiredTwoStepCaptcha: false,
+      stepCaptchaVisible: false,
+      encryptedString: {
+        key: "",
+        iv: "",
+      },
+      url: {
+        getPrimaryInfo: "/sys/sysAnnouncementSend/getPrimaryInfo"
+      }
+    }
+  },
+  created() {
+    Vue.ls.remove(ACCESS_TOKEN)
+    this.getRouterData();
+    this.rememberMe = true
+  },
+  methods: {
+    handleTabClick(key) {
+      this.customActiveKey = key
     },
-    data () {
-      return {
-        customActiveKey: 'tab1',
-        rememberMe: true,
-        loginBtn: false,
-        requiredTwoStepCaptcha: false,
-        stepCaptchaVisible: false,
-        encryptedString:{
-          key:"",
-          iv:"",
-        },
-        url:{
-          getPrimaryInfo:"/sys/sysAnnouncementSend/getPrimaryInfo"
+    handleRememberMeChange(e) {
+      this.rememberMe = e.target.checked
+    },
+    /**璺宠浆鍒扮櫥褰曢〉闈㈢殑鍙傛暟-璐﹀彿鑾峰彇*/
+    getRouterData() {
+      this.$nextTick(() => {
+        let temp = this.$route.params.username || this.$route.query.username || ''
+        if (temp) {
+          this.$refs.alogin.acceptUsername(temp)
         }
+      })
+    },
+
+    //鐧诲綍
+    handleSubmit() {
+      this.loginBtn = true;
+      if (this.customActiveKey === 'tab1') {
+        // 浣跨敤璐︽埛瀵嗙爜鐧诲綍
+        this.$refs.alogin.handleLogin(this.rememberMe)
+      } else {
+        //鎵嬫満鍙风爜鐧诲綍
+        this.$refs.plogin.handleLogin(this.rememberMe)
       }
     },
-    created() {
-      Vue.ls.remove(ACCESS_TOKEN)
-      this.getRouterData();
-      this.rememberMe = true
+    // 鏍¢獙澶辫触
+    validateFail() {
+      this.loginBtn = false;
     },
-    methods:{
-      handleTabClick(key){
-        this.customActiveKey = key
-      },
-      handleRememberMeChange(e){
-        this.rememberMe = e.target.checked
-      },
-      /**璺宠浆鍒扮櫥褰曢〉闈㈢殑鍙傛暟-璐﹀彿鑾峰彇*/
-      getRouterData(){
-        this.$nextTick(() => {
-          let temp = this.$route.params.username || this.$route.query.username || ''
-          if (temp) {
-            this.$refs.alogin.acceptUsername(temp)
+    // 鐧诲綍鍚庡彴鎴愬姛
+    requestSuccess(loginResult) {
+      this.$router.push({ path: "/isps/userAnnouncement" }).catch(() => {
+        console.log('鐧诲綍璺宠浆棣栭〉鍑洪敊,杩欎釜閿欒浠庡摢閲屾潵鐨�')
+      })
+      this.$notification.success({
+        message: '娆㈣繋',
+        description: `${timeFix()}锛屾杩庡洖鏉,
+      });
+      var userId = store.getters.userInfo.id;
+      let that = this;
+      getAction(this.url.getPrimaryInfo, { userId: userId }).then(res => {
+        if (res.success) {
+          for (var i = 0; i < res.result.length; i++) {
+            that.$notification.success({
+              message: '鏈�鏂版湭璇绘秷鎭��' + res.result[i].msgCategory + '銆�',
+              description: res.result[i].msgContent,
+              duration: 60,
+              icon: <a-icon type="exclamation-circle" style="color:red" />,
+            });
           }
-        })
-      },
-
-      //鐧诲綍
-      handleSubmit () {
-        this.loginBtn = true;
-        if (this.customActiveKey === 'tab1') {
-          // 浣跨敤璐︽埛瀵嗙爜鐧诲綍
-          this.$refs.alogin.handleLogin(this.rememberMe)
-        } else {
-          //鎵嬫満鍙风爜鐧诲綍
-          this.$refs.plogin.handleLogin(this.rememberMe)
         }
-      },
-      // 鏍¢獙澶辫触
-      validateFail(){
-        this.loginBtn = false;
-      },
-      // 鐧诲綍鍚庡彴鎴愬姛
-      requestSuccess(loginResult){
-        this.$router.push({ path: "/isps/userAnnouncement" }).catch(()=>{
-          console.log('鐧诲綍璺宠浆棣栭〉鍑洪敊,杩欎釜閿欒浠庡摢閲屾潵鐨�')
-        })
-        this.$notification.success({
-          message: '娆㈣繋',
-          description: `${timeFix()}锛屾杩庡洖鏉,
-        });
-        var userId = store.getters.userInfo.id;
-        let that = this;
-        getAction(this.url.getPrimaryInfo,{userId:userId}).then(res=>{
-            if(res.success){
-                for(var i=0;i<res.result.length;i++){
-                  that.$notification.success({
-                    message: '鏈�鏂版湭璇绘秷鎭��'+res.result[i].msgCategory+'銆�',
-                    description:res.result[i].msgContent,
-                    duration:60,
-                    icon:<a-icon type="exclamation-circle" style="color:red" />,
-                  });
-                }
-            }
-        })
-        // this.$refs.loginSelect.show(loginResult)
-      },
-      //鐧诲綍鍚庡彴澶辫触
-      requestFailed (err) {
-        let description = ((err.response || {}).data || {}).message || err.message || "璇锋眰鍑虹幇閿欒锛岃绋嶅悗鍐嶈瘯"
-        this.$notification[ 'error' ]({
-          message: '鐧诲綍澶辫触',
-          description: description,
-          duration: 4,
-        });
-        //璐︽埛瀵嗙爜鐧诲綍閿欒鍚庢洿鏂伴獙璇佺爜
-        if(this.customActiveKey === 'tab1' && description.indexOf('瀵嗙爜閿欒')>0){
-          this.$refs.alogin.handleChangeCheckCode()
-        }
-        this.loginBtn = false;
-      },
-      loginSelectOk(){
-        this.loginSuccess()
-      },
-      //鐧诲綍鎴愬姛
-      loginSuccess () {
-        this.$router.push({ path: "/dashboard/analysis" }).catch(()=>{
-          console.log('鐧诲綍璺宠浆棣栭〉鍑洪敊,杩欎釜閿欒浠庡摢閲屾潵鐨�')
-        })
-        this.$notification.success({
-          message: '娆㈣繋',
-          description: `${timeFix()}锛屾杩庡洖鏉,
-        });
-     
-      },
-
-      stepCaptchaSuccess () {
-        this.loginSuccess()
-      },
-      stepCaptchaCancel () {
-        this.Logout().then(() => {
-          this.loginBtn = false
-          this.stepCaptchaVisible = false
-        })
-      },
-      //鑾峰彇瀵嗙爜鍔犲瘑瑙勫垯
-      getEncrypte(){
-        var encryptedString = Vue.ls.get(ENCRYPTED_STRING);
-        if(encryptedString == null){
-          getEncryptedString().then((data) => {
-            this.encryptedString = data
-          });
-        }else{
-          this.encryptedString = encryptedString;
-        }
+      })
+      // this.$refs.loginSelect.show(loginResult)
+    },
+    //鐧诲綍鍚庡彴澶辫触
+    requestFailed(err) {
+      let description = ((err.response || {}).data || {}).message || err.message || "璇锋眰鍑虹幇閿欒锛岃绋嶅悗鍐嶈瘯"
+      this.$notification['error']({
+        message: '鐧诲綍澶辫触',
+        description: description,
+        duration: 4,
+      });
+      //璐︽埛瀵嗙爜鐧诲綍閿欒鍚庢洿鏂伴獙璇佺爜
+      if (this.customActiveKey === 'tab1' && description.indexOf('瀵嗙爜閿欒') > 0) {
+        this.$refs.alogin.handleChangeCheckCode()
       }
+      this.loginBtn = false;
+    },
+    loginSelectOk() {
+      this.loginSuccess()
+    },
+    //鐧诲綍鎴愬姛
+    loginSuccess() {
+      this.$router.push({ path: "/isps/userAnnouncement" }).catch(() => {
+        console.log('鐧诲綍璺宠浆棣栭〉鍑洪敊,杩欎釜閿欒浠庡摢閲屾潵鐨�')
+      })
+      this.$notification.success({
+        message: '娆㈣繋',
+        description: `${timeFix()}锛屾杩庡洖鏉,
+      });
 
+    },
+
+    stepCaptchaSuccess() {
+      this.loginSuccess()
+    },
+    stepCaptchaCancel() {
+      this.Logout().then(() => {
+        this.loginBtn = false
+        this.stepCaptchaVisible = false
+      })
+    },
+    //鑾峰彇瀵嗙爜鍔犲瘑瑙勫垯
+    getEncrypte() {
+      var encryptedString = Vue.ls.get(ENCRYPTED_STRING);
+      if (encryptedString == null) {
+        getEncryptedString().then((data) => {
+          this.encryptedString = data
+        });
+      } else {
+        this.encryptedString = encryptedString;
+      }
     }
 
   }
+
+}
 </script>
 <style lang="less" scoped>
-  .user-layout-login {
-    label {
-      font-size: 14px;
-    }
+.user-layout-login {
+  label {
+    font-size: 14px;
+  }
   .getCaptcha {
-      display: block;
-      width: 100%;
-      height: 40px;
-    }
+    display: block;
+    width: 100%;
+    height: 40px;
+  }
 
   .forge-password {
-      font-size: 14px;
-    }
+    font-size: 14px;
+  }
 
-    button.login-button {
-      padding: 0 15px;
-      font-size: 16px;
-      height: 40px;
-      width: 100%;
-    }
+  button.login-button {
+    padding: 0 15px;
+    font-size: 16px;
+    height: 40px;
+    width: 100%;
+  }
 
   .user-login-other {
-      text-align: left;
-      margin-top: 24px;
-      line-height: 22px;
+    text-align: left;
+    margin-top: 24px;
+    line-height: 22px;
 
     .item-icon {
-        font-size: 24px;
-        color: rgba(0,0,0,.2);
-        margin-left: 16px;
-        vertical-align: middle;
-        cursor: pointer;
-        transition: color .3s;
+      font-size: 24px;
+      color: rgba(0, 0, 0, 0.2);
+      margin-left: 16px;
+      vertical-align: middle;
+      cursor: pointer;
+      transition: color 0.3s;
 
       &:hover {
-          color: #1890ff;
-        }
-      }
-
-    .register {
-        float: right;
+        color: #1890ff;
       }
     }
+
+    .register {
+      float: right;
+    }
   }
+}
 </style>
 <style>
-  .valid-error .ant-select-selection__placeholder{
-    color: #f5222d;
-  }
+.valid-error .ant-select-selection__placeholder {
+  color: #f5222d;
+}
 </style>
\ No newline at end of file

--
Gitblit v1.9.3