user-authentication.js 820 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. const app = getApp()
  2. Page({
  3. onShareAppMessage() {
  4. return {
  5. title: '用户鉴权',
  6. path: 'packageCloud/pages/user/user-authentication/user-authentication'
  7. }
  8. },
  9. data: {
  10. theme: 'light',
  11. openid: '',
  12. loading: false
  13. },
  14. onGetOpenid() {
  15. this.setData({
  16. loading: true
  17. })
  18. app.getUserOpenIdViaCloud()
  19. .then(openid => {
  20. this.setData({
  21. openid,
  22. loading: false
  23. })
  24. return openid
  25. })
  26. .catch(err => {
  27. console.error(err)
  28. })
  29. },
  30. clear() {
  31. this.setData({
  32. openid: '',
  33. })
  34. },
  35. onLoad() {
  36. this.setData({
  37. theme: wx.getSystemInfoSync().theme || 'light'
  38. })
  39. if (wx.onThemeChange) {
  40. wx.onThemeChange(({theme}) => {
  41. this.setData({theme})
  42. })
  43. }
  44. }
  45. })