Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
sun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
谢林臻
sun
Commits
2230190d
Commit
2230190d
authored
Nov 16, 2018
by
Davve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成密码修改功能
parent
7631019b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
42 deletions
+23
-42
account.py
api/account.py
+18
-3
user.js
vu/src/store/modules/user.js
+5
-21
AccountDetail.vue
vu/src/views/account/components/AccountDetail.vue
+0
-1
list.vue
vu/src/views/account/list.vue
+0
-17
No files found.
api/account.py
View file @
2230190d
...
...
@@ -79,8 +79,14 @@ class AccountUpdateOrCreateView(APIView):
class
LoginView
(
APIView
):
def
get
(
self
,
request
):
"""
获取用户信息
:param request:
:return:
"""
map
=
{
'admin'
:
{
'id'
:
1
,
'roles'
:
[
'admin'
],
'token'
:
'admin'
,
'introduction'
:
'我是超级管理员'
,
...
...
@@ -88,6 +94,7 @@ class LoginView(APIView):
'name'
:
'Super Admin'
},
'editor'
:
{
'id'
:
2
,
'roles'
:
[
'editor'
],
'token'
:
'editor'
,
'introduction'
:
'我是编辑'
,
...
...
@@ -97,15 +104,20 @@ class LoginView(APIView):
}
token
=
request
.
GET
.
get
(
'token'
)
return
{
'data'
:
map
[
'admin'
]
'data'
:
map
[
token
]
}
def
post
(
self
,
request
):
"""
登陆
:param request:
:return:
"""
username
=
request
.
POST
.
get
(
'username'
)
password
=
request
.
POST
.
get
(
'password'
)
if
username
==
'admin'
and
password
==
'123123'
:
return
{
data
=
{
'id'
:
1
,
'roles'
:
[
'admin'
],
'token'
:
'admin'
,
...
...
@@ -114,7 +126,7 @@ class LoginView(APIView):
'name'
:
'Super Admin'
}
else
:
return
{
data
=
{
'id'
:
2
,
'roles'
:
[
'editor'
],
'token'
:
'editor'
,
...
...
@@ -122,6 +134,9 @@ class LoginView(APIView):
'avatar'
:
'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif'
,
'name'
:
'Normal Editor'
}
return
{
'data'
:
data
}
class
LogoutView
(
APIView
):
...
...
vu/src/store/modules/user.js
View file @
2230190d
...
...
@@ -3,8 +3,8 @@ import { getToken, setToken, removeToken } from '@/utils/auth'
const
user
=
{
state
:
{
id
:
''
,
user
:
''
,
id
:
''
,
status
:
''
,
code
:
''
,
token
:
getToken
(),
...
...
@@ -44,7 +44,7 @@ const user = {
},
SET_ID
:
(
state
,
id
)
=>
{
state
.
id
=
id
}
,
}
},
actions
:
{
...
...
@@ -53,11 +53,10 @@ const user = {
const
username
=
userInfo
.
username
.
trim
()
return
new
Promise
((
resolve
,
reject
)
=>
{
loginByUsername
(
username
,
userInfo
.
password
).
then
(
response
=>
{
const
data
=
response
.
data
console
.
log
(
data
)
const
data
=
response
.
data
.
data
.
data
commit
(
'SET_TOKEN'
,
data
.
token
)
commit
(
'SET_ID'
,
data
.
id
)
setToken
(
response
.
data
.
token
)
setToken
(
data
.
token
)
resolve
()
}).
catch
(
error
=>
{
reject
(
error
)
...
...
@@ -78,7 +77,6 @@ const user = {
}
else
{
reject
(
'getInfo: roles must be a non-null array !'
)
}
commit
(
'SET_NAME'
,
data
.
name
)
commit
(
'SET_ID'
,
data
.
id
)
commit
(
'SET_AVATAR'
,
data
.
avatar
)
...
...
@@ -90,20 +88,6 @@ const user = {
})
},
// 第三方验证登录
// LoginByThirdparty({ commit, state }, code) {
// return new Promise((resolve, reject) => {
// commit('SET_CODE', code)
// loginByThirdparty(state.status, state.email, state.code).then(response => {
// commit('SET_TOKEN', response.data.token)
// setToken(response.data.token)
// resolve()
// }).catch(error => {
// reject(error)
// })
// })
// },
// 登出
LogOut
({
commit
,
state
})
{
return
new
Promise
((
resolve
,
reject
)
=>
{
...
...
@@ -133,7 +117,7 @@ const user = {
commit
(
'SET_TOKEN'
,
role
)
setToken
(
role
)
getUserInfo
(
role
).
then
(
response
=>
{
const
data
=
response
.
data
const
data
=
response
.
data
.
data
commit
(
'SET_ROLES'
,
data
.
roles
)
commit
(
'SET_ID'
,
data
.
id
)
commit
(
'SET_NAME'
,
data
.
name
)
...
...
vu/src/views/account/components/AccountDetail.vue
View file @
2230190d
...
...
@@ -132,7 +132,6 @@ export default {
methods
:
{
fetchData
(
id
)
{
fetchAccountDetail
(
id
).
then
(
response
=>
{
console
.
log
(
response
.
data
.
data
)
this
.
postForm
=
response
.
data
.
data
.
data
}).
catch
(
err
=>
{
...
...
vu/src/views/account/list.vue
View file @
2230190d
...
...
@@ -54,23 +54,6 @@ import waves from '@/directive/waves'
export
default
{
name
:
'UserList'
,
components
:
{
Pagination
},
filters
:
{
isOnlineFilter
(
status
)
{
const
statusMap
=
{
1
:
'success'
,
0
:
'info'
,
}
return
statusMap
[
status
]
},
genderFilter
(
status
)
{
const
statusMap
=
{
'男'
:
'success'
,
'女'
:
'info'
,
'全部'
:
'danger'
}
return
statusMap
[
status
]
},
},
directives
:
{
waves
},
data
()
{
return
{
...
...
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