Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
study
Project
Project
Details
Activity
Releases
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
Damon
study
Commits
cdf251ba
Commit
cdf251ba
authored
Jul 10, 2021
by
Damon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 登录流程
parent
9497f9d6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
57 deletions
+97
-57
App.vue
src/App.vue
+23
-0
mine.vue
src/pages/index/mine.vue
+61
-55
index.vue
src/pages/login/index.vue
+13
-2
No files found.
src/App.vue
View file @
cdf251ba
...
@@ -3,6 +3,8 @@ export default {
...
@@ -3,6 +3,8 @@ export default {
onLaunch
:
function
()
{
onLaunch
:
function
()
{
// 版本更新
// 版本更新
this
.
updateApp
()
this
.
updateApp
()
// 检查登录是否已过期
this
.
checkLogin
()
},
},
onShow
:
function
()
{
onShow
:
function
()
{
console
.
log
(
'App Show'
)
console
.
log
(
'App Show'
)
...
@@ -11,6 +13,27 @@ export default {
...
@@ -11,6 +13,27 @@ export default {
console
.
log
(
'App Hide'
)
console
.
log
(
'App Hide'
)
},
},
methods
:
{
methods
:
{
checkLogin
()
{
if
(
this
.
vuex_token
)
{
uni
.
checkSession
({
success
:
(
result
)
=>
{
//session_key 未过期,并且在本生命周期一直有效
console
.
log
(
"session未过期"
,
result
)
},
fail
:
(
error
)
=>
{
// session_key 已经失效,需要重新执行登录流程
console
.
log
(
"error"
,
error
)
this
.
$u
.
route
({
url
:
'pages/login/index'
})
}
})
}
else
{
this
.
$u
.
route
({
url
:
'pages/login/index'
})
}
},
/* 版本更新 */
/* 版本更新 */
updateApp
()
{
updateApp
()
{
if
(
uni
.
canIUse
(
'getUpdateManager'
))
{
if
(
uni
.
canIUse
(
'getUpdateManager'
))
{
...
...
src/pages/index/mine.vue
View file @
cdf251ba
<
template
>
<
template
>
<view>
<view>
<view
class=
"u-flex user-box u-p-l-30 u-p-t-30 u-p-r-20 u-p-b-30"
>
<view
class=
"u-flex user-box u-p-l-30 u-p-t-30 u-p-r-20 u-p-b-30"
@
tap=
"login"
>
<view
class=
"u-m-r-10"
>
<view
class=
"u-m-r-10"
>
<view
class=
"avatar"
>
<u-avatar
:src=
"avatar"
size=
"140"
></u-avatar>
<open-data
type=
"userAvatarUrl"
></open-data>
</view>
</view>
<view
class=
"u-flex-1"
>
</view>
<view
class=
"u-font-18 u-p-b-20"
>
{{
nikeName
}}
</view>
<view
class=
"u-flex-1"
>
<view
class=
"u-font-14 u-tips-color"
>
累计刷题俩999次
</view>
<view
class=
"u-font-18 u-p-b-20"
>
</view>
<open-data
type=
"userNickName"
></open-data>
</view>
</view>
<view
class=
"u-font-14 u-tips-color"
>
累计刷题俩999次
</view>
<view
class=
"u-m-t-20"
>
</view>
<u-cell-group>
</view>
<u-cell-item
icon=
"star"
title=
"个人信息"
value=
"完善度40%"
></u-cell-item>
<u-cell-item
icon=
"photo"
title=
"我的题库"
></u-cell-item>
<view
class=
"u-m-t-20"
>
<u-cell-item
icon=
"coupon"
title=
"联系客服"
></u-cell-item>
<u-cell-group>
<u-cell-item
icon=
"coupon"
title=
"退出登录"
@
tap=
"logout"
></u-cell-item>
<u-cell-item
icon=
"star"
title=
"个人信息"
value=
"完善度40%"
@
tap=
"login"
></u-cell-item>
</u-cell-group>
<u-cell-item
icon=
"photo"
title=
"我的题库"
></u-cell-item>
</view>
<u-cell-item
icon=
"coupon"
title=
"联系客服"
></u-cell-item>
</view>
</u-cell-group>
</view>
</view>
</
template
>
</
template
>
<
script
>
<
script
>
export
default
{
export
default
{
data
()
{
data
()
{
return
{
return
{
pic
:
'https://uviewui.com/common/logo.png'
,
pic
:
'https://uviewui.com/common/logo.png'
,
show
:
true
,
show
:
true
}
}
},
},
computed
:
{},
computed
:
{
onLoad
()
{},
avatar
()
{
methods
:
{
return
this
.
userInfo
.
avatarUrl
||
this
.
pic
login
()
{
},
this
.
$u
.
route
({
nikeName
()
{
url
:
'pages/login/index'
,
return
this
.
userInfo
.
nickName
||
'未登录'
})
}
},
},
},
onLoad
()
{
}
},
methods
:
{
login
()
{
this
.
$u
.
route
({
url
:
'pages/login/index'
})
},
logout
()
{
this
.
$u
.
vuex
(
'vuex_token'
,
''
)
this
.
$u
.
vuex
(
'userInfo'
,
{})
}
}
}
</
script
>
</
script
>
<
style
lang=
"scss"
>
<
style
lang=
"scss"
>
page
{
page
{
background-color
:
#ededed
;
background-color
:
#ededed
;
}
}
.camera
{
.camera
{
width
:
54px
;
width
:
54px
;
height
:
44px
;
height
:
44px
;
&
:active
{
&
:active
{
background-color
:
#ededed
;
background-color
:
#ededed
;
}
}
}
}
.user-box
{
.user-box
{
background-color
:
#fff
;
background-color
:
#fff
;
.avatar
{
width
:
120rpx
;
height
:
120rpx
;
}
}
}
</
style
>
</
style
>
\ No newline at end of file
src/pages/login/index.vue
View file @
cdf251ba
...
@@ -18,22 +18,33 @@ export default {
...
@@ -18,22 +18,33 @@ export default {
}
}
},
},
onShow
()
{
onShow
()
{
console
.
log
(
"this"
,
this
)
this
.
checkLogin
(
)
},
},
methods
:
{
methods
:
{
checkLogin
()
{
if
(
this
.
vuex_token
)
{
uni
.
checkSession
({
success
:
(
result
)
=>
{
this
.
$u
.
route
({
type
:
'back'
})
}
})
}
},
wxLogin
()
{
wxLogin
()
{
// 获取code 小程序专有,用户登录凭证。
// 获取code 小程序专有,用户登录凭证。
uni
.
getUserProfile
({
uni
.
getUserProfile
({
desc
:
'获取用户基本资料'
,
desc
:
'获取用户基本资料'
,
lang
:
'zh_CN'
,
lang
:
'zh_CN'
,
success
:
(
user
)
=>
{
success
:
(
user
)
=>
{
//获取成功基本资料后开启登录,因为基本资料首先要授权
//
获取成功基本资料后开启登录,因为基本资料首先要授权
uni
.
login
({
uni
.
login
({
provider
:
'weixin'
,
provider
:
'weixin'
,
success
:
(
code_res
)
=>
{
success
:
(
code_res
)
=>
{
if
(
code_res
.
errMsg
==
'login:ok'
)
{
if
(
code_res
.
errMsg
==
'login:ok'
)
{
let
code
=
code_res
.
code
let
code
=
code_res
.
code
console
.
log
(
'user, code'
,
user
,
code
)
console
.
log
(
'user, code'
,
user
,
code
)
this
.
$u
.
vuex
(
'vuex_token'
,
code
)
this
.
$u
.
vuex
(
'userInfo'
,
user
.
userInfo
)
this
.
$u
.
route
({
this
.
$u
.
route
({
type
:
'back'
type
:
'back'
})
})
...
...
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