wx.login({ success: res => { this .globalData.code=res.code; // this.getUserInfo(); this .pushUserInfo(); } }) |
pushUserInfo() { let that= this ; wx.request({ url: ‘’ ', method: ' POST ', data: { code: this.globalData.code, }, success(res) { console.log(res); that.globalData.openid = res.data; // 由于 getOpenID 是网络请求,可能会在 Page.onLoad 之后才返回 // if (that.openidReadyCallback) { // //如果存在实例app中存在openidReadyCallback,则将返回的数据回掉给实例中 // that.openidReadyCallback(res) // } that.searchFormId(); }, fail(e) { wx.showToast({ title: ' 获取openid异常 ', icon: ' none', duration: 2000 //持续的时间 }) } }) }, |