login.js 647 B

12345678910111213141516171819202122232425262728293031323334353637
  1. const app = getApp()
  2. Page({
  3. onShareAppMessage() {
  4. return {
  5. title: '微信登录',
  6. path: 'packageAPI/pages/api/login/login'
  7. }
  8. },
  9. onLoad() {
  10. this.setData({
  11. theme: wx.getSystemInfoSync().theme || 'light'
  12. })
  13. if (wx.onThemeChange) {
  14. wx.onThemeChange(({theme}) => {
  15. this.setData({theme})
  16. })
  17. }
  18. this.setData({
  19. hasLogin: app.globalData.hasLogin
  20. })
  21. },
  22. data: {
  23. theme: 'light',},
  24. login() {
  25. const that = this
  26. wx.login({
  27. success() {
  28. app.globalData.hasLogin = true
  29. that.setData({
  30. hasLogin: true
  31. })
  32. }
  33. })
  34. }
  35. })