laya 发布的体验版小游戏 真机上大概率创建不出获取授权按钮
laya 发布的体验版 有很大的概率 wx.createUserInfoButton在真机上无效 ,创建不出按钮,但在 开发者工具上 每次都可创建出获取授权按钮 是什么原因呢? 是不是因为没正式发布?还是代码有问题?
[代码]private WxLogin() {[代码][代码] [代码][代码]if[代码] [代码](Laya.Browser.onMiniGame) {[代码][代码] [代码][代码]wx.login({[代码][代码] [代码][代码]pkgName: [代码][代码]""[代码][代码],[代码][代码] [代码][代码]success: res => {[代码][代码] [代码][代码]let code = res.code;[代码][代码] [代码][代码]if[代码] [代码](code == [代码][代码]null[代码][代码]) {[代码][代码] [代码][代码]LoginScenesMgr.Instance._CloseGame();[代码][代码] [代码][代码]return[代码][代码];[代码][代码] [代码][代码]} [代码][代码]else[代码] [代码]{[代码][代码] [代码][代码]UserAccInfo.wx_Code = code;[代码][代码] [代码][代码]}[代码][代码] [代码][代码]//获取设置[代码][代码] [代码][代码]wx.getSetting({[代码][代码] [代码][代码]success: (res) => {[代码][代码] [代码][代码]//已经进行了授权[代码][代码] [代码][代码]if[代码] [代码](res.authSetting[[代码][代码]'scope.userInfo'[代码][代码]]) {[代码][代码] [代码][代码]console.log([代码][代码]"已经授权了 直接获取数据 "[代码][代码])[代码][代码] [代码][代码]wx.getUserInfo({[代码][代码] [代码][代码]lang: [代码][代码]"zh_CN"[代码][代码],[代码][代码] [代码][代码]withCredentials: [代码][代码]true[代码][代码],[代码][代码] [代码][代码]success: (res) => {[代码][代码] [代码][代码]LoginScenesMgr.Instance.SetUserWxInfo(res);[代码][代码] [代码][代码]console.log([代码][代码]"已经授权 直接获取信息 成功"[代码][代码]);[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail: () => {[代码][代码] [代码][代码]console.log([代码][代码]"getUserInfo fail"[代码][代码]);[代码][代码] [代码][代码]wx.showModal({[代码][代码] [代码][代码]title: [代码][代码]'友情提醒'[代码][代码],[代码][代码] [代码][代码]cancelText: [代码][代码]"取消"[代码][代码],[代码][代码] [代码][代码]cancelColor: [代码][代码]'#000000'[代码][代码],[代码][代码] [代码][代码]content: [代码][代码]'请允许微信获得授权!'[代码][代码],[代码][代码] [代码][代码]confirmText: [代码][代码]"确定"[代码][代码],[代码][代码] [代码][代码]showCancel: [代码][代码]false[代码][代码],[代码][代码] [代码][代码]confirmColor: [代码][代码]"#3CC51F"[代码][代码],[代码][代码] [代码][代码]success: res => {[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail: () => {[代码][代码] [代码][代码]},[代码][代码] [代码][代码]complete: () => {[代码][代码] [代码][代码]}[代码][代码] [代码][代码]});[代码][代码] [代码][代码]},[代码][代码] [代码][代码]complete: () => {[代码][代码] [代码][代码]}[代码][代码] [代码][代码]});[代码][代码] [代码][代码]} [代码][代码]else[代码] [代码]{[代码][代码] [代码][代码]console.log([代码][代码]"没有授权 创建登陆按钮"[代码][代码]);[代码][代码] [代码][代码]LoginScenesMgr.Instance.wxLoginBtn = wx.createUserInfoButton({[代码][代码] [代码][代码]type: [代码][代码]'image'[代码][代码],[代码][代码] [代码][代码]image: [代码][代码]'res/Ui/wxLogin.png'[代码][代码],[代码][代码] [代码][代码]style:[代码][代码] [代码][代码]{[代码][代码] [代码][代码]left: wx.getSystemInfoSync().windowWidth / 2 - 75,[代码][代码] [代码][代码]bottom: 90,[代码][代码] [代码][代码]width: 150,[代码][代码] [代码][代码]height: 60,[代码][代码] [代码][代码]}[代码][代码] [代码][代码]});[代码][代码] [代码][代码]LoginScenesMgr.Instance.wxLoginBtn.onTap((res) => {[代码][代码] [代码][代码]if[代码] [代码](res.errMsg == [代码][代码]"getUserInfo:ok"[代码][代码]) {[代码][代码] [代码][代码]LoginScenesMgr.Instance.SetUserWxInfo(res);[代码][代码] [代码][代码]console.log([代码][代码]"点击按钮"[代码][代码]);[代码][代码] [代码][代码]}[代码][代码] [代码][代码]else[代码] [代码]{[代码][代码] [代码][代码]wx.showModal({[代码][代码] [代码][代码]title: [代码][代码]'友情提醒'[代码][代码],[代码][代码] [代码][代码]cancelText: [代码][代码]"取消"[代码][代码],[代码][代码] [代码][代码]cancelColor: [代码][代码]'#000000'[代码][代码],[代码][代码] [代码][代码]content: [代码][代码]'请允许微信获得授权!'[代码][代码],[代码][代码] [代码][代码]confirmText: [代码][代码]"确定"[代码][代码],[代码][代码] [代码][代码]showCancel: [代码][代码]false[代码][代码],[代码][代码] [代码][代码]confirmColor: [代码][代码]"#3CC51F"[代码][代码],[代码][代码] [代码][代码]success: res => {[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail: () => {[代码][代码] [代码][代码]},[代码][代码] [代码][代码]complete: () => {[代码][代码] [代码][代码]}[代码][代码] [代码][代码]});[代码][代码] [代码][代码]}[代码][代码] [代码][代码]});[代码][代码] [代码][代码]}[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail: () => {[代码][代码] [代码][代码]LoginScenesMgr.Instance._CloseGame();[代码][代码] [代码][代码]console.log([代码][代码]"getSetting fail"[代码][代码]);[代码][代码] [代码][代码]},[代码][代码] [代码][代码]complete: () => {[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码]//wx.getSetting[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail: () => {[代码][代码] [代码][代码]console.log([代码][代码]"wx.login"[代码][代码]);[代码][代码] [代码][代码]LoginScenesMgr.Instance._CloseGame();[代码][代码] [代码][代码]},[代码][代码] [代码][代码]complete: () => { }[代码][代码] [代码][代码]});[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码]