Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
apaas-ui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gzga-jzapi
apaas-ui
Commits
d9d55de3
Commit
d9d55de3
authored
Jun 09, 2021
by
李丹
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户修改密码 提交参数改为加密的
parent
776fa404
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
110 additions
and
11 deletions
+110
-11
src/pages/user/user_info.vue
src/pages/user/user_info.vue
+10
-2
src/utils/common.js
src/utils/common.js
+100
-9
No files found.
src/pages/user/user_info.vue
View file @
d9d55de3
...
...
@@ -202,6 +202,7 @@
<el-input
v-model=
"form.passwordOld"
autocomplete=
"new-password"
type=
"password"
></el-input>
</el-form-item>
<el-form-item
prop=
"passwordNew"
class=
"dia_item"
>
...
...
@@ -262,6 +263,7 @@
<
script
>
import
BlockRadius
from
"
@/components/general/block-radius
"
;
import
UploadFile
from
"
@/components/general/upload_file
"
;
import
CryptoJS
from
"
crypto-js
"
;
//加密js
export
default
{
components
:
{
BlockRadius
,
...
...
@@ -539,8 +541,14 @@ export default {
let
query
=
{
id
:
this
.
user_data
.
accountNo
,
form
:
{
origin_password
:
this
.
form
.
passwordOld
,
new_password
:
this
.
form
.
passwordNew
,
origin_password
:
CryptoJS
.
AES
.
encrypt
(
this
.
form
.
passwordOld
,
"
swuE9cmCZQwrkYRV
"
),
new_password
:
CryptoJS
.
AES
.
encrypt
(
this
.
form
.
passwordNew
,
"
swuE9cmCZQwrkYRV
"
),
},
};
this
.
$api
.
user
.
editUserPassword
(
query
).
then
((
response
)
=>
{
...
...
src/utils/common.js
View file @
d9d55de3
function
getRole
(){
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
true
)
{
function
getRole
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
true
)
{
resolve
(
1
)
}
else
{
}
else
{
reject
(
'
error
'
)
}
})
}
//时间戳转时间格式
var
formatDateTime_date
=
function
(
date
)
{
//时间戳转时间格式
var
formatDateTime_date
=
function
(
date
)
{
var
y
=
date
.
getFullYear
();
var
M
=
date
.
getMonth
()
+
1
;
M
=
M
<
10
?
(
'
0
'
+
M
)
:
M
;
...
...
@@ -21,10 +21,101 @@ function getRole(){
m
=
m
<
10
?
(
'
0
'
+
m
)
:
m
;
var
s
=
date
.
getSeconds
();
s
=
s
<
10
?
(
'
0
'
+
s
)
:
s
;
return
y
+
'
-
'
+
M
+
'
-
'
+
d
+
'
'
+
h
+
'
:
'
+
m
+
'
:
'
+
s
;
return
y
+
'
-
'
+
M
+
'
-
'
+
d
+
'
'
+
h
+
'
:
'
+
m
+
'
:
'
+
s
;
};
import
CryptoJS
from
'
crypto-js
'
//加密js
var
data_flag
=
true
export
{
//标准时间转换成时间戳
var
formatDateTime
=
function
(
te
)
{
if
(
te
==
''
)
{
return
''
}
else
{
var
time
=
new
Date
(
te
);
var
dateTime
=
time
.
getTime
();
return
dateTime
;
}
}
// 取得cookie
function
getCookie
(
name
)
{
if
(
document
.
cookie
.
length
>
0
)
{
var
arr
=
document
.
cookie
.
split
(
'
;
'
);
//这里显示的格式需要切割一下自己可输出看下
console
.
log
(
arr
)
for
(
var
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
var
arr2
=
arr
[
i
].
split
(
'
=
'
);
//再次切割
//这里会切割出以username为第0项的数组、以password为第0项的数组,判断查找相对应的值
if
(
arr2
[
0
]
==
'
username
'
)
{
name
=
arr2
[
1
];
//拿到账号
}
else
if
(
arr2
[
0
]
==
'
password
'
)
{
//拿到拿到加密后的密码arr2[1]并解密
var
bytes
=
CryptoJS
.
AES
.
decrypt
(
arr2
[
1
].
toString
(),
'
swuE9cmCZQwrkYRV
'
);
var
plaintext
=
bytes
.
toString
(
CryptoJS
.
enc
.
Utf8
);
//拿到解密后的密码(登录时输入的密码)
name
=
plaintext
;
}
}
}
// var nameEQ = name + '='
// var ca = document.cookie.split(';') // 把cookie分割成组
// for (var i = 0; i < ca.length; i++) {
// var c = ca[i] // 取得字符串
// while (c.charAt(0) == ' ') { // 判断一下字符串有没有前导空格
// c = c.substring(1, c.length) // 有的话,从第二位开始取
// }
// if (c.indexOf(nameEQ) == 0) { // 如果含有我们要的name
// return unescape(c.substring(nameEQ.length, c.length)) // 解码并截取我们要值
// }
// }
// return false
}
// 清除cookie
function
clearCookie
(
name
)
{
setCookie
(
name
,
""
,
-
1
);
}
// 设置cookie
function
setCookie
(
username
,
password
,
days
)
{
var
text
=
CryptoJS
.
AES
.
encrypt
(
password
,
'
swuE9cmCZQwrkYRV
'
);
//使用CryptoJS方法加密
var
saveDays
=
new
Date
();
//获取时间
saveDays
.
setTime
(
saveDays
.
getTime
()
+
24
*
60
*
60
*
1000
*
days
);
//保存的天数
console
.
log
(
saveDays
)
console
.
log
(
saveDays
.
toGMTString
())
//字符串拼接存入cookie
window
.
document
.
cookie
=
"
username
"
+
"
=
"
+
username
+
"
;path=/;expires=
"
+
saveDays
.
toGMTString
();
window
.
document
.
cookie
=
"
password
"
+
"
=
"
+
text
+
"
;path=/;expires=
"
+
saveDays
.
toGMTString
();
// seconds = seconds || 0; //seconds有值就直接赋值,没有为0,这个根php不一样。
// var expires = "";
// if (seconds != 0 ) { //设置cookie生存时间
// var date = new Date();
// date.setTime(date.getTime()+(seconds*1000));
// expires = "; expires="+date.toGMTString();
// }
// document.cookie = name+"="+escape(value)+expires+"; path=/"; //转码并赋值
}
export
{
data_flag
,
getRole
,
formatDateTime
,
getCookie
,
clearCookie
,
setCookie
,
formatDateTime_date
}
\ No newline at end of file
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment