app.js 812 B

1234567891011121314151617181920212223242526272829303132333435
  1. /**
  2. * @Description: app entrypoint
  3. * @Date: 2022年10月20日 Thursday
  4. * @Author liuyuqi.gov@msn.
  5. */
  6. App({
  7. onLaunch: function () {
  8. //调用API从本地缓存中获取数据
  9. var logs = wx.getStorageSync('logs') || []
  10. logs.unshift(Date.now())
  11. wx.setStorageSync('logs', logs)
  12. },
  13. getUserInfo:function(cb){
  14. var that = this
  15. if(this.globalData.userInfo){
  16. typeof cb == "function" && cb(this.globalData.userInfo)
  17. }else{
  18. //调用登录接口
  19. wx.login({
  20. success: function () {
  21. wx.getUserInfo({
  22. success: function (res) {
  23. that.globalData.userInfo = res.userInfo
  24. typeof cb == "function" && cb(that.globalData.userInfo)
  25. }
  26. })
  27. }
  28. })
  29. }
  30. },
  31. globalData:{
  32. userInfo:null
  33. }
  34. })