提交 7ff18263 作者: 王进

修改无法登陆bug

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