智慧农业大数据平台
xiebin
2022-11-16 3dc278f10a4c3e3db7ce3a445bed710bdc88916e
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
<template>
    <div class="auth-page">
        <div class="title"></div>
        <div class="container">
            <h1 class="text-xs-center">用户登录</h1>
            <div class="loginbody">
                <el-form :model="user" ref="formName" status-icon :rules="rules">
                    <!-- 用户账号 -->
                    <span class="input">用户名:</span>
                    <el-form-item prop="username">
                        <el-input
                            v-model="user.username"
                            prefix-icon="el-icon-user"
                            placeholder="请输入您的用户名"
                            autocomplete="off"
                        ></el-input>
                    </el-form-item>
                    <!-- 用户密码 -->
                    <span class="input">密码:</span>
                    <el-form-item prop="password">
                        <el-input
                            type="password"
                            v-model="user.password"
                            prefix-icon="el-icon-lock"
                            placeholder="请输入您密码"
                            autocomplete="off"
                        ></el-input>
                    </el-form-item>
                    <!-- 登录按钮 -->
                    <el-form-item>
                        <el-button type="primary" @click.enter="onLogin(user)">登&nbsp;录</el-button>
                    </el-form-item>
                </el-form>
            </div>
        </div>
    </div>
</template>
 
<script>
import nprogress from 'nprogress'
import md5 from 'js-md5'
import axios from 'axios'
import * as auth from '@/utils/auth'
import { EventBus } from '../../eventBus/event-bus'
 
export default {
    name: 'AppRegister',
    data () {
        return {
            user: {
                username: '',
                password: ''
            },
            rules: {
                username: [
                    { required: true, message: '用户名不能为空', trigger: 'blur' },
                    {
                        min: 3,
                        max: 10,
                        message: '用户账号长度在3~10个字符之间',
                        trigger: 'blur'
                    }
                ],
                password: [
                    { required: true, message: '密码不能为空', trigger: 'blur' },
                    {
                        min: 3,
                        max: 10,
                        message: '用户密码长度在3~10个字符之间',
                        trigger: 'blur'
                    }
                ]
            },
            errors: null,
            newAxios: null
        }
    },
    created () {
        //跳转到统一登录页
        window.location.replace('http://dev.jxpskj.com:8020/ncny/login.html')
        var that = this
 
        this.newAxios = axios.create({
            baseURL: 'http://dev.jxpskj.com:8020/api',
            timeout: 600000,
            headers: {
                Authorization: 'Basic c2FiZXI6c2FiZXJfc2VjcmV0',
                'Tenant-Id': '000000'
            }
        })
 
        document.onkeydown = (e) => {
            const _key = window.event.keyCode
            if (_key === 13) {
                that.onLogin(that.user)
            }
        }
    },
    methods: {
        onLogin ({ username, password }) {
            this.$refs.formName.validate((valid) => {
                if (valid) {
                    nprogress.start()
 
                    this.newAxios({
                        method: 'POST',
                        url: '/blade-auth/oauth/token',
                        params: {
                            username: username,
                            password: md5(password),
                            tenantId: '000000'
                        }
                    }).then((res) => {
                        if (res.data.access_token) {
                            this.$store.commit('setUser', res.data)
                            auth.setToken(res.data.access_token)
                            window.localStorage.setItem('userName', res.data.nick_name)//赋值
                            this.$router.push({ path: '/' })
                        } else {
                            this.$message({
                                type: 'warning',
                                message: '用户名或密码不正确,请重新输入'
                            })
                        }
                        nprogress.done()
                    })
                }
            })
        }
    }
}
</script>
 
<style scoped lang="scss">
.auth-page {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url(../../../public/img/bg/group16@2x.png);
    background-size: 100% 100%;
    margin: 0;
    padding: 0;
 
    .title {
        width: 1389px;
        height: 115px;
        background-image: url(../../../public/img/bg/login_title@2x.png);
        background-size: 100% 100%;
        margin: 99px 264px 0px 266px;
    }
    .container {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        margin: 317px auto;
        width: 653px;
        height: 552px;
        background-image: url(../../../public/img/bg/rectangle11@2x.png);
        background-size: 100% 100%;
        border-radius: 10px;
        letter-spacing: 100;
 
        h1 {
            margin: 54px 244px 0px 243px;
            width: 166px;
            text-align: left;
            width: 176px;
            height: 30px;
            font-size: 42px;
            font-family: PangMenZhengDao;
            font-weight: 400;
            color: #ffffff;
            line-height: 30px;
            letter-spacing: 2px;
        }
 
        .loginbody {
            position: absolute;
            top: 120px;
            left: 0;
            right: 0;
            bottom: 0;
            width: 72%;
            // margin: auto;
            margin-left: 51px;
 
            .el-form-item {
                text-align: center;
 
                /deep/.el-input__inner {
                    width: 548px;
                    height: 59px;
                    background: #0c2d49;
                    opacity: 0.5;
                    margin-bottom: 15px;
                    font-size: 21px;
                }
                /deep/.el-input--prefix .el-input__inner {
                    padding-left: 40px;
                }
                /deep/.el-input__inner:focus {
                    border: 2px solid #22b4cb;
                    opacity: 0.8;
                    color: #fff;
                }
                /deep/.el-form-item__error {
                    color: #f00;
                    line-height: 0;
                    font-size: 15px;
                    opacity: 0.8;
                    letter-spacing: 2px;
                    font-weight: 700;
                }
                /deep/.el-input__icon {
                    height: 91%;
                    width: 34px;
                }
                /deep/.el-icon-user::before,
                /deep/.el-icon-lock::before {
                    font-size: 22px;
                }
                /deep/.el-form-item.is-error,
                /deep/.el-input__validateIcon {
                    font-size: 22px;
                }
                /deep/.el-input__suffix {
                    right: -48px;
                }
                /deep/.el-input input::-webkit-input-placeholder {
                    color: #ffffff;
                    font-size: 21px;
                    opacity: 0.5;
                    line-height: 27px;
                }
                /deep/.el-input input::-moz-input-placeholder {
                    color: #ffffff;
                    font-size: 21px;
                    opacity: 0.5;
                }
                /deep/.el-input input::-ms-input-placeholder {
                    color: #ffffff;
                    font-size: 21px;
                    opacity: 0.5;
                    line-height: 27px;
                }
 
                .el-button {
                    width: 548px;
                    height: 59px;
                    background: linear-gradient(
                        90deg,
                        rgba(0, 249, 247, 0.54),
                        rgba(0, 182, 249, 0.54)
                    );
                    box-shadow: 0px 2px 20px 1px rgba(1, 25, 70, 0.46);
                    font-size: 29px;
                    margin-top: 25px;
                }
            }
 
            .input {
                display: inline-block;
                width: 100px;
                height: 23px;
                font-size: 24px;
                font-family: PingFang SC;
                color: #ffffff;
                margin-bottom: 21px;
            }
        }
    }
}
</style>