kongdeqiang
2023-11-21 2898325db11ed938f9891991198b88ea6a042d3d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<template>
    <div class="login-wrap">
        <div class="ms-login">
            <div class="ms-title">峰峰智慧泊车</div>
            <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="0px" class="ms-content">
                <el-form-item prop="loginId">
                    <el-input v-model="ruleForm.loginName" placeholder="loginName">
                        <el-button slot="prepend" icon="el-icon-lx-people">用户名</el-button>
                    </el-input>
                </el-form-item>
                <el-form-item prop="password">
                    <el-input type="password" placeholder="password" v-model="ruleForm.password" @keyup.enter.native="submitForm('ruleForm')">
                        <el-button slot="prepend" icon="el-icon-lx-lock">密&nbsp&nbsp&nbsp&nbsp码</el-button>
                    </el-input>
                </el-form-item>
 
                <div class="login-btn">
                    <el-button type="primary" @click="submitForm('ruleForm')">登录</el-button>
                </div>
            </el-form>
        </div>
    </div>
</template>
 
<script>
   import {mapMutations,mapState} from 'vuex';
    export default {
        data: function(){
            return {
               // 权限菜单
                ruleForm: {
                    loginName: '',
                    password: '',
                },
                rules: {
                    loginName: [
                        { required: true, message: '请输入用户名', trigger: 'blur' }
                    ],
                    password: [
                        { required: true, message: '请输入密码', trigger: 'blur' }
                    ]
                }
            }
        },
        created(){
            //this.$router.push({'path': '/home'});
        },
        computed:{
            ...mapState(['resultAsyncRoutes'])
 
        },
        methods: {
            ...mapMutations([
            'SET_ROLELISt',
            'SET_ROLES'
       ]),
            submitForm(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        var url = this.$systemconfig.basePath + '/ffzf/user/login';
                        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;
                            // 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 {
                            //     this.$router.push({'path': '/index'});
                            // }
                        }
                    })
                    } else {
                        return false;
                }
                });
            }
        }
    }
</script>
 
<style scoped>
    .login-wrap{
        position: relative;
        width:100%;
        height:100%;
        /*background-image: url(../../assets/img/loginBj.jpg);*/
        /*background-size: 100%;*/
    }
    .ms-title{
        width:100%;
        line-height: 50px;
        text-align: center;
        font-size:20px;
        color: rgb(12, 12, 12);
        border-bottom: 1px solid #ddd;
    }
    .ms-login{
        position: absolute;
        left:50%;
        top:50%;
        width:350px;
        margin:-190px 0 0 -175px;
        border-radius: 5px;
        background: rgba(255,255,255, 0.3);
        overflow: hidden;
    }
    .ms-content{
        padding: 30px 30px;
    }
    .login-btn{
        text-align: center;
    }
    .login-btn button{
        width:100%;
        height:36px;
        margin-bottom: 10px;
    }
    .login-tips{
        font-size:12px;
        line-height:30px;
        color:#fff;
    }
</style>