// app.js App({ onLaunch() { wx.login({ success: res => { wx.request({ url: `https://api.weixin.qq.com/sns/jscode2session?appid=wx2f97e348556960c3&secret=18baa11279fd9854c68220dbf23d33e4&js_code=${res.code}&grant_type=authorization_code`, success: (res) => { this.globalData.openid= res.data.openid } }) } }); }, globalData: { userId: null,//扫描二维码获取的id openid: null,//使用者的openid type:null, //类型是监护人还是监护对象 // 监护对象的id } })