Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
E
ec-report-refactor
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
lihuizhen
ec-report-refactor
Commits
cf970f11
Commit
cf970f11
authored
Jan 17, 2022
by
peco
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:授权 和 admin 相关处理
parent
6f19e4e6
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
162 additions
and
10 deletions
+162
-10
http.api.js
common/http.api.js
+10
-1
index.vue
pages/center/index.vue
+46
-3
customer.vue
pages/customer/customer.vue
+106
-6
No files found.
common/http.api.js
View file @
cf970f11
...
...
@@ -17,6 +17,12 @@ const install = (Vue, vm) => {
const
getUserListCount
=
params
=>
vm
.
$u
.
get
(
`
${
baseUrl
}
/report/user/getUserListCount`
,
params
)
// 修改密码
const
changePassword
=
params
=>
vm
.
$u
.
post
(
`
${
baseUrl
}
/report/user/changePassword`
,
params
)
// 获取用户数据
const
getAuthorizedList
=
params
=>
vm
.
$u
.
get
(
`
${
baseUrl
}
/report/user/getAuthorizedList`
,
params
)
// 授权/取消授权
const
authorizeOrUnauthorize
=
params
=>
vm
.
$u
.
post
(
`
${
baseUrl
}
/report/user/authorizeOrUnauthorize`
,
params
)
// 获取OPENID
const
getOpenId
=
params
=>
vm
.
$u
.
get
(
`
${
baseUrl
}
/report/user/getOpenId`
,
params
)
vm
.
$u
.
api
=
{
quickLogin
,
...
...
@@ -25,7 +31,10 @@ const install = (Vue, vm) => {
dataSetPreview
,
getAuthorized
,
getUserListCount
,
changePassword
changePassword
,
getAuthorizedList
,
authorizeOrUnauthorize
,
getOpenId
}
}
...
...
pages/center/index.vue
View file @
cf970f11
...
...
@@ -8,6 +8,11 @@
</view>
</block>
</view>
<view
class=
"subscribe"
v-if=
"admin"
@
tap=
'subscribe()'
>
订阅消息
</view>
<u-button
class=
"my-u-block u-m-t-80"
type=
"warning"
...
...
@@ -47,7 +52,7 @@
{
'text'
:
'待授权'
,
'show'
:
true
,
'count'
:
'0'
},
{
'text'
:
'已授权'
,
'show'
:
true
,
'count'
:
'0'
}];
this
.
$u
.
api
.
getUserListCount
(
{
param
}
).
then
(
res
=>
{
this
.
$u
.
api
.
getUserListCount
(
param
).
then
(
res
=>
{
const
{
Status
,
Result
}
=
res
.
data
if
(
Status
===
'true'
)
{
itemList
[
1
].
count
=
Result
.
no_authorized
;
...
...
@@ -85,6 +90,32 @@
break
;
}
},
// 订阅消息
subscribe
()
{
var
that
=
this
uni
.
login
({
provider
:
'weixin'
,
success
:
function
(
res
)
{
var
code
=
res
.
code
var
param
=
{
code
:
code
,
id
:
uni
.
getStorageSync
(
'userId'
)
}
that
.
$u
.
api
.
getOpenId
(
param
).
then
(
res
=>
{
const
{
Status
,
Result
}
=
res
.
data
if
(
Status
===
'true'
)
{
}
})
}
})
uni
.
requestSubscribeMessage
({
tmplIds
:
[
'GSPZ_GSbsgfRSu8wugGPe2zqmReDbY8yeIEqd8pPPM8'
],
success
(
res
)
{
console
.
log
(
'授权结果'
+
res
[
'GSPZ_GSbsgfRSu8wugGPe2zqmReDbY8yeIEqd8pPPM8'
])
}
})
},
// 退出登录
logout
()
{
uni
.
removeStorageSync
(
'userId'
);
...
...
@@ -121,10 +152,22 @@
}
.item-cell-text
{
margin-left
:
20rpx
;
font-size
:
2
4
rpx
;
font-size
:
2
8
rpx
;
}
.item-cell-list-count
{
margin-left
:
300rpx
;
font-size
:
24rpx
;
font-size
:
28rpx
;
}
.subscribe
{
width
:
30%
;
text-align
:
center
;
font-size
:
30rpx
;
border
:
0
.1rpx
solid
#cccccc
;
border-radius
:
10rpx
;
margin
:
60rpx
;
padding
:
25rpx
0rpx
25rpx
0rpx
;
display
:
flex
;
justify-content
:
center
;
margin-left
:
35%
;
}
</
style
>
\ No newline at end of file
pages/customer/customer.vue
View file @
cf970f11
<
template
>
<view>
授权列表
<view
class=
"wrap"
>
<view
class=
"item-list"
>
<block
v-for=
"(item,index) in userList"
>
<view
class=
"item-cell"
>
<view
class=
"item-name"
>
{{
item
.
userName
}}
</view>
<view
class=
"item-button"
@
tap =
"authorized(item.id, item.authorized, index)"
v-if=
"item.authorized"
>
取消授权
</view>
<view
class=
"item-button"
@
tap =
"authorized(item.id, item.authorized, index)"
v-else
>
授权
</view>
</view>
</block>
</view>
</view>
</
template
>
...
...
@@ -8,15 +16,107 @@
export
default
{
data
()
{
return
{
confirmed
:
''
,
userList
:
[]
}
},
onLoad
(
option
)
{
var
copfirmed
=
option
.
confirmed
this
.
$data
.
confirmed
=
copfirmed
},
onShow
()
{
this
.
judgeAndLoad
()
},
methods
:
{
// 判断权限和加载数据
judgeAndLoad
()
{
var
isAdmin
=
uni
.
getStorageSync
(
'admin'
)
if
(
isAdmin
)
{
this
.
getUserList
()
}
else
{
this
.
$u
.
toast
(
'您没有操作权限'
)
uni
.
navigateBack
({
})
}
if
(
this
.
$data
.
confirmed
===
'true'
)
{
uni
.
setNavigationBarTitle
({
title
:
'已授权列表'
})
}
else
{
uni
.
setNavigationBarTitle
({
title
:
'待授权列表'
})
}
},
// 获取列表
getUserList
()
{
var
userId
=
uni
.
getStorageSync
(
'userId'
)
var
param
=
{
id
:
userId
,
authorized
:
this
.
$data
.
confirmed
}
this
.
$u
.
api
.
getAuthorizedList
(
param
).
then
(
res
=>
{
const
{
Status
,
Result
}
=
res
.
data
if
(
Status
===
'true'
||
Result
.
length
>
0
)
{
this
.
$data
.
userList
=
Result
}
else
{
this
.
$data
.
userList
=
[]
}
})
},
// 授权
authorized
(
id
,
authorized
,
index
)
{
var
type
=
authorized
?
'unthorize'
:
'authorize'
var
operatorId
=
uni
.
getStorageSync
(
'userId'
)
var
param
=
{
type
:
type
,
id
:
id
,
operatorId
:
operatorId
}
this
.
$u
.
api
.
authorizeOrUnauthorize
(
param
).
then
(
res
=>
{
const
{
Status
,
Result
}
=
res
.
data
if
(
Status
===
'true'
)
{
this
.
$data
.
userList
.
splice
(
index
,
1
)
this
.
$u
.
toast
(
'操作成功'
)
}
else
{
this
.
$u
.
toast
(
'操作失败'
)
}
})
}
},
// 下拉刷新
onPullDownRefresh
()
{
this
.
judgeAndLoad
()
uni
.
stopPullDownRefresh
()
}
}
</
script
>
<
style
>
<
style
lang=
"scss"
scoped
>
.item-list
{
display
:
flex
;
flex-direction
:
column
;
}
.item-cell
{
display
:
flex
;
position
:
relative
;
justify-content
:
space-between
;
width
:
100%
;
height
:
100rpx
;
align-items
:
center
;
border-bottom
:
0
.1rpx
solid
#cccccc
;
}
.item-name
{
margin-left
:
20rpx
;
font-size
:
28rpx
;
}
.item-button
{
margin-right
:
40rpx
;
font-size
:
28rpx
;
border
:
0
.1rpx
solid
#cccccc
;
border-radius
:
5rpx
;
padding
:
10rpx
20rpx
10rpx
20rpx
;
}
</
style
>
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