app.js 580 B

123456789101112131415161718192021
  1. // app.js
  2. App({
  3. onLaunch() {
  4. wx.login({
  5. success: res => {
  6. wx.request({
  7. url: `https://api.weixin.qq.com/sns/jscode2session?appid=wx2f97e348556960c3&secret=18baa11279fd9854c68220dbf23d33e4&js_code=${res.code}&grant_type=authorization_code`,
  8. success: (res) => {
  9. this.globalData.openid= res.data.openid
  10. }
  11. })
  12. }
  13. });
  14. },
  15. globalData: {
  16. userId: null,//扫描二维码获取的id
  17. openid: null,//使用者的openid
  18. type:null, //类型是监护人还是监护对象
  19. // 监护对象的id
  20. }
  21. })