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
d2380993
Commit
d2380993
authored
Nov 16, 2018
by
Davve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成账户中心后端编写
parent
d4e96189
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
61 additions
and
22 deletions
+61
-22
account.py
api/account.py
+34
-0
urls.py
api/urls.py
+4
-0
account.js
vu/src/api/account.js
+9
-0
pick.js
vu/src/api/pick.js
+0
-1
getters.js
vu/src/store/getters.js
+1
-0
user.js
vu/src/store/modules/user.js
+8
-1
list.vue
vu/src/views/account/list.vue
+4
-19
Navbar.vue
vu/src/views/layout/components/Navbar.vue
+1
-1
No files found.
api/account.py
View file @
d2380993
...
...
@@ -6,6 +6,38 @@
from
utils.base
import
APIView
class
AccountList
(
APIView
):
def
get
(
self
,
request
):
page
=
request
.
GET
.
get
(
'page'
,
1
)
limit
=
request
.
GET
.
get
(
'limit'
,
10
)
filter
=
self
.
handle_filter
(
request
.
GET
.
get
(
'filter'
,
""
))
try
:
data
=
self
.
rpc
[
'venus/community/pick/get'
](
offset
=
page
,
limit
=
limit
,
filters
=
filter
)
.
unwrap
()
except
Exception
as
e
:
# raise e
data
=
{
'total'
:
100
,
'data'
:
[
{
'id'
:
1
,
'nickname'
:
'鹿晗1'
,
'password'
:
'21233423'
,
'email'
:
'www.baidu.com'
,
'username'
:
'admin1'
},
{
'id'
:
2
,
'nickname'
:
'鹿晗2'
,
'password'
:
'21233423'
,
'email'
:
'www.baidu.com'
,
'username'
:
'admin2'
},
{
'id'
:
3
,
'nickname'
:
'鹿晗3'
,
'password'
:
'21233423'
,
'email'
:
'www.baidu.com'
,
'username'
:
'admin3'
},
{
'id'
:
4
,
'nickname'
:
'鹿晗4'
,
'password'
:
'21233423'
,
'email'
:
'www.baidu.com'
,
'username'
:
'admin4'
},
]
}
return
data
def
post
(
self
,
request
):
ids
=
request
.
POST
.
get
(
'ids'
,
''
)
.
split
()
type
=
request
.
POST
.
get
(
'type'
,
''
)
try
:
self
.
rpc
[
'venus/community/account/offline_account'
](
type
=
type
,
ids
=
ids
)
.
unwrap
()
except
Exception
as
e
:
raise
e
return
{
"message"
:
"更新成功"
}
class
LoginView
(
APIView
):
def
post
(
self
,
request
):
username
=
request
.
POST
.
get
(
'username'
)
...
...
@@ -13,6 +45,7 @@ class LoginView(APIView):
if
username
==
'admin'
and
password
==
'123123'
:
return
{
'id'
:
1
,
'roles'
:
[
'admin'
],
'token'
:
'admin'
,
'introduction'
:
'我是超级管理员'
,
...
...
@@ -21,6 +54,7 @@ class LoginView(APIView):
}
else
:
return
{
'id'
:
2
,
'roles'
:
[
'editor'
],
'token'
:
'editor'
,
'introduction'
:
'我是编辑'
,
...
...
api/urls.py
View file @
d2380993
...
...
@@ -18,6 +18,10 @@ urlpatterns = [
# 登陆,注销相关
url
(
r'account/login$'
,
LoginView
.
as_view
()),
url
(
r'account/logout'
,
LogoutView
.
as_view
()),
url
(
r'account/list'
,
AccountList
.
as_view
()),
url
(
r'account/update'
,
AccountList
.
as_view
()),
url
(
r'account/get'
,
UpdateOrCreateView
.
as_view
()),
url
(
r'account/create'
,
UpdateOrCreateView
.
as_view
()),
# user相关
url
(
r'user/list$'
,
UserListView
.
as_view
()),
...
...
vu/src/api/account.js
View file @
d2380993
...
...
@@ -8,3 +8,12 @@ export function fetchList(query) {
})
}
export
function
OffLineOrOnLine
(
data
)
{
console
.
log
(
data
)
return
request
({
url
:
'/api/account/update'
,
method
:
'post'
,
data
})
}
vu/src/api/pick.js
View file @
d2380993
...
...
@@ -8,7 +8,6 @@ export function fetchList(query) {
})
}
export
function
OffLineOrOnLine
(
data
)
{
console
.
log
(
data
)
return
request
({
...
...
vu/src/store/getters.js
View file @
d2380993
...
...
@@ -8,6 +8,7 @@ const getters = {
token
:
state
=>
state
.
user
.
token
,
avatar
:
state
=>
state
.
user
.
avatar
,
name
:
state
=>
state
.
user
.
name
,
id
:
state
=>
state
.
user
.
id
,
introduction
:
state
=>
state
.
user
.
introduction
,
status
:
state
=>
state
.
user
.
status
,
roles
:
state
=>
state
.
user
.
roles
,
...
...
vu/src/store/modules/user.js
View file @
d2380993
...
...
@@ -3,6 +3,7 @@ import { getToken, setToken, removeToken } from '@/utils/auth'
const
user
=
{
state
:
{
id
:
''
,
user
:
''
,
status
:
''
,
code
:
''
,
...
...
@@ -40,7 +41,10 @@ const user = {
},
SET_ROLES
:
(
state
,
roles
)
=>
{
state
.
roles
=
roles
}
},
SET_ID
:
(
state
,
id
)
=>
{
state
.
id
=
id
},
},
actions
:
{
...
...
@@ -51,6 +55,7 @@ const user = {
loginByUsername
(
username
,
userInfo
.
password
).
then
(
response
=>
{
const
data
=
response
.
data
.
data
commit
(
'SET_TOKEN'
,
data
.
token
)
commit
(
'SET_ID'
,
data
.
id
)
setToken
(
response
.
data
.
token
)
resolve
()
}).
catch
(
error
=>
{
...
...
@@ -75,6 +80,7 @@ const user = {
}
commit
(
'SET_NAME'
,
data
.
name
)
commit
(
'SET_ID'
,
data
.
id
)
commit
(
'SET_AVATAR'
,
data
.
avatar
)
commit
(
'SET_INTRODUCTION'
,
data
.
introduction
)
resolve
(
response
)
...
...
@@ -129,6 +135,7 @@ const user = {
getUserInfo
(
role
).
then
(
response
=>
{
const
data
=
response
.
data
commit
(
'SET_ROLES'
,
data
.
roles
)
commit
(
'SET_ID'
,
data
.
id
)
commit
(
'SET_NAME'
,
data
.
name
)
commit
(
'SET_AVATAR'
,
data
.
avatar
)
commit
(
'SET_INTRODUCTION'
,
data
.
introduction
)
...
...
vu/src/views/account/list.vue
View file @
d2380993
...
...
@@ -20,7 +20,7 @@
</
template
>
</el-table-column>
<el-table-column
width=
"307px"
align=
"center"
label=
"
昵称
"
>
<el-table-column
width=
"307px"
align=
"center"
label=
"
用户名
"
>
<
template
slot-scope=
"scope"
>
<span>
{{
scope
.
row
.
username
}}
</span>
</
template
>
...
...
@@ -28,7 +28,7 @@
<el-table-column
width=
"280px"
align=
"center"
label=
"密码"
>
<
template
slot-scope=
"scope"
>
<span>
{{
scope
.
row
.
p
hone
}}
</span>
<span>
{{
scope
.
row
.
p
assword
}}
</span>
</
template
>
</el-table-column>
...
...
@@ -47,7 +47,7 @@
</template>
<
script
>
import
{
fetchList
,
OffLineOrOnLine
}
from
'@/api/
user
'
import
{
fetchList
,
OffLineOrOnLine
}
from
'@/api/
account
'
import
Pagination
from
'@/components/Pagination'
// Secondary package based on el-pagination
import
waves
from
'@/directive/waves'
...
...
@@ -93,22 +93,8 @@ export default {
{
'key'
:
1
,
'display_name'
:
'是'
},
{
'key'
:
0
,
'display_name'
:
'否'
}
],
ReBooleanTypeOptions
:
[
{
'key'
:
1
,
'display_name'
:
'是'
},
{
'key'
:
0
,
'display_name'
:
'否'
}
],
IdentifyTypeOptions
:
[
{
'key'
:
1
,
'display_name'
:
'组长'
},
{
'key'
:
2
,
'display_name'
:
'管理员'
},
{
'key'
:
3
,
'display_name'
:
'长老'
},
{
'key'
:
4
,
'display_name'
:
'普通群员'
},
],
UserTypeOptions
:
[
{
'key'
:
0
,
'display_name'
:
'普通用户'
},
{
'key'
:
1
,
'display_name'
:
'马甲用户'
}
],
SearchTypeOptions
:[
{
'key'
:
'
nickname'
,
'display_name'
:
'昵称
'
},
{
'key'
:
'
username'
,
'display_name'
:
'用户名
'
},
]
}
},
...
...
@@ -156,7 +142,6 @@ export default {
}
OffLineOrOnLine
({
type
:
val
,
ids
:
str
}).
then
(
response
=>
{
this
.
multipleSelection
=
[];
response
.
data
.
data
.
message
this
.
$message
.
success
(
response
.
data
.
data
.
message
);
})
},
...
...
vu/src/views/layout/components/Navbar.vue
View file @
d2380993
...
...
@@ -33,7 +33,7 @@
账号中心
</el-dropdown-item>
</router-link>
<router-link
:to=
"'/account/edit/'+
1
"
class=
"link-type"
>
<router-link
:to=
"'/account/edit/'+
this.$store.getters.id
"
class=
"link-type"
>
<el-dropdown-item>
修改密码
</el-dropdown-item>
...
...
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