import { loginByUserInfo } from './../../utils/login'
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    visible: Boolean
  },

  /**
   * 组件的初始数据
   */
  data: {
    show: false
  },
  ready () {
    this.showPannel()
    wx.login({
      success: (res) => {
        this.wx_code = res.code
      }
  })
  },
  /**
   * 组件的方法列表
   */
  methods: {
    bindgetuserinfo (e) {
      if (!e.detail.userInfo) {
        return
      }
      loginByUserInfo(e.detail, this.wx_code).then(res => {
        this.triggerEvent('loginSuccess')
      })
    },
    showPannel () {
      this.animation = wx.createAnimation({
        duration: 200,
        timingFunction: 'ease'
      })
      this.animation.translateY(8).step()
      this.setData({
        animationData: this.animation.export(),
        show: true
      })
    },
    hide () {
      this.triggerEvent('hide')
    }
  }
})
