[更新]
This commit is contained in:
@@ -43,41 +43,47 @@ Page({
|
||||
},
|
||||
|
||||
/**
|
||||
* 登录
|
||||
* 微信授权登录
|
||||
*/
|
||||
userInfo(e){
|
||||
if(e.detail.errMsg == "getUserInfo:ok"){
|
||||
this.setData({
|
||||
isLogin : true,
|
||||
userInfo : e.detail.rawData,
|
||||
iv : e.detail.iv,
|
||||
encryptedData : e.detail.encryptedData
|
||||
})
|
||||
|
||||
// 检查用户登录Code是否过期
|
||||
wx.checkSession({
|
||||
success: res=>{
|
||||
this.userLogin()
|
||||
},
|
||||
fail: err=>{
|
||||
// 登录过期重新获取code
|
||||
wx.login({
|
||||
getuserInfo() {
|
||||
wx.getUserProfile({
|
||||
desc : "获取你的昵称、头像、地区及性别",
|
||||
success : e => {
|
||||
console.log(e)
|
||||
if(e.errMsg == "getUserProfile:ok"){
|
||||
this.setData({
|
||||
isLogin : true,
|
||||
userInfo : e.rawData,
|
||||
iv : e.iv,
|
||||
encryptedData : e.encryptedData
|
||||
})
|
||||
// 检查用户登录Code是否过期
|
||||
wx.checkSession({
|
||||
success: res=>{
|
||||
this.setData({
|
||||
loginCode: res.code
|
||||
})
|
||||
// 登录
|
||||
console.log(res)
|
||||
this.userLogin()
|
||||
},
|
||||
fail: err=>{
|
||||
// 登录过期重新获取code
|
||||
wx.login({
|
||||
success: res=>{
|
||||
this.setData({
|
||||
loginCode: res.code
|
||||
})
|
||||
// 登录
|
||||
this.userLogin()
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}else{
|
||||
wx.showToast({
|
||||
title: '拒绝了登录授权',
|
||||
icon : 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
fail : res => {
|
||||
//拒绝授权
|
||||
this.showErrorModal('您拒绝了请求');
|
||||
return;
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -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>
|
||||
@@ -23,7 +23,7 @@
|
||||
"compileHotReLoad": false,
|
||||
"useMultiFrameRuntime": true,
|
||||
"useApiHook": true,
|
||||
"useApiHostProcess": false,
|
||||
"useApiHostProcess": true,
|
||||
"babelSetting": {
|
||||
"ignore": [],
|
||||
"disablePlugins": [],
|
||||
|
||||
Reference in New Issue
Block a user