user-authentication.js 584 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. const app = getApp()
  2. Page({
  3. onShareAppMessage() {
  4. return {
  5. title: '用户鉴权',
  6. path: 'page/cloud/pages/user-authentication/user-authentication'
  7. }
  8. },
  9. data: {
  10. openid: '',
  11. loading: false
  12. },
  13. onGetOpenid() {
  14. this.setData({
  15. loading: true
  16. })
  17. app.getUserOpenIdViaCloud()
  18. .then(openid => {
  19. this.setData({
  20. openid,
  21. loading: false
  22. })
  23. return openid
  24. })
  25. .catch(err => {
  26. console.error(err)
  27. })
  28. },
  29. clear() {
  30. this.setData({
  31. openid: '',
  32. })
  33. }
  34. })