This commit is contained in:
张慢慢
2021-05-25 14:00:28 +08:00
parent 4b6e9d9e91
commit e4752f75b7
3 changed files with 38 additions and 31 deletions

View File

@@ -43,20 +43,24 @@ Page({
},
/**
* 登录
* 微信授权登录
*/
userInfo(e){
if(e.detail.errMsg == "getUserInfo:ok"){
getuserInfo() {
wx.getUserProfile({
desc : "获取你的昵称、头像、地区及性别",
success : e => {
console.log(e)
if(e.errMsg == "getUserProfile:ok"){
this.setData({
isLogin : true,
userInfo : e.detail.rawData,
iv : e.detail.iv,
encryptedData : e.detail.encryptedData
userInfo : e.rawData,
iv : e.iv,
encryptedData : e.encryptedData
})
// 检查用户登录Code是否过期
wx.checkSession({
success: res=>{
console.log(res)
this.userLogin()
},
fail: err=>{
@@ -72,13 +76,15 @@ Page({
})
}
})
}else{
wx.showToast({
title: '拒绝了登录授权',
icon : 'none'
})
}
},
fail : res => {
//拒绝授权
this.showErrorModal('您拒绝了请求');
return;
}
})
},
/**
* 用户登录

View File

@@ -2,4 +2,5 @@
<view class="loginImg">
<image src="/static/img/login_img.png" mode="widthFix"></image>
</view>
<button class="loginBtn" size="mini" hover-class="none" open-type="getUserInfo" bindgetuserinfo="userInfo" lang="zh_CN" disabled="{{isLogin}}">用户授权</button>
<button class="loginBtn" size="mini" hover-class="none" bindtap="getuserInfo" disabled="{{isLogin}}">用户授权</button>

View File

@@ -23,7 +23,7 @@
"compileHotReLoad": false,
"useMultiFrameRuntime": true,
"useApiHook": true,
"useApiHostProcess": false,
"useApiHostProcess": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],