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
9057437e
Commit
9057437e
authored
Jan 12, 2022
by
peco
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:部分登录功能
parent
0f427422
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
156 additions
and
9 deletions
+156
-9
http.api.js
common/http.api.js
+7
-1
pages.json
pages.json
+9
-0
index.vue
pages/center/index.vue
+22
-2
index.vue
pages/index/index.vue
+39
-1
authorized.vue
pages/login/authorized.vue
+22
-0
login.vue
pages/login/login.vue
+57
-5
No files found.
common/http.api.js
View file @
9057437e
...
...
@@ -5,15 +5,21 @@ const install = (Vue, vm) => {
/*************** 认证 API *****************/
// 登录
let
quickLogin
=
params
=>
vm
.
$u
.
post
(
`
${
baseUrl
}
/report/user/quickLogin`
,
params
)
// 注册
let
register
=
params
=>
vm
.
$u
.
post
(
`
${
baseUrl
}
/report/user/register`
,
params
)
// 报表列表
const
getReportList
=
params
=>
vm
.
$u
.
get
(
`
${
reportUrl
}
/report/chart/getList`
,
params
)
// 数据集
const
dataSetPreview
=
params
=>
vm
.
$u
.
post
(
`
${
reportUrl
}
/report/dataset/preview`
,
params
)
// 检查授权状态
const
getAuthorized
=
params
=>
vm
.
$u
.
get
(
`
${
baseUrl
}
/report/user/getAuthorized`
,
params
)
vm
.
$u
.
api
=
{
quickLogin
,
register
,
getReportList
,
dataSetPreview
dataSetPreview
,
getAuthorized
}
}
...
...
pages.json
View file @
9057437e
...
...
@@ -23,6 +23,15 @@
}
}
,{
"path"
:
"pages/login/authorized"
,
"style"
:
{
"navigationBarTitleText"
:
""
,
"enablePullDownRefresh"
:
false
}
}
],
"globalStyle"
:
{
"navigationBarTextStyle"
:
"black"
,
...
...
pages/center/index.vue
View file @
9057437e
<
template
>
<view>
个人中心
<u-button
class=
"my-u-block u-m-t-80"
type=
"warning"
shape=
"square"
:ripple=
"true"
@
click=
"logout()"
>
退出
</u-button>
</view>
</
template
>
...
...
@@ -15,6 +21,20 @@
},
methods
:
{
// 退出登录
logout
()
{
uni
.
removeStorageSync
(
'userId'
);
uni
.
removeStorageSync
(
'username'
);
uni
.
removeStorageSync
(
'appId'
);
uni
.
removeStorageSync
(
'authorized'
);
uni
.
removeStorageSync
(
'admin'
);
uni
.
removeStorageSync
(
'show'
);
uni
.
clearStorage
();
uni
.
reLaunch
({
url
:
'/pages/index/index'
})
}
}
}
...
...
pages/index/index.vue
View file @
9057437e
...
...
@@ -34,9 +34,47 @@
async
onLoad
()
{
this
.
getReportList
()
},
onShow
()
{
this
.
userAuthCheck
()
},
methods
:
{
//检查是否登录
userAuthCheck
()
{
var
userId
=
uni
.
getStorageSync
(
'userId'
)
this
.
getNewestAuthFromServer
()
var
authorized
=
uni
.
getStorageSync
(
'authorized'
)
if
(
userId
)
{
if
(
authorized
)
{
}
else
{
uni
.
reLaunch
({
url
:
'../login/authorized'
})
}
}
else
{
uni
.
reLaunch
({
url
:
'../login/login'
})
}
},
//获取最新的授权信息
getNewestAuthFromServer
()
{
var
param
=
{
id
:
uni
.
getStorageSync
(
'usaerId'
)
}
this
.
$u
.
api
.
getAuthorized
({
param
}).
then
(
res
=>
{
const
{
Status
,
Result
}
=
res
.
data
if
(
Status
===
'true'
)
{
uni
.
setStorageSync
(
'authorized'
,
Result
.
authorized
)
}
})
},
async
getReportList
()
{
let
res
=
await
this
.
$u
.
api
.
getReportList
({
id
:
'61
c424a4c06bff0ce05d9a53
'
})
let
res
=
await
this
.
$u
.
api
.
getReportList
({
id
:
'61
d697eec06bffb97312afeb
'
})
console
.
log
()
const
{
Status
,
Result
}
=
res
.
data
if
(
Status
===
'true'
)
{
...
...
pages/login/authorized.vue
0 → 100644
View file @
9057437e
<
template
>
<view>
授权中心
</view>
</
template
>
<
script
>
export
default
{
data
()
{
return
{
}
},
methods
:
{
}
}
</
script
>
<
style
>
</
style
>
pages/login/login.vue
View file @
9057437e
...
...
@@ -10,12 +10,14 @@
<u-form-item
label=
"用户名"
prop=
"userName"
>
<u-input
v-model=
"params.userName"
placeholder=
"请输入用户名"
type=
"text"
/>
</u-form-item>
<u-form-item
label=
"密码"
prop=
"password"
>
<u-input
v-model=
"params.password"
placeholder=
"请输入密码"
type=
"password"
:password-icon=
"true"
/>
...
...
@@ -26,9 +28,19 @@
type=
"warning"
shape=
"square"
:ripple=
"true"
@
click=
"submit"
@
click=
"submit
('login')
"
:disabled=
"!submitDisabled"
>
登入
</u-button>
<u-button
class=
"my-u-block u-m-t-80"
type=
"warning"
shape=
"square"
:ripple=
"true"
@
click=
"submit('register')"
:disabled=
"!submitDisabled"
>
注册
</u-button>
<text
class=
"tips-text"
>
使用须知:仅限企业内部人员使用,使用前需要认证用户
</text>
</view>
</view>
</
template
>
...
...
@@ -58,12 +70,27 @@ export default {
}
},
methods
:
{
submit
()
{
// 登录
submit
(
type
)
{
this
.
$refs
.
uForm
.
validate
(
async
valid
=>
{
if
(
valid
)
{
let
res
=
await
this
.
$u
.
api
.
quickLogin
(
this
.
params
)
var
info
=
{
url
:
this
.
$u
.
api
.
quickLogin
(
this
.
params
),
msg
:
'登录成功'
}
if
(
'register'
==
type
)
{
info
=
{
url
:
this
.
$u
.
api
.
register
(
this
.
params
),
msg
:
'注册成功'
}
}
let
res
=
await
info
.
url
this
.
$u
.
vuex
(
'vuex_token'
,
`
${
res
.
token_type
}
${
res
.
access_token
}
`
)
this
.
$u
.
toast
(
'登录成功'
)
this
.
$u
.
toast
(
info
.
msg
)
this
.
removeUserStorage
()
this
.
saveUserStorage
(
res
.
data
.
Result
)
// 登录成功后返回来源页面
let
timer
=
setTimeout
(()
=>
{
const
backUrl
=
uni
.
getStorageSync
(
'back_url'
)
||
'/pages/index/index'
...
...
@@ -77,7 +104,27 @@ export default {
console
.
log
(
'验证失败'
);
}
})
},
// 清除用户信息
removeUserStorage
()
{
uni
.
removeStorageSync
(
'userId'
);
uni
.
removeStorageSync
(
'username'
);
uni
.
removeStorageSync
(
'appId'
);
uni
.
removeStorageSync
(
'authorized'
);
uni
.
removeStorageSync
(
'admin'
);
uni
.
removeStorageSync
(
'show'
);
},
// 存储用户信息
saveUserStorage
(
info
)
{
uni
.
setStorageSync
(
'userId'
,
info
.
id
);
uni
.
setStorageSync
(
'username'
,
info
.
userName
);
uni
.
setStorageSync
(
'appId'
,
info
.
appId
);
uni
.
setStorageSync
(
'authorized'
,
info
.
authorized
);
uni
.
setStorageSync
(
'admin'
,
info
.
admin
);
uni
.
setStorageSync
(
'show'
,
info
.
show
);
}
},
onReady
()
{
this
.
$refs
.
uForm
.
setRules
(
this
.
rules
)
...
...
@@ -86,4 +133,9 @@ export default {
</
script
>
<
style
lang=
"scss"
scoped
>
.tips-text
{
color
:
black
;
size
:
20rpx
;
padding-top
:
50rpx
;
}
</
style
>
\ 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