http://es6.ruanyifeng.com/#docs/promise 推荐你看下promise的语法,学习下es6,callback的写法不利于阅读
关于切换账号第一次解密失败希望得到帮助。 场景,本地微信授权获取用户头像信息,真机同个微信账号授权第一次会解密失败,需要第二次再code 是不是哪里业务错了还是 ,希望得到帮助 [代码]//绑定微信[代码][代码]bindGetUserInfo: [代码][代码]function[代码] [代码](e,callback) {[代码][代码] [代码][代码]var[代码] [代码]that=[代码][代码]this[代码][代码];[代码][代码] [代码] [代码] [代码][代码]var[代码] [代码]id=wx.getStorageSync([代码][代码]'id'[代码][代码])[代码][代码] [代码][代码]var[代码] [代码]loginsalt=wx.getStorageSync([代码][代码]'loginsalt'[代码][代码])[代码][代码] [代码][代码]if[代码][代码](!id || !loginsalt){[代码][代码] [代码][代码]/*wx.reLaunch({[代码][代码] [代码][代码]url: '/pages/login/login'[代码][代码] [代码][代码]})[代码][代码] [代码][代码]return;*/[代码][代码] [代码][代码]}[代码][代码] [代码][代码]if[代码] [代码]([代码][代码]typeof[代码] [代码]callback !== [代码][代码]'function'[代码][代码]) {[代码][代码] [代码][代码]callback = [代码][代码]function[代码] [代码]callback() {};[代码][代码] [代码][代码]}[代码][代码] [代码][代码]if[代码] [代码](e.detail.userInfo) {[代码][代码] [代码][代码]wx.showLoading({[代码][代码] [代码][代码]title: [代码][代码]'加载中'[代码][代码],[代码][代码] [代码][代码]mask:[代码][代码]true[代码][代码] [代码][代码]})[代码][代码] [代码][代码]wx.login({[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码]success(data) {[代码][代码] [代码][代码]wx.getSetting({[代码][代码] [代码][代码]success: res => {[代码][代码] [代码][代码]if[代码] [代码](res.authSetting[[代码][代码]'scope.userInfo'[代码][代码]]) { [代码][代码] [代码][代码]wx.getUserInfo({[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码]success(res) {[代码][代码] [代码][代码]wx.request({[代码][代码] [代码][代码]url: that.data.url+[代码][代码]'wechat/wxapp_userinfo'[代码][代码],[代码][代码] [代码][代码]data: {[代码][代码] [代码][代码]id:id,[代码][代码] [代码][代码]loginsalt:loginsalt,[代码][代码] [代码][代码]code: data.code,[代码][代码] [代码][代码]encryptedData: res.encryptedData,[代码][代码] [代码][代码]iv: res.iv[代码][代码] [代码][代码]},[代码][代码] [代码][代码]success(res) {[代码][代码] [代码][代码]//解密失败 -41003[代码][代码] [代码][代码]//工具微信授权用户信息后,真机再同个微信授权用户信息第一次就解密失败[代码][代码] [代码] [代码] [代码][代码]wx.hideLoading();[代码][代码] [代码][代码]if[代码][代码](res.data.ret==1){[代码][代码] [代码][代码]callback(res.data);[代码][代码] [代码][代码]}[代码][代码]else[代码][代码]{[代码][代码] [代码][代码]wx.showToast({[代码][代码] [代码][代码]title: res.data.msg,[代码][代码] [代码][代码]icon: [代码][代码]'none'[代码][代码],[代码][代码] [代码][代码]duration: 3000[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]},fail(){[代码][代码] [代码][代码]wx.hideLoading();[代码][代码] [代码][代码]wx.showToast({[代码][代码] [代码][代码]title: [代码][代码]'网络异常'[代码][代码],[代码][代码] [代码][代码]icon: [代码][代码]'none'[代码][代码],[代码][代码] [代码][代码]duration: 3000[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]});[代码][代码] [代码][代码]}[代码][代码]else[代码][代码]{[代码][代码] [代码][代码]//wx.redirectTo({ url: '/pages/users/getuinfo/getuinfo' });[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码] [代码] [代码][代码]}[代码][代码] [代码][代码]});[代码][代码] [代码][代码]}[代码][代码]}[代码]
2019-05-10