login-pannel.js 927 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { loginByUserInfo } from './../../utils/login'
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. properties: {
  7. visible: Boolean
  8. },
  9. /**
  10. * 组件的初始数据
  11. */
  12. data: {
  13. show: false
  14. },
  15. ready () {
  16. this.showPannel()
  17. wx.login({
  18. success: (res) => {
  19. this.wx_code = res.code
  20. }
  21. })
  22. },
  23. /**
  24. * 组件的方法列表
  25. */
  26. methods: {
  27. bindgetuserinfo (e) {
  28. if (!e.detail.userInfo) {
  29. return
  30. }
  31. loginByUserInfo(e.detail, this.wx_code).then(res => {
  32. this.triggerEvent('loginSuccess')
  33. })
  34. },
  35. showPannel () {
  36. this.animation = wx.createAnimation({
  37. duration: 200,
  38. timingFunction: 'ease'
  39. })
  40. this.animation.translateY(8).step()
  41. this.setData({
  42. animationData: this.animation.export(),
  43. show: true
  44. })
  45. },
  46. hide () {
  47. this.triggerEvent('hide')
  48. }
  49. }
  50. })