-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
增加了一个路由监控,类似于vue-router中的路由卫士,利用监测路径的变化来是否执行监控用户是否授权登陆,如果没登陆就弹出授权界面。
- Loading branch information
dengguochao23
committed
Nov 29, 2020
1 parent
6d2cfbd
commit b9665c4
Showing
22 changed files
with
358 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { | ||
getToken | ||
} from '../../api/token' | ||
import { | ||
_getUserInfo | ||
} from '../../util/getUser' | ||
import { | ||
saveUserByNickname, | ||
saveUserByImage | ||
} from '../../api/user' | ||
let data = { | ||
nickname: null, | ||
logo: null | ||
} | ||
Page({ | ||
onGotUserInfo() { | ||
wx.login({ | ||
complete: (res) => { | ||
_getUserInfo().then(res => { | ||
data.nickname = res.userInfo.nickName | ||
data.logo = res.userInfo.avatarUrl | ||
}).then(() => { | ||
saveUserByImage(data.logo) | ||
}).then(() => { | ||
saveUserByNickname(data.nickname) | ||
}).then(()=>{ | ||
wx.navigateBack() | ||
}) | ||
}, | ||
success: (res) =>{ | ||
if (res.code) { | ||
getToken(res.code).then((res) => { | ||
wx.setStorage({ | ||
data: res.token, | ||
key: 'token', | ||
}) | ||
}) | ||
} | ||
} | ||
}) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"usingComponents": { | ||
"van-image": "../../miniprogram_npm/@vant/weapp/image", | ||
"van-divider": "../../miniprogram_npm/@vant/weapp/divider" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<view class="login bg"> | ||
<view class="logo"> | ||
<image src="{{tool.img()}}" /> | ||
</view> | ||
<view class="title"> | ||
<text>七享网</text> | ||
</view> | ||
<view class="context"> | ||
<van-divider borderColor="#D3D3D3"></van-divider> | ||
<text>登陆后应用获得以下权限</text> | ||
<text>1、获得你的公开信息(昵称、头像等)</text> | ||
<text>2、可以完全享用该项目</text> | ||
<text>3、放心我绝不会盗用您的微信信息另做它用的,亲~</text> | ||
</view> | ||
<button class="but" plain="true" open-type="getUserInfo" lang="zh_CN" bindgetuserinfo="onGotUserInfo">确认登陆</button> | ||
</view> | ||
<wxs module="tool"> | ||
var img = function () { | ||
return '../../image/logo/logo.png' | ||
} | ||
module.exports = { | ||
img: img | ||
} | ||
</wxs> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
.login{ | ||
position: fixed; | ||
top: 0px; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
} | ||
.logo{ | ||
width: 100%; | ||
text-align: center; | ||
margin-top: 100rpx; | ||
margin-bottom: 20px; | ||
} | ||
.logo image { | ||
width: 100px; | ||
height: 100px; | ||
background-color: #fff; | ||
border-radius: 50%; | ||
} | ||
.login .title{ | ||
font-size: 50rpx; | ||
font-weight: 700; | ||
color: #1c92d2; | ||
} | ||
.context{ | ||
width: 70%; | ||
} | ||
.context text{ | ||
display: block; | ||
color: #D3D3D3; | ||
font-size: 24rpx; | ||
} | ||
.context text:nth-last-child(4){ | ||
font-size: 36rpx; | ||
font-weight: 700; | ||
color: black; | ||
margin-bottom: 12px; | ||
} | ||
.but{ | ||
width: 70%; | ||
height: 46px; | ||
border: none !important; | ||
background-color: #1c92d2 !important; | ||
color: white !important; | ||
margin-top: 80px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.