app.js 862 B

1234567891011121314151617181920212223242526272829303132
  1. // app.js
  2. import {
  3. xcxdl
  4. } from "./apis/index"
  5. import authorize from "./utils/authorize"
  6. App({
  7. onLaunch() {
  8. // 登录
  9. let publicId = wx.getStorageSync("PUBLIC_ID")
  10. if (!publicId || !publicId.openid || !publicId.unionid) {
  11. wx.login({
  12. success: res => {
  13. xcxdl({
  14. js_code: res.code
  15. }).then((res) => {
  16. if (res.code == 200) {
  17. wx.setStorageSync('PUBLIC_ID', {
  18. openid: res.openid,
  19. unionid: res.unionid
  20. })
  21. }
  22. })
  23. }
  24. })
  25. }
  26. // 用户鉴权
  27. this.globalData = {
  28. authorize: authorize
  29. }
  30. },
  31. })