提交 7ff18263 作者: 王进

修改无法登陆bug

上级 81356bf0
...@@ -15,7 +15,6 @@ class WechatSDK { ...@@ -15,7 +15,6 @@ class WechatSDK {
this.sdkinit() this.sdkinit()
} }
private debug: number // 1是测试模式,用于printf函数输出 private debug: number // 1是测试模式,用于printf函数输出
private isAuthorize: boolean = false // 用户授权状态
private sdkinit() { private sdkinit() {
const that = this const that = this
//配置默认参数 //配置默认参数
...@@ -88,15 +87,6 @@ class WechatSDK { ...@@ -88,15 +87,6 @@ class WechatSDK {
that.ReportData({ // 上报统计授权 that.ReportData({ // 上报统计授权
action: 'activation' action: 'activation'
}) })
//获取用户授权状态
this.getOpenSetting().then(res => {
if (res == 0) {
this.createUserInfoButton()
}
that.isAuthorize = (res == 1)
}, err => {
console.log('获取授权状态-->', err)
})
}, err => { console.log(err) }) }, err => { console.log(err) })
} }
private obj = { initReady: 0 } private obj = { initReady: 0 }
...@@ -122,16 +112,21 @@ class WechatSDK { ...@@ -122,16 +112,21 @@ class WechatSDK {
//用户授权操作 //用户授权操作
private doAuthorize(LoginCallBack) { private doAuthorize(LoginCallBack) {
const that = this const that = this
// 用户授权 //获取用户授权状态
if (this.isAuthorize) { this.getOpenSetting().then(res => {
if (res == 1) {
this.getUserInfo().then(res => { this.getUserInfo().then(res => {
that.doLogin(res, LoginCallBack) that.doLogin(res, LoginCallBack)
}, err => { }, err => {
console.log("获取用户信息失败-->", err) console.log("获取用户信息失败-->", err)
}) })
} else { } else {
this.createUserInfoButton() this.createUserInfoButton(LoginCallBack)
} }
}, err => {
console.log('获取授权状态-->', err)
this.createUserInfoButton(LoginCallBack)
})
} }
private doLogin(res, LoginCallBack) { private doLogin(res, LoginCallBack) {
const that = this const that = this
...@@ -601,7 +596,7 @@ class WechatSDK { ...@@ -601,7 +596,7 @@ class WechatSDK {
return (wx as any).getLaunchOptionsSync() return (wx as any).getLaunchOptionsSync()
} }
private createUserInfoButton() { private createUserInfoButton(LoginCallBack) {
const that = this const that = this
const w = (wx as any).getSystemInfoSync().windowWidth const w = (wx as any).getSystemInfoSync().windowWidth
const h = (wx as any).getSystemInfoSync().windowHeight const h = (wx as any).getSystemInfoSync().windowHeight
...@@ -620,8 +615,7 @@ class WechatSDK { ...@@ -620,8 +615,7 @@ class WechatSDK {
}) })
UserInfoButton.onTap(res => { UserInfoButton.onTap(res => {
if (res.userInfo) { // 根据返回数据判断用户是否授权 if (res.userInfo) { // 根据返回数据判断用户是否授权
// that.doLogin(res, LoginCallBack) // 用户重新授权 that.doLogin(res, LoginCallBack) // 用户重新授权
that.isAuthorize = true
UserInfoButton.destroy() UserInfoButton.destroy()
} }
}) })
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论