Login.vue
6.7 KB
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
<template>
<div id="login" :style="{height:innerHeight+'px'}">
<h1>视频分析综合管理平台</h1>
<div class="form-horizontal">
<div class="form-group">
<div class="col-sm-offset-2 col-sm-8">
<input type="text" class="form-control" v-model="username" id="username" placeholder="请输入用户名">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-8">
<input type="password" class="form-control" v-model="password" id="password" placeholder="请输入密码">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-8">
<button class="btn" @click.stop="login">登录</button>
</div>
</div>
<!--<div class="form-group">
<div class="col-sm-offset-2 col-sm-8">
<p>北京文安智能技术股份有限公司</p>
<p>v2.0.0.1</p>
</div>
</div>-->
</div>
</div>
</template>
<script>
let sha1 = require('js-sha1');
import types from '../store/types.js'
export default {
name: 'Login',
data() {
return {
username: '',
password: '',
innerHeight:0
}
},
methods: {
initHeight(){
this.innerHeight=window.innerHeight;
},
login(){
this.$api.login.login({
"username":this.username,
"password":this.password,
"user_type": "user"
}).then(res => {
if(!res.ecode){
this.$store.commit(types.ATOKEN,res.atoken);
// localStorage.setItem('rtoken',m.data.rtoken)
sessionStorage.setItem('user_unid',res.user_unid)
//本系统可以直接用本地缓存做
// localStorage.setItem('user_name',this.username)
// 处理登录用户权限菜单显示问题;
//算法配置列表
this.algoList();
//存储配置列表
this.storeConfList();
//code列表
this.getCatesList();
this.getCodeList();
this.getCustomCode();
this.getEventList();
this.getDev();
this.getMenu(res.user_unid);
}
}).catch((err) => {
})
},
getMenu(id){
//获取菜单
this.$api.login.getMenus({
"shape":"tree"
}).then(res=>{
localStorage.setItem('menu', JSON.stringify(res.menu_tree[0].children))
this.$store.dispatch('GetMenuRole',res.menu_tree[0].children).then(res => {
this.$router.push('/')
})
})
},
algoList() {
this.$api.login.algocombs({
limit: '',
algo_set: 'video'
}).then(res => {
if(!res.ecode){
this.$store.commit(types.ALGO,res.list_data);
}
}).catch((err) => {
})
},
storeConfList(){
this.$api.login.storeconfs({
offset: 0,
limit: ''
}).then(res => {
if(!res.ecode){
this.$store.commit(types.STORECONF,res.list_data);
}
}).catch((err) => {
})
},
getCodeList(){
this.$api.codes.cates().then(res => {
res.list_data.forEach(item=>{
this.$api.codes.codes({
},item.cate_unid).then(res => {
// 存储code列表
window.localStorage.setItem(item.name,JSON.stringify(res.list_data))
// 存储单独code
res.list_data.forEach(chilItem=>{
window.localStorage.setItem(item.name+'-'+chilItem.code,chilItem.name)
})
}).catch((err) => {
})
})
}).catch((err) => {
})
},
getCustomCode(){
this.$api.codes.customCode().then(res => {
if(res.list_data.length > 0) {
res.list_data.forEach((item) => {
window.localStorage.setItem(item.name + '-' + item.cate, item.unid);
})
} else {
this.$message({
type: 'warning',
message: '获取自定义编码失败!'
})
}
}).catch((err) => {
})
},
getCatesList(){
this.$api.codes.eventCates({}).then(res=>{
// 存储cate列表
window.localStorage.setItem('cate列表',JSON.stringify(res.list_data))
// 存储单独code
res.list_data.forEach(item=>{
this.getOneEventList(item.code,item.event_cate_unid)
})
})
},
getOneEventList(code,id){
this.$api.codes.eventType({},id).then(res=>{
// 存储cate列表
window.localStorage.setItem(code,JSON.stringify(res.list_data))
})
},
getEventList(){
this.$api.search.eventTypes({}).then(res=>{
// 存储code列表
window.localStorage.setItem('安防事件',JSON.stringify(res.list_data))
// 存储单独code
res.list_data.forEach(item=>{
window.localStorage.setItem('安防事件-'+item.code,item.name)
})
})
},
getDev() {
this.$api.resource.devs().then(res => {
sessionStorage.setItem('dev_unid',res[0].dev_unid);
this.getDevsName(res[0].dev_unid);
})
},
getDevsName(id){
this.$api.resource.getDevsName({
is_leaf: 0
},id).then(res=>{
if(res.list_data.length>0){
sessionStorage.setItem('device_id',res.list_data[0].device_id);
}
})
},
},
watch: {},
mounted() {
},
created() {
this.initHeight();
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
.loginTitle{
height:60px;
background: #dcdcdc;
position: relative;
}
.loginTitle>div{
position: absolute;
text-align: left;
/*left: 5%;*/
height: 60px;
/*margin-top: 15px;*/
/*background: url(../assets/daer.jpg) no-repeat;*/
padding-left: 50px;
background-size: 100% 60px;
width:150px
}
.loginTitle>div span:first-child{
position: absolute;
left:50px;
top: -5px;
font-weight: bold;
font-size: 18px;
font-family: "隶书";
}
.loginTitle>div span:last-child{
font-weight: 500;
font-size: 12px;
font-family: Aparajita;
position: absolute;
left:50px;
top: 16px;
}
.form-horizontal {
width: 450px;
height: 350px;
background: url(../assets/img/login/233.png) no-repeat;
background-size: 500px 430px;
position: absolute;
left: 58%;
top: 200px;
padding-top:50px;
border-radius: 10px;
}
h1 {
color: #F5F5F5;
height: 40px;
line-height: 40px;
padding: 60px 0px;
position: absolute;
left:10%;
top:220px;
font-size:50px;
letter-spacing: 8px;
text-shadow: 5px 5px 5px #000
}
#login {
text-align: center;
position: relative;
background: url(../assets/img/login/2333.png) no-repeat 0 0;
background-size:cover
}
#login input {
color: #fff;
background: rgba(255,255,255,.5);
border-radius: 0;
border: none;
border: 1px solid #86B1DB;
box-shadow: none;
margin-top: 20px;
height: 40px;
/* line-height: 40px; */
border-radius: 5px;
font-size: 16px;
}
#login input:focus {
outline: none;
box-shadow: none;
}
button {
width: 60%;
margin-top: 40px;
background: #09cef7;
color: #fff!important;
height: 40px;
font-size: 20px;
}
button:hover {
color: #D6D9DF
}
p {
color: #fff;
margin: 0;
}
p:nth-child(1) {
padding-top: 15px
}
</style>