解决方案就是在app.js加一个回调函数
wx.login({
fail: res => {
console.log(res)
},
success: res => {
util.request(api.dl, {
code: res.code,
}, "GET").then(res => {
if (this.employIdCallback){
this.employIdCallback(res);
}
this.globalData.userid=res
然后在你的首页onLoad进行判断是否有这个值然后进行不同的逻辑
onLoad: function (options) {
console.log( )
if(!app.globalData.userid){
this.getstore()
this.getfl()
}else{
app.employIdCallback= param1=> {
this.getstore()
this.getfl()
}
}
},
试试新出炉的,用完真香定律https://developers.weixin.qq.com/community/develop/article/doc/00002ac57208f0e7335d111f156013