提交 7ecfb597 作者: 王进

提示升级微信

上级 54106925
......@@ -120,9 +120,8 @@ class WechatSDK {
console.log(err)
})
}
private doLogin(res, LoginCallBack, target?) {
private doLogin(res, LoginCallBack) {
const that = this
if(target) target.destroy()
// 获取用户信息
const userInfo = res
const UserObj = {
......@@ -587,56 +586,27 @@ class WechatSDK {
const that = this
const w = (wx as any).getSystemInfoSync().windowWidth
const h = (wx as any).getSystemInfoSync().windowHeight
let UserInfoButton; // 按钮对象
const BtnObjParam = { // 按钮样式
type: 'text',
text: ' ',
style: {
left: 0,
top: 0,
width: w,
height: h,
backgroundColor: 'rgba(0, 0, 0, 0)',
color: '#ffffff'
}
}
if ((wx as any).createUserInfoButton) { // 做兼容
UserInfoButton = (wx as any).createUserInfoButton(BtnObjParam)
const UserInfoButton = (wx as any).createUserInfoButton({ // 按钮样式
type: 'text',
text: ' ',
style: {
left: 0,
top: 0,
width: w,
height: h,
backgroundColor: 'rgba(0, 0, 0, 0)',
color: '#ffffff'
}
})
UserInfoButton.onTap(res => {
if (res.userInfo) that.doLogin(res, LoginCallBack, UserInfoButton) // 用户重新授权
UserInfoButton.destroy()
if (res.userInfo) that.doLogin(res, LoginCallBack) // 用户重新授权
})
} else {
UserInfoButton = (wx as any).createopenSettingButton(BtnObjParam)
UserInfoButton.onTap(async res => {
const status = await that.getSetting();
if (status == 1) {
const userInfo = await that.getUserInfo();
if(userInfo) that.doLogin(userInfo, LoginCallBack, UserInfoButton)
}
})
that.sdkAlert('微信版本过低,请升级客户端。')
}
}
private async getSetting(): Promise<any> { //获取授权配置
return new Promise((resolve, reject) => {
(wx as any).getSetting({
success: res => {
const authSetting = res.authSetting
if (authSetting['scope.userInfo'] === true) {
resolve(1)
} else if (authSetting['scope.userInfo'] === false) {
resolve(0)
} else {
resolve(-1)
}
},
fail: () => {
reject()
},
complete: () => { }
})
})
}
}
// md5加密
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论