kongdeqiang
2024-10-16 8bb7963646f27027c3eac087bdd50fdcfa7426cb
src/components/page/Login.vue
@@ -23,9 +23,11 @@
</template>
<script>
   import {mapMutations,mapState} from 'vuex';
    export default {
        data: function(){
            return {
               // 权限菜单
                ruleForm: {
                    loginName: '',
                    password: '',
@@ -43,8 +45,15 @@
        created(){
            //this.$router.push({'path': '/home'});
        },
        computed:{
            ...mapState(['resultAsyncRoutes'])
        },
        methods: {
            ...mapMutations([
            'SET_ROLELISt',
            'SET_ROLES'
       ]),
            submitForm(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
@@ -52,10 +61,14 @@
                        this.$byutil.postData(this,url,this.ruleForm,res=>{
                            let data = res.data;
                          if (data) {
                            localStorage.userId = data.id
                            localStorage.name = data.name
                            localStorage.type = data.type
                            this.$router.push({'path': '/home'});
                            localStorage.userId = data.id;
                            localStorage.name = data.name;
                            localStorage.type = data.type;
                            // localStorage.userRouters = JSON.stringify(this.items) ;
                            this.SET_ROLES(data.type)
                            this.SET_ROLELISt();  // 筛选左侧菜单栏
                            this.$router.push({'path': this.resultAsyncRoutes[0].children[0].indexUrl || '/home'});
                             // 自动跳转当前权限路由的第一个页面 ,如果找不到就去跳home
                            // if (this._isMobile()) {
                            //     this.$router.push({'path': '/index4'});
                            // } else {