Commit d2380993 authored by Davve's avatar Davve

完成账户中心后端编写

parent d4e96189
......@@ -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': '我是编辑',
......
......@@ -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()),
......
......@@ -8,3 +8,12 @@ export function fetchList(query) {
})
}
export function OffLineOrOnLine(data) {
console.log(data)
return request({
url: '/api/account/update',
method: 'post',
data
})
}
......@@ -8,7 +8,6 @@ export function fetchList(query) {
})
}
export function OffLineOrOnLine(data) {
console.log(data)
return request({
......
......@@ -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,
......
......@@ -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)
......
......@@ -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.phone }}</span>
<span>{{ scope.row.password }}</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);
})
},
......
......@@ -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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment